From 6375b45f3a5a01b340ed3eb47d6e03bdab7969db Mon Sep 17 00:00:00 2001 From: zhx Date: Wed, 20 May 2026 12:01:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AC=E7=9B=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/props-source-select-drawer.vue | 59 ++++++++++++++----- .../views/resident-activity/wheel-config.vue | 15 ++++- 2 files changed, 59 insertions(+), 15 deletions(-) diff --git a/apps/src/views/operate/components/props-source-select-drawer.vue b/apps/src/views/operate/components/props-source-select-drawer.vue index 4f8da3c..f5e77ac 100644 --- a/apps/src/views/operate/components/props-source-select-drawer.vue +++ b/apps/src/views/operate/components/props-source-select-drawer.vue @@ -20,14 +20,21 @@ import { defineOptions({ name: 'OperatePropsSourceSelectDrawer' }); +type SourceTypeOption = { + label: string; + value: string; +}; + const props = withDefaults( defineProps<{ defaultType?: string; open: boolean; sysOrigin: string; + typeOptions?: SourceTypeOption[]; }>(), { defaultType: 'AVATAR_FRAME', + typeOptions: undefined, }, ); @@ -36,11 +43,6 @@ const emit = defineEmits<{ select: [item: SourceItem]; }>(); -type SourceTypeOption = { - label: string; - value: string; -}; - type SourceItem = { amount?: number | string; cover?: string; @@ -62,12 +64,21 @@ const TYPE_OPTIONS: SourceTypeOption[] = [ { label: '聊天气泡', value: 'CHAT_BUBBLE' }, { label: '飘窗', value: 'FLOAT_PICTURE' }, { label: '碎片', value: 'FRAGMENTS' }, + { label: '资料卡', value: 'DATA_CARD' }, ]; -const typeSelectOptions = TYPE_OPTIONS.map((item) => ({ - label: item.label, - value: item.value as any, -})); +const effectiveTypeOptions = computed(() => + (props.typeOptions && props.typeOptions.length > 0 ? props.typeOptions : TYPE_OPTIONS).map( + (item) => ({ + label: item.label, + value: item.value as any, + }), + ), +); + +const allowedTypeSet = computed( + () => new Set(effectiveTypeOptions.value.map((item) => String(item.value))), +); const loading = ref(false); const keyword = ref(''); @@ -197,13 +208,21 @@ function formatSourcePrice(amount: number | string | undefined) { return `${amount} 金币`; } +function resolveSourceType(type?: string) { + const value = String(type || '').trim(); + if (value && allowedTypeSet.value.has(value)) { + return value; + } + return String(effectiveTypeOptions.value[0]?.value || 'AVATAR_FRAME'); +} + watch( () => props.open, (open) => { if (!open) { return; } - query.propsType = props.defaultType || 'AVATAR_FRAME'; + query.propsType = resolveSourceType(props.defaultType); keyword.value = ''; void loadSource(query.propsType); }, @@ -213,14 +232,26 @@ watch( watch( () => props.defaultType, (value) => { - if (!props.open || !value) { + if (!props.open) { return; } - query.propsType = value; - void loadSource(value); + query.propsType = resolveSourceType(value); + void loadSource(query.propsType); }, ); +watch( + () => props.typeOptions, + () => { + if (!props.open) { + return; + } + query.propsType = resolveSourceType(query.propsType || props.defaultType); + void loadSource(query.propsType); + }, + { deep: true }, +); + watch( () => props.sysOrigin, () => { @@ -327,7 +358,7 @@ function handleSelect(item: SourceItem) {