Skip to content

Commit c87713f

Browse files
committed
【增加】Dall 生成中 按钮控制
1 parent 91fc466 commit c87713f

File tree

1 file changed

+27
-15
lines changed

1 file changed

+27
-15
lines changed

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

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,13 @@
8787
</el-space>
8888
</div>
8989
<div class="btns">
90-
<!-- <el-button size="large" round>重置内容</el-button>-->
91-
<el-button type="primary" size="large" round @click="handlerGenerateImage">生成内容</el-button>
90+
<el-button type="primary"
91+
size="large"
92+
round
93+
:loading="drawIn"
94+
@click="handlerGenerateImage">
95+
{{drawIn ? '生成中' : '生成内容'}}
96+
</el-button>
9297
</div>
9398
</template>
9499
<script setup lang="ts">
@@ -109,6 +114,7 @@ interface ImageSizeVO {
109114
110115
// 定义属性
111116
const prompt = ref<string>('') // 提示词
117+
const drawIn = ref<boolean>(false) // 生成中
112118
const selectHotWord = ref<string>('') // 选中的热词
113119
const hotWords = ref<string[]>(['中国旗袍', '古装美女', '卡通头像', '机甲战士', '童话小屋', '中国长城']) // 热词
114120
const selectModel = ref<any>({}) // 模型
@@ -216,19 +222,25 @@ const handlerSizeClick = async (imageSize: ImageSizeVO) => {
216222
* 图片生产
217223
*/
218224
const handlerGenerateImage = async () => {
219-
// todo @范 图片生产逻辑
220-
console.log('prompt.value', prompt)
221-
console.log('prompt.value', prompt.value)
222-
const form = {
223-
prompt: prompt.value, // 提示词
224-
model: selectModel.value.key, // 模型
225-
style: selectImageStyle.value.key, // 图像生成的风格
226-
size: selectImageSize.value.key, // size不能为空
227-
} as ImageDallReqVO
228-
// 发送请求
229-
await ImageApi.dall(form)
230-
// 回调
231-
emits('onDrawComplete', selectModel.value.key)
225+
try {
226+
// 加载中
227+
drawIn.value = true
228+
// 回调
229+
emits('onDrawStart', selectModel.value.key)
230+
const form = {
231+
prompt: prompt.value, // 提示词
232+
model: selectModel.value.key, // 模型
233+
style: selectImageStyle.value.key, // 图像生成的风格
234+
size: selectImageSize.value.key, // size不能为空
235+
} as ImageDallReqVO
236+
// 发送请求
237+
await ImageApi.dall(form)
238+
} finally {
239+
// 回调
240+
emits('onDrawComplete', selectModel.value.key)
241+
// 加载结束
242+
drawIn.value = false
243+
}
232244
}
233245
234246
</script>

0 commit comments

Comments
 (0)