refactor(selector): simplify presets with data-driven groups

This commit is contained in:
2026-02-24 20:28:03 +08:00
parent 5e665966db
commit f8eb2f6563
4 changed files with 118 additions and 92 deletions

View File

@@ -3,6 +3,7 @@ import { computed } from 'vue';
import { useDialogs } from '@/ts/useDialogs';
import { getLogicFlowInstance } from '@/ts/useLogicFlow';
import { SELECTOR_PRESETS } from '@/configs/selectorPresets';
import type { SelectorConfig } from '@/types/selector';
const props = defineProps<{
node: any;
@@ -10,30 +11,29 @@ const props = defineProps<{
const { openGenericSelector } = useDialogs();
// 当前选中的资产库
const currentLibrary = computed(() => props.node.properties?.assetLibrary || 'shikigami');
// 当前选中的资产
const currentAsset = computed(() => {
return props.node.properties?.selectedAsset || { name: '未选择' };
});
// 打开选择器
const handleOpenSelector = () => {
const lf = getLogicFlowInstance();
const node = props.node;
if (!lf || !node) return;
const library = currentLibrary.value;
const config = SELECTOR_PRESETS[library];
const preset = SELECTOR_PRESETS[library];
if (!config) {
if (!preset) {
console.error('未找到资产库配置:', library);
return;
}
// 设置当前选中项
config.currentItem = node.properties?.selectedAsset;
const config: SelectorConfig = {
...preset,
currentItem: node.properties?.selectedAsset || null
};
openGenericSelector(config, (selectedItem) => {
lf.setProperties(node.id, {
@@ -80,4 +80,4 @@ const handleOpenSelector = () => {
color: #606266;
margin-bottom: 8px;
}
</style>
</style>