页面加载时预请求平台模型接口,避免首次点击"发送"时才触发请求
This commit is contained in:
parent
5da5496492
commit
2b1e7385e0
@ -87,7 +87,7 @@ import { useDisplayStore } from '@/stores'
|
||||
import { generate } from '@/utils/websocket'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { fetchModelConfig } from '@/utils/modelConfig'
|
||||
import { getModelId } from '@/utils/modelApi'
|
||||
import { getModelId, fetchPlatformModels, getPlatformCode } from '@/utils/modelApi'
|
||||
|
||||
const props = defineProps({
|
||||
isGenerate: {
|
||||
@ -292,14 +292,25 @@ watch([() => model.value, () => modelType.value], async ([newModel, newModelType
|
||||
}
|
||||
})
|
||||
|
||||
// 预加载平台模型列表,避免首次点击"发送"时才请求接口
|
||||
const prefetchModels = () => {
|
||||
const code = getPlatformCode(props.type)
|
||||
fetchPlatformModels(code)
|
||||
}
|
||||
|
||||
watch(() => props.type, (newType) => {
|
||||
if (newType === 'Video') {
|
||||
model.value = 'LTX2.0'
|
||||
} else {
|
||||
model.value = 'flux'
|
||||
}
|
||||
prefetchModels()
|
||||
}, { immediate: true })
|
||||
|
||||
onMounted(() => {
|
||||
prefetchModels()
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user