Skip to content

Commit 8f2c6ab

Browse files
committed
【增加】增加 midjourney 请求
1 parent b82391d commit 8f2c6ab

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/api/ai/image/index.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,27 @@ export interface ImagePageReqVO {
2323
pageSize: number // 分页大小
2424
}
2525

26+
export interface ImageDallReqVO {
27+
prompt: string // 提示词
28+
model: string // 模型
29+
style: string // 图像生成的风格
30+
width: string // 图片宽度
31+
height: string // 图片高度
32+
}
33+
2634
export interface ImageDallReqVO {
2735
prompt: string // 提示词
2836
model: string // 模型
2937
style: string // 图像生成的风格
3038
size: string // size不能为空
3139
}
3240

41+
export interface ImageMidjourneyImagineReqVO {
42+
prompt: string // 提示词
43+
base64Array: string[] // size不能为空
44+
}
45+
46+
3347
// AI API 密钥 API
3448
export const ImageApi = {
3549
// 获取 image 列表
@@ -44,8 +58,12 @@ export const ImageApi = {
4458
dall: async (data: ImageDallReqVO)=> {
4559
return await request.post({ url: `/ai/image/dall`, data })
4660
},
61+
// midjourney - imagine
62+
midjourneyImagine: async (data: ImageMidjourneyImagineReqVO)=> {
63+
return await request.post({ url: `/ai/image/midjourney/imagine`, data })
64+
},
4765
// 删除
4866
deleteImage: async (id: number)=> {
49-
return await request.delete({ url: `/ai/image/delete-my?id=${id}`})
67+
return await request.delete({ url: `/ai/image/delete-id-my?id=${id}`})
5068
},
5169
}

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@
7474
<script setup lang="ts">
7575
7676
// image 模型
77+
import {ImageApi, ImageMidjourneyImagineReqVO} from "@/api/ai/image";
78+
79+
// 定义 emits
80+
const emits = defineEmits(['onDrawStart', 'onDrawComplete'])
81+
7782
interface ImageModelVO {
7883
key: string
7984
name: string
@@ -172,6 +177,19 @@ const handlerSizeClick = async (imageSize: ImageSizeVO) => {
172177
*/
173178
const handlerGenerateImage = async () => {
174179
// todo @范 图片生产逻辑
180+
try {
181+
// 回调
182+
// emits('onDrawStart', selectModel.value.key)
183+
// 发送请求
184+
const req = {
185+
prompt: prompt.value,
186+
base64Array: [],
187+
} as ImageMidjourneyImagineReqVO
188+
await ImageApi.midjourneyImagine(req)
189+
} finally {
190+
// 回调
191+
// emits('onDrawComplete', selectModel.value.key)
192+
}
175193
}
176194
</script>
177195
<style scoped lang="scss">

0 commit comments

Comments
 (0)