fix: align canvas model options with backend
This commit is contained in:
@@ -88,6 +88,11 @@ const setStoredJson = (key, value) => {
|
||||
}
|
||||
}
|
||||
|
||||
const getValidStoredModel = (key, defaultValue, builtInModels) => {
|
||||
const stored = getStored(key, defaultValue)
|
||||
return builtInModels.some(model => model.key === stored) ? stored : defaultValue
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查模型是否支持指定渠道
|
||||
*/
|
||||
@@ -160,8 +165,8 @@ export const useModelStore = defineStore('model', () => {
|
||||
|
||||
// 选中的模型
|
||||
const selectedChatModel = ref(getStored(STORAGE_KEYS.SELECTED_CHAT_MODEL, DEFAULT_CHAT_MODEL))
|
||||
const selectedImageModel = ref(getStored(STORAGE_KEYS.SELECTED_IMAGE_MODEL, DEFAULT_IMAGE_MODEL))
|
||||
const selectedVideoModel = ref(getStored(STORAGE_KEYS.SELECTED_VIDEO_MODEL, DEFAULT_VIDEO_MODEL))
|
||||
const selectedImageModel = ref(getValidStoredModel(STORAGE_KEYS.SELECTED_IMAGE_MODEL, DEFAULT_IMAGE_MODEL, IMAGE_MODELS))
|
||||
const selectedVideoModel = ref(getValidStoredModel(STORAGE_KEYS.SELECTED_VIDEO_MODEL, DEFAULT_VIDEO_MODEL, VIDEO_MODELS))
|
||||
|
||||
// 按渠道存储的 API 配置
|
||||
const apiKeysByProvider = ref(getStoredJson(STORAGE_KEYS.API_KEYS_BY_PROVIDER, {}))
|
||||
@@ -205,47 +210,13 @@ export const useModelStore = defineStore('model', () => {
|
||||
}))
|
||||
])
|
||||
|
||||
const allImageModels = computed(() => [
|
||||
...IMAGE_MODELS.map(m => ({ ...m, isCustom: false })),
|
||||
...customImageModels.value.map(m => ({
|
||||
label: m.label || m.key,
|
||||
key: m.key,
|
||||
isCustom: true,
|
||||
sizes: [],
|
||||
defaultParams: { quality: 'standard', style: 'vivid' }
|
||||
})),
|
||||
// 添加当前渠道的自定义模型
|
||||
...(customImageModelsByProvider.value[currentProvider.value] || []).map(m => ({
|
||||
label: m.label || m.key,
|
||||
key: m.key,
|
||||
isCustom: true,
|
||||
sizes: [],
|
||||
defaultParams: { quality: 'standard', style: 'vivid' },
|
||||
provider: [currentProvider.value]
|
||||
}))
|
||||
])
|
||||
const allImageModels = computed(() =>
|
||||
IMAGE_MODELS.map(m => ({ ...m, isCustom: false }))
|
||||
)
|
||||
|
||||
const allVideoModels = computed(() => [
|
||||
...VIDEO_MODELS.map(m => ({ ...m, isCustom: false })),
|
||||
...customVideoModels.value.map(m => ({
|
||||
label: m.label || m.key,
|
||||
key: m.key,
|
||||
isCustom: true,
|
||||
ratios: ['16x9', '9:16', '1:1'],
|
||||
durs: [{ label: '5 秒', key: 5 }, { label: '10 秒', key: 10 }],
|
||||
defaultParams: { ratio: '16:9', duration: 5 }
|
||||
})),
|
||||
// 添加当前渠道的自定义模型
|
||||
...(customVideoModelsByProvider.value[currentProvider.value] || []).map(m => ({
|
||||
label: m.label || m.key,
|
||||
key: m.key,
|
||||
isCustom: true,
|
||||
ratios: ['16x9', '9:16', '1:1'],
|
||||
durs: [{ label: '5 秒', key: 5 }, { label: '10 秒', key: 10 }],
|
||||
defaultParams: { ratio: '16:9', duration: 5 },
|
||||
provider: [currentProvider.value]
|
||||
}))
|
||||
])
|
||||
const allVideoModels = computed(() =>
|
||||
VIDEO_MODELS.map(m => ({ ...m, isCustom: false }))
|
||||
)
|
||||
|
||||
// ============ Computed: Available Models (filtered by provider) ============
|
||||
|
||||
@@ -412,29 +383,12 @@ export const useModelStore = defineStore('model', () => {
|
||||
provider: [provider]
|
||||
}))
|
||||
]
|
||||
const image = [
|
||||
...IMAGE_MODELS.filter(m => isModelSupported(m, provider)).map(m => ({ ...m, isCustom: false })),
|
||||
...(customImageModelsByProvider.value[provider] || []).map(m => ({
|
||||
label: m.label || m.key,
|
||||
key: m.key,
|
||||
isCustom: true,
|
||||
sizes: [],
|
||||
defaultParams: { quality: 'standard', style: 'vivid' },
|
||||
provider: [provider]
|
||||
}))
|
||||
]
|
||||
const video = [
|
||||
...VIDEO_MODELS.filter(m => isModelSupported(m, provider)).map(m => ({ ...m, isCustom: false })),
|
||||
...(customVideoModelsByProvider.value[provider] || []).map(m => ({
|
||||
label: m.label || m.key,
|
||||
key: m.key,
|
||||
isCustom: true,
|
||||
ratios: ['16x9', '9:16', '1:1'],
|
||||
durs: [{ label: '5 秒', key: 5 }, { label: '10 秒', key: 10 }],
|
||||
defaultParams: { ratio: '16:9', duration: 5 },
|
||||
provider: [provider]
|
||||
}))
|
||||
]
|
||||
const image = IMAGE_MODELS
|
||||
.filter(m => isModelSupported(m, provider))
|
||||
.map(m => ({ ...m, isCustom: false }))
|
||||
const video = VIDEO_MODELS
|
||||
.filter(m => isModelSupported(m, provider))
|
||||
.map(m => ({ ...m, isCustom: false }))
|
||||
return { chat, image, video }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user