【代码重构】AI:“聊天模型”重构为“模型”,支持 type 模型类型

This commit is contained in:
YunaiV
2025-03-03 21:26:24 +08:00
parent 0f4216f6f7
commit ae632ac23b
13 changed files with 276 additions and 184 deletions

View File

@@ -6,21 +6,28 @@
<el-segmented v-model="selectPlatform" :options="platformOptions" />
</div>
<div class="modal-switch-container">
<Common
v-if="selectPlatform === 'common'"
ref="commonRef"
:models="models"
@on-draw-complete="handleDrawComplete"
/>
<Dall3
v-if="selectPlatform === AiPlatformEnum.OPENAI"
ref="dall3Ref"
:models="models"
@on-draw-start="handleDrawStart"
@on-draw-complete="handleDrawComplete"
/>
<Midjourney v-if="selectPlatform === AiPlatformEnum.MIDJOURNEY" ref="midjourneyRef" />
<Midjourney
v-if="selectPlatform === AiPlatformEnum.MIDJOURNEY"
ref="midjourneyRef"
:models="models"
/>
<StableDiffusion
v-if="selectPlatform === AiPlatformEnum.STABLE_DIFFUSION"
ref="stableDiffusionRef"
@on-draw-complete="handleDrawComplete"
/>
<Other
v-if="selectPlatform === 'other'"
ref="otherRef"
:models="models"
@on-draw-complete="handleDrawComplete"
/>
</div>
@@ -38,17 +45,23 @@ import { ImageVO } from '@/api/ai/image'
import Dall3 from './components/dall3/index.vue'
import Midjourney from './components/midjourney/index.vue'
import StableDiffusion from './components/stableDiffusion/index.vue'
import Other from './components/other/index.vue'
import Common from './components/common/index.vue'
import { ModelApi, ModelVO } from '@/api/ai/model/model'
import { AiModelTypeEnum } from '@/views/ai/utils/constants'
const imageListRef = ref<any>() // image 列表 ref
const dall3Ref = ref<any>() // dall3(openai) ref
const midjourneyRef = ref<any>() // midjourney ref
const stableDiffusionRef = ref<any>() // stable diffusion ref
const otherRef = ref<any>() // stable diffusion ref
const commonRef = ref<any>() // stable diffusion ref
// 定义属性
const selectPlatform = ref(AiPlatformEnum.MIDJOURNEY)
const selectPlatform = ref('common') // 选中的平台
const platformOptions = [
{
label: '通用',
value: 'common'
},
{
label: 'DALL3 绘画',
value: AiPlatformEnum.OPENAI
@@ -58,15 +71,13 @@ const platformOptions = [
value: AiPlatformEnum.MIDJOURNEY
},
{
label: 'Stable Diffusion',
label: 'SD 绘图',
value: AiPlatformEnum.STABLE_DIFFUSION
},
{
label: '其它',
value: 'other'
}
]
const models = ref<ModelVO[]>([]) // 模型列表
/** 绘画 start */
const handleDrawStart = async (platform: string) => {}
@@ -75,7 +86,7 @@ const handleDrawComplete = async (platform: string) => {
await imageListRef.value.getImageList()
}
/** 重新生成:将画图详情填充到对应平台 */
/** 重新生成:将画图详情填充到对应平台 */
const handleRegeneration = async (image: ImageVO) => {
// 切换平台
selectPlatform.value = image.platform
@@ -90,6 +101,12 @@ const handleRegeneration = async (image: ImageVO) => {
}
// TODO @fan貌似 other 重新设置不行?
}
/** 组件挂载的时候 */
onMounted(async () => {
// 获取模型列表
models.value = await ModelApi.getModelSimpleList(AiModelTypeEnum.IMAGE)
})
</script>
<style scoped lang="scss">
@@ -109,10 +126,7 @@ const handleRegeneration = async (image: ImageVO) => {
display: flex;
flex-direction: column;
padding: 20px;
width: 350px;
.segmented {
}
width: 390px;
.segmented .el-segmented {
--el-border-radius-base: 16px;