fix: 视频时长统一使用模型选项下拉框

This commit is contained in:
GouJ committed 2026-09-25 20:21:20 +08:00
1 parent e5a65e514e
commit b242014af2
1 file changed
+18 -1
@@ -48,9 +48,19 @@ function updateOption(key: string, value: string | number | boolean | null) {
}
function choices(item: GenerationModelItem['generationOptions'][number]): SelectOption[] {
return [...(item.options ?? []), ...(item.specialValues ?? [])]
const options = [...(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 }))
if (
/duration|时长/i.test(`${item.key} ${item.label}`) &&
Number.isInteger(item.min) &&
Number.isInteger(item.max) &&
item.max! >= item.min! &&
item.max! - item.min! <= 60
) {
for (let value = item.min!; value <= item.max!; value++) options.push({ label: `${value} 秒`, value })
}
return options
}
function selectValue(key: string): string | number | null {
@@ -88,6 +98,13 @@ function selectValue(key: string): string | number | null {
/>
<span class="text-xs">{{ options[item.key] ? '已启用' : '未启用' }}</span>
</div>
<NSelect
v-else-if="/duration|时长/i.test(`${item.key} ${item.label}`)"
:value="selectValue(item.key)"
:options="choices(item)"
:disabled="disabled || item.userEditable === false"
@update:value="updateOption(item.key, $event)"
/>
<NInputNumber
v-else-if="item.type === 'integer' || item.type === 'number'"
:value="typeof options[item.key] === 'number' ? Number(options[item.key]) : null"