Skip to content

Commit 69940e2

Browse files
committed
【代码评审】AI:绘图 other 优化
1 parent 369860a commit 69940e2

File tree

3 files changed

+24
-77
lines changed

3 files changed

+24
-77
lines changed

src/views/ai/image/index/components/other/index.vue

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@
3636
<el-text tag="b">平台</el-text>
3737
</div>
3838
<el-space wrap class="group-item-body">
39-
<el-select v-model="otherPlatform" placeholder="Select" size="large" class="!w-350px" @change="handlerPlatformChange">
39+
<el-select
40+
v-model="otherPlatform"
41+
placeholder="Select"
42+
size="large"
43+
class="!w-350px"
44+
@change="handlerPlatformChange"
45+
>
4046
<el-option
4147
v-for="item in OtherPlatformEnum"
4248
:key="item.key"
@@ -52,16 +58,11 @@
5258
</div>
5359
<el-space wrap class="group-item-body">
5460
<el-select v-model="model" placeholder="Select" size="large" class="!w-350px">
55-
<el-option
56-
v-for="item in models"
57-
:key="item.key"
58-
:label="item.name"
59-
:value="item.key"
60-
/>
61+
<el-option v-for="item in models" :key="item.key" :label="item.name" :value="item.key" />
6162
</el-select>
6263
</el-space>
6364
</div>
64-
<div class="group-item" v-if="otherPlatform !== AiPlatformEnum.CHATGLM">
65+
<div class="group-item">
6566
<div>
6667
<el-text tag="b">图片尺寸</el-text>
6768
</div>
@@ -77,9 +78,10 @@
7778
</div>
7879
</template>
7980
<script setup lang="ts">
80-
import {ImageApi, ImageDrawReqVO, ImageVO} from '@/api/ai/image'
81+
import { ImageApi, ImageDrawReqVO, ImageVO } from '@/api/ai/image'
8182
import {
82-
AiPlatformEnum, ChatGlmModels,
83+
AiPlatformEnum,
84+
ChatGlmModels,
8385
ImageHotWords,
8486
ImageModelVO,
8587
OtherPlatformEnum,
@@ -100,7 +102,6 @@ const otherPlatform = ref<string>(AiPlatformEnum.TONG_YI) // 平台
100102
const models = ref<ImageModelVO[]>(TongYiWanXiangModels) // 模型 TongYiWanXiangModels、QianFanModels
101103
const model = ref<string>(models.value[0].key) // 模型
102104
103-
104105
const emits = defineEmits(['onDrawStart', 'onDrawComplete']) // 定义 emits
105106
106107
/** 选择热词 */
@@ -132,9 +133,8 @@ const handleGenerateImage = async () => {
132133
prompt: prompt.value, // 提示词
133134
width: width.value, // 图片宽度
134135
height: height.value, // 图片高度
135-
options: {
136-
}
137-
} as ImageDrawReqVO
136+
options: {}
137+
} as unknown as ImageDrawReqVO
138138
await ImageApi.drawImage(form)
139139
} finally {
140140
// 回调
@@ -149,28 +149,24 @@ const settingValues = async (detail: ImageVO) => {
149149
prompt.value = detail.prompt
150150
width.value = detail.width
151151
height.value = detail.height
152-
153152
}
154153
155154
/** 平台切换 */
156-
const handlerPlatformChange = async (platform) => {
155+
const handlerPlatformChange = async (platform: string) => {
157156
// 切换平台,切换模型、风格
158157
if (AiPlatformEnum.TONG_YI === platform) {
159158
models.value = TongYiWanXiangModels
160159
} else if (AiPlatformEnum.YI_YAN === platform) {
161160
models.value = QianFanModels
162-
} else if (AiPlatformEnum.CHATGLM === platform) {
161+
} else if (AiPlatformEnum.ZHI_PU === platform) {
163162
models.value = ChatGlmModels
164-
// ChatGlm 模型没有 width、height 随便默认一个值过后台必填检测
165-
height.value = 512
166-
width.value = 512
167163
} else {
168164
models.value = []
169165
}
170166
// 切换平台,默认选择一个风格
171167
if (models.value.length > 0) {
172168
model.value = models.value[0].key
173-
} else {
169+
} else {
174170
model.value = ''
175171
}
176172
}

src/views/ai/image/index/index.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const platformOptions = [
6262
value: AiPlatformEnum.STABLE_DIFFUSION
6363
},
6464
{
65-
label: '其他',
65+
label: '其它',
6666
value: 'other'
6767
}
6868
]
@@ -88,6 +88,7 @@ const handleRegeneration = async (image: ImageVO) => {
8888
} else if (image.platform === AiPlatformEnum.STABLE_DIFFUSION) {
8989
stableDiffusionRef.value.settingValues(image)
9090
}
91+
// TODO @fan:貌似 other 重新设置不行?
9192
}
9293
</script>
9394

