【代码评审】AI:绘图 other 优化

pull/482/head
YunaiV 2024-07-13 00:06:27 +08:00
parent 369860a055
commit 69940e2780
3 changed files with 24 additions and 77 deletions

View File

@ -36,7 +36,13 @@
<el-text tag="b">平台</el-text>
</div>
<el-space wrap class="group-item-body">
<el-select v-model="otherPlatform" placeholder="Select" size="large" class="!w-350px" @change="handlerPlatformChange">
<el-select
v-model="otherPlatform"
placeholder="Select"
size="large"
class="!w-350px"
@change="handlerPlatformChange"
>
<el-option
v-for="item in OtherPlatformEnum"
:key="item.key"
@ -52,16 +58,11 @@
</div>
<el-space wrap class="group-item-body">
<el-select v-model="model" placeholder="Select" size="large" class="!w-350px">
<el-option
v-for="item in models"
:key="item.key"
:label="item.name"
:value="item.key"
/>
<el-option v-for="item in models" :key="item.key" :label="item.name" :value="item.key" />
</el-select>
</el-space>
</div>
<div class="group-item" v-if="otherPlatform !== AiPlatformEnum.CHATGLM">
<div class="group-item">
<div>
<el-text tag="b">图片尺寸</el-text>
</div>
@ -77,9 +78,10 @@
</div>
</template>
<script setup lang="ts">
import {ImageApi, ImageDrawReqVO, ImageVO} from '@/api/ai/image'
import { ImageApi, ImageDrawReqVO, ImageVO } from '@/api/ai/image'
import {
AiPlatformEnum, ChatGlmModels,
AiPlatformEnum,
ChatGlmModels,
ImageHotWords,
ImageModelVO,
OtherPlatformEnum,
@ -100,7 +102,6 @@ const otherPlatform = ref<string>(AiPlatformEnum.TONG_YI) // 平台
const models = ref<ImageModelVO[]>(TongYiWanXiangModels) // TongYiWanXiangModelsQianFanModels
const model = ref<string>(models.value[0].key) //
const emits = defineEmits(['onDrawStart', 'onDrawComplete']) // emits
/** 选择热词 */
@ -132,9 +133,8 @@ const handleGenerateImage = async () => {
prompt: prompt.value, //
width: width.value, //
height: height.value, //
options: {
}
} as ImageDrawReqVO
options: {}
} as unknown as ImageDrawReqVO
await ImageApi.drawImage(form)
} finally {
//
@ -149,28 +149,24 @@ const settingValues = async (detail: ImageVO) => {
prompt.value = detail.prompt
width.value = detail.width
height.value = detail.height
}
/** 平台切换 */
const handlerPlatformChange = async (platform) => {
const handlerPlatformChange = async (platform: string) => {
//
if (AiPlatformEnum.TONG_YI === platform) {
models.value = TongYiWanXiangModels
} else if (AiPlatformEnum.YI_YAN === platform) {
models.value = QianFanModels
} else if (AiPlatformEnum.CHATGLM === platform) {
} else if (AiPlatformEnum.ZHI_PU === platform) {
models.value = ChatGlmModels
// ChatGlm widthheight 便
height.value = 512
width.value = 512
} else {
models.value = []
}
//
if (models.value.length > 0) {
model.value = models.value[0].key
} else {
} else {
model.value = ''
}
}

View File

@ -62,7 +62,7 @@ const platformOptions = [
value: AiPlatformEnum.STABLE_DIFFUSION
},
{
label: '其',
label: '其',
value: 'other'
}
]
@ -88,6 +88,7 @@ const handleRegeneration = async (image: ImageVO) => {
} else if (image.platform === AiPlatformEnum.STABLE_DIFFUSION) {
stableDiffusionRef.value.settingValues(image)
}
// TODO @fan other
}
</script>

View File

@ -20,11 +20,10 @@ export const AiPlatformEnum = {
Ollama: 'Ollama',
STABLE_DIFFUSION: 'StableDiffusion', // Stability AI
MIDJOURNEY: 'Midjourney', // Midjourney
SUNO: 'Suno', // Suno AI
CHATGLM: 'ChatGlm', // ChatGlm
SUNO: 'Suno' // Suno AI
}
export const OtherPlatformEnum:ImageModelVO [] = [
export const OtherPlatformEnum: ImageModelVO[] = [
{
key: AiPlatformEnum.TONG_YI,
name: '通义万相'
@ -34,8 +33,8 @@ export const OtherPlatformEnum:ImageModelVO [] = [
name: '百度千帆'
},
{
key: AiPlatformEnum.CHATGLM,
name: '智铺 ChatGlm'
key: AiPlatformEnum.ZHI_PU,
name: '智谱 AI'
}
]
@ -205,54 +204,6 @@ export const StableDiffusionStylePresets: ImageModelVO[] = [
}
]
// todo @芋艿 这些是通义的风格,看要不要删除
export const TongYiWanXiangStylePresets: ImageModelVO[] = [
{
key: '-1',
name: '上传图像风格'
},
{
key: '0',
name: '复古漫画'
},
{
key: '1',
name: '3D童话'
},
{
key: '2',
name: '二次元'
},
{
key: '3',
name: '小清新'
},
{
key: '4',
name: '未来科技'
},
{
key: '5',
name: '国画古风'
},
{
key: '6',
name: '将军百战'
},
{
key: '7',
name: '炫彩卡通'
},
{
key: '8',
name: '清雅国风'
},
{
key: '9',
name: '喜迎新年'
}
]
export const TongYiWanXiangModels: ImageModelVO[] = [
{
key: 'wanx-v1',
@ -278,7 +229,6 @@ export const ChatGlmModels: ImageModelVO[] = [
}
]
export const StableDiffusionClipGuidancePresets: ImageModelVO[] = [
{
key: 'NONE',
@ -338,7 +288,7 @@ export const Dall3StyleList: ImageModelVO[] = [
export interface ImageSizeVO {
key: string
name: string
name?: string
style: string
width: string
height: string