auto-save 2026-05-27 17:29 (~3)

This commit is contained in:
2026-05-27 17:29:45 +08:00
parent fb939b8fcf
commit 6ac548a937
3 changed files with 29 additions and 9 deletions

View File

@@ -24,6 +24,7 @@ import {
DEFAULT_VIDEO_DURATION
} from '@/config/models'
import { useModelConfig } from '@/hooks/useModelConfig'
import { useModelStore } from './pinia'
// Loading state (always false for built-in models) | 加载状态
const loading = ref(false)
@@ -38,10 +39,23 @@ const getModelConfigHook = () => {
}
}
const getPiniaModelStore = () => {
try {
return useModelStore()
} catch {
return null
}
}
/**
* Initialize models (no-op for built-in) | 初始化模型
*/
export const loadAllModels = async () => {
const modelStore = getPiniaModelStore()
if (modelStore) {
await modelStore.loadRuntimeModels?.()
return [...modelStore.allImageModels, ...modelStore.allVideoModels, ...modelStore.allChatModels]
}
const modelConfig = getModelConfigHook()
if (modelConfig) {
return [...modelConfig.allImageModels.value, ...modelConfig.allVideoModels.value, ...modelConfig.allChatModels.value]
@@ -53,6 +67,12 @@ export const loadAllModels = async () => {
* Get model config by name | 根据名称获取模型配置
*/
export const getModelConfig = (modelKey) => {
const modelStore = getPiniaModelStore()
if (modelStore) {
return modelStore.getImageModel(modelKey) ||
modelStore.getVideoModel(modelKey) ||
modelStore.getChatModel(modelKey)
}
const modelConfig = getModelConfigHook()
if (modelConfig) {
return modelConfig.getImageModel(modelKey) ||
@@ -68,7 +88,7 @@ export const getModelConfig = (modelKey) => {
* Returns options based on model's sizes array and quality
*/
export const getModelSizeOptions = (modelKey, quality = 'standard') => {
const model = IMAGE_MODELS.find(m => m.key === modelKey)
const model = getModelConfig(modelKey) || IMAGE_MODELS.find(m => m.key === modelKey)
if (model?.sizeOptions) {
return model.sizeOptions
@@ -93,7 +113,7 @@ export const getModelSizeOptions = (modelKey, quality = 'standard') => {
* Get quality options for image model | 获取图片模型画质选项
*/
export const getModelQualityOptions = (modelKey) => {
const model = IMAGE_MODELS.find(m => m.key === modelKey)
const model = getModelConfig(modelKey) || IMAGE_MODELS.find(m => m.key === modelKey)
return model?.qualities || []
}

View File

@@ -319,7 +319,6 @@ const isApiConfigured = computed(() => !!modelStore.currentApiKey)
// Initialize models on page load | 页面加载时初始化模型
onMounted(() => {
loadAllModels()
modelStore.loadRuntimeModels()
})
// Chat templates | 问答模板