auto-save 2026-05-27 17:51 (~4)
This commit is contained in:
@@ -139,6 +139,45 @@ const normalizeRuntimeImageModel = (item) => {
|
||||
}
|
||||
}
|
||||
|
||||
const normalizeRuntimeDurationOptions = (items = []) => {
|
||||
if (!Array.isArray(items)) return []
|
||||
return items
|
||||
.map(item => {
|
||||
const key = typeof item === 'object' ? item?.value || item?.key || item?.id : item
|
||||
if (!key) return null
|
||||
return {
|
||||
label: typeof item === 'object' ? item.label || `${key} 秒` : `${key} 秒`,
|
||||
key
|
||||
}
|
||||
})
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
const normalizeRuntimeVideoModel = (item) => {
|
||||
const key = item?.id || item?.model
|
||||
if (!key) return null
|
||||
const sizeOptions = normalizeRuntimeSizeOptions(item.size_options)
|
||||
const durationOptions = normalizeRuntimeDurationOptions(item.duration_options)
|
||||
return {
|
||||
label: item.label || item.model || key,
|
||||
key,
|
||||
provider: ['chatfire'],
|
||||
type: 't2v+i2v',
|
||||
model: item.model,
|
||||
ratios: sizeOptions.map(option => option.key),
|
||||
durs: durationOptions,
|
||||
resolutions: ['720p'],
|
||||
defaultResolution: '720p',
|
||||
defaultParams: {
|
||||
ratio: sizeOptions[0]?.key || '720x1280',
|
||||
duration: durationOptions[0]?.key || 5,
|
||||
resolution: '720p'
|
||||
},
|
||||
available: item.available !== false,
|
||||
isRuntime: true
|
||||
}
|
||||
}
|
||||
|
||||
const mergeModels = (builtInModels, runtimeModels) => {
|
||||
const byKey = new Map()
|
||||
builtInModels.forEach(model => byKey.set(model.key, { ...model, isCustom: false }))
|
||||
@@ -206,6 +245,7 @@ export const useModelStore = defineStore('model', () => {
|
||||
const customImageModelsByProvider = ref(getStoredJson(STORAGE_KEYS.CUSTOM_IMAGE_MODELS_BY_PROVIDER, {}))
|
||||
const customVideoModelsByProvider = ref(getStoredJson(STORAGE_KEYS.CUSTOM_VIDEO_MODELS_BY_PROVIDER, {}))
|
||||
const runtimeImageModels = ref([])
|
||||
const runtimeVideoModels = ref([])
|
||||
|
||||
// 选中的模型
|
||||
const selectedChatModel = ref(getStored(STORAGE_KEYS.SELECTED_CHAT_MODEL, DEFAULT_CHAT_MODEL))
|
||||
@@ -259,7 +299,7 @@ export const useModelStore = defineStore('model', () => {
|
||||
)
|
||||
|
||||
const allVideoModels = computed(() =>
|
||||
VIDEO_MODELS.map(m => ({ ...m, isCustom: false }))
|
||||
mergeModels(VIDEO_MODELS, runtimeVideoModels.value)
|
||||
)
|
||||
|
||||
// ============ Computed: Available Models (filtered by provider) ============
|
||||
@@ -274,7 +314,7 @@ export const useModelStore = defineStore('model', () => {
|
||||
)
|
||||
|
||||
const availableVideoModels = computed(() =>
|
||||
allVideoModels.value.filter(m => isModelSupported(m, currentProvider.value))
|
||||
allVideoModels.value.filter(m => isModelSupported(m, currentProvider.value) && m.available !== false)
|
||||
)
|
||||
|
||||
// ============ Computed: Model Options for UI (all models, not filtered by provider) ============
|
||||
@@ -291,7 +331,8 @@ export const useModelStore = defineStore('model', () => {
|
||||
const allVideoModelOptions = computed(() =>
|
||||
allVideoModels.value.map(m => ({
|
||||
label: m.label,
|
||||
key: m.key
|
||||
key: m.key,
|
||||
disabled: false
|
||||
}))
|
||||
)
|
||||
|
||||
@@ -399,6 +440,15 @@ export const useModelStore = defineStore('model', () => {
|
||||
.filter(item => item?.id && item.id !== 'auto')
|
||||
.map(normalizeRuntimeImageModel)
|
||||
.filter(Boolean)
|
||||
const videoOptions = data?.models?.video_options || []
|
||||
runtimeVideoModels.value = videoOptions
|
||||
.filter(item => {
|
||||
const id = String(item?.id || '').toLowerCase()
|
||||
const model = String(item?.model || '').toLowerCase()
|
||||
return id.includes('seedance') || model.includes('seedance')
|
||||
})
|
||||
.map(normalizeRuntimeVideoModel)
|
||||
.filter(Boolean)
|
||||
return true
|
||||
} catch (err) {
|
||||
console.warn('[model store] runtime model load failed', err)
|
||||
@@ -564,6 +614,7 @@ export const useModelStore = defineStore('model', () => {
|
||||
allImageModels,
|
||||
allVideoModels,
|
||||
runtimeImageModels,
|
||||
runtimeVideoModels,
|
||||
|
||||
// Available models filtered by provider
|
||||
availableChatModels,
|
||||
|
||||
Reference in New Issue
Block a user