src/views/ai/utils/constants.ts

Lines changed: 5 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ export const AiPlatformEnum = {
2020
Ollama: 'Ollama',
2121
STABLE_DIFFUSION: 'StableDiffusion', // Stability AI
2222
MIDJOURNEY: 'Midjourney', // Midjourney
23-
SUNO: 'Suno', // Suno AI
24-
CHATGLM: 'ChatGlm', // ChatGlm
23+
SUNO: 'Suno' // Suno AI
2524
}
2625

27-
export const OtherPlatformEnum:ImageModelVO [] = [
26+
export const OtherPlatformEnum: ImageModelVO[] = [
2827
{
2928
key: AiPlatformEnum.TONG_YI,
3029
name: '通义万相'
@@ -34,8 +33,8 @@ export const OtherPlatformEnum:ImageModelVO [] = [
3433
name: '百度千帆'
3534
},
3635
{
37-
key: AiPlatformEnum.CHATGLM,
38-
name: '智铺 ChatGlm'
36+
key: AiPlatformEnum.ZHI_PU,
37+
name: '智谱 AI'
3938
}
4039
]
4140

@@ -205,54 +204,6 @@ export const StableDiffusionStylePresets: ImageModelVO[] = [
205204
}
206205
]
207206

208-
// todo @芋艿 这些是通义的风格,看要不要删除
209-
export const TongYiWanXiangStylePresets: ImageModelVO[] = [
210-
{
211-
key: '-1',
212-
name: '上传图像风格'
213-
},
214-
{
215-
key: '0',
216-
name: '复古漫画'
217-
},
218-
{
219-
key: '1',
220-
name: '3D童话'
221-
},
222-
{
223-
key: '2',
224-
name: '二次元'
225-
},
226-
{
227-
key: '3',
228-
name: '小清新'
229-
},
230-
{
231-
key: '4',
232-
name: '未来科技'
233-
},
234-
{
235-
key: '5',
236-
name: '国画古风'
237-
},
238-
{
239-
key: '6',
240-
name: '将军百战'
241-
},
242-
{
243-
key: '7',
244-
name: '炫彩卡通'
245-
},
246-
{
247-
key: '8',
248-
name: '清雅国风'
249-
},
250-
{
251-
key: '9',
252-
name: '喜迎新年'
253-
}
254-
]
255-
256207
export const TongYiWanXiangModels: ImageModelVO[] = [
257208
{
258209
key: 'wanx-v1',
@@ -278,7 +229,6 @@ export const ChatGlmModels: ImageModelVO[] = [
278229
}
279230
]
280231

281-
282232
export const StableDiffusionClipGuidancePresets: ImageModelVO[] = [
283233
{
284234
key: 'NONE',
@@ -338,7 +288,7 @@ export const Dall3StyleList: ImageModelVO[] = [
338288

339289
export interface ImageSizeVO {
340290
key: string
341-
name: string
291+
name?: string
342292
style: string
343293
width: string
344294
height: string

0 commit comments

Comments
 (0)