fix: 收紧生成参数选择器类型

This commit is contained in:
GouJ committed 2026-09-24 18:21:12 +08:00
1 parent 6341911abd
commit ba03e7b92f
1 file changed
+10 -2
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { computed } from 'vue'
import { NFormItem, NInputNumber, NSelect, NSwitch, NTag } from 'naive-ui'
import type { SelectOption } from 'naive-ui'
import type { CreativeProfileAspectRatio, GenerationModelCatalog, GenerationModelItem, GenerationOptions } from '../types'
const props = defineProps<{
@@ -39,8 +40,15 @@ function updateOption(key: string, value: string | number | boolean | null) {
emit('update:options', next)
}
function choices(item: GenerationModelItem['generationOptions'][number]) {
function choices(item: GenerationModelItem['generationOptions'][number]): SelectOption[] {
return [...(item.options ?? []), ...(item.specialValues ?? [])]
.filter(option => typeof option.value === 'string' || typeof option.value === 'number')
.map(option => ({ label: option.label, value: option.value as string | number }))
}
function selectValue(key: string): string | number | null {
const value = props.options[key]
return typeof value === 'string' || typeof value === 'number' ? value : null
}
</script>
@@ -73,7 +81,7 @@ function choices(item: GenerationModelItem['generationOptions'][number]) {
/>
<NSelect
v-else
:value="options[item.key] ?? null"
:value="selectValue(item.key)"
:options="choices(item)"
:disabled="disabled || item.userEditable === false"
@update:value="updateOption(item.key, $event)"