【代码优化】AI:增加枚举类

This commit is contained in:
YunaiV
2024-07-03 13:52:00 +08:00
parent 8da1c04b55
commit 33cf98e306
6 changed files with 97 additions and 29 deletions

View File

@ -3,15 +3,19 @@
<div class="ai-image">
<div class="left">
<div class="segmented">
<el-segmented v-model="selectModel" :options="modelOptions" />
<el-segmented v-model="selectPlatform" :options="platformOptions" />
</div>
<div class="modal-switch-container">
<!-- TODO @fan1建议 Dall3 改成 OpenAI 绘图因为 dall3 其实本质是模型2涉及到中英文的地方中文和英文之间有个空格哈 -->
<Dall3 v-if="selectModel === 'DALL3绘画'"
@on-draw-start="handlerDrawStart"
@on-draw-complete="handlerDrawComplete" />
<Midjourney v-if="selectModel === 'MJ绘画'" />
<StableDiffusion v-if="selectModel === 'Stable Diffusion'" @on-draw-complete="handlerDrawComplete" />
<Dall3
v-if="selectPlatform === AiPlatformEnum.OPENAI"
@on-draw-start="handlerDrawStart"
@on-draw-complete="handlerDrawComplete"
/>
<Midjourney v-if="selectPlatform === AiPlatformEnum.MIDJOURNEY" />
<StableDiffusion
v-if="selectPlatform === AiPlatformEnum.STABLE_DIFFUSION"
@on-draw-complete="handlerDrawComplete"
/>
</div>
</div>
<div class="main">
@ -26,18 +30,31 @@ import Dall3 from './dall3/index.vue'
import Midjourney from './midjourney/index.vue'
import StableDiffusion from './stable-diffusion/index.vue'
import ImageTask from './ImageTask.vue'
import { AiPlatformEnum } from '@/views/ai/utils/constants'
// ref
const imageTaskRef = ref<any>() // image task ref
// 定义属性
const selectModel = ref('Stable Diffusion')
const modelOptions = ['DALL3绘画', 'MJ绘画', 'Stable Diffusion']
const drawIn = ref<boolean>(false) // 生成中
const selectPlatform = ref('StableDiffusion')
const platformOptions = [
{
label: 'DALL3 绘画',
value: AiPlatformEnum.OPENAI
},
{
label: 'MJ 绘画',
value: AiPlatformEnum.MIDJOURNEY
},
{
label: 'Stable Diffusion',
value: AiPlatformEnum.STABLE_DIFFUSION
}
]
const drawIn = ref<boolean>(false) // 生成中
/** 绘画 - start */
const handlerDrawStart = async (type) => {
// todo
// todo @fan这个是不是没用啦
drawIn.value = true
}
@ -47,15 +64,9 @@ const handlerDrawComplete = async (type) => {
// todo
await imageTaskRef.value.getImageList()
}
//
onMounted( async () => {
})
</script>
<style scoped lang="scss">
.ai-image {
position: absolute;
left: 0;
@ -101,5 +112,4 @@ onMounted( async () => {
background-color: #f7f8fa;
}
}
</style>