From cc9e11859dd64bbf2da8e666d21f5e14c1891c1b Mon Sep 17 00:00:00 2001 From: cherishsince Date: Fri, 31 May 2024 14:02:35 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=A2=9E=E5=8A=A0=E3=80=91midjourney?= =?UTF-8?q?=20=E5=A2=9E=E5=8A=A0=20width=20=E5=92=8C=20height?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/ai/image/index.ts | 2 + src/views/ai/image/midjourney/index.vue | 66 +++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/src/api/ai/image/index.ts b/src/api/ai/image/index.ts index 8e52d427..a5b88399 100644 --- a/src/api/ai/image/index.ts +++ b/src/api/ai/image/index.ts @@ -42,6 +42,8 @@ export interface ImageMidjourneyImagineReqVO { prompt: string // 提示词 model: string // 模型 mj nijj base64Array: string[] // size不能为空 + width: string // 图片宽度 + height: string // 图片高度 } diff --git a/src/views/ai/image/midjourney/index.vue b/src/views/ai/image/midjourney/index.vue index 8d423124..ef1d7822 100644 --- a/src/views/ai/image/midjourney/index.vue +++ b/src/views/ai/image/midjourney/index.vue @@ -30,6 +30,22 @@ +
+
+ 尺寸 +
+ +
+
+
+
+
{{ imageSize.key }}
+
+
+
模型 @@ -73,6 +89,8 @@ interface ImageModelVO { interface ImageSizeVO { key: string style: string, + width: string, + height: string, } // 定义属性 @@ -94,6 +112,41 @@ const models = ref([ ]) // 模型 selectModel.value = models.value[0] // 默认选中 +const selectImageSize = ref({} as ImageSizeVO) // 选中 size +const imageSizeList = ref([ + { + key: '1:1', + width: "1", + height: "1", + style: 'width: 30px; height: 30px;background-color: #dcdcdc;', + }, + { + key: '3:4', + width: "3", + height: "4", + style: 'width: 30px; height: 40px;background-color: #dcdcdc;', + }, + { + key: '4:3', + width: "4", + height: "3", + style: 'width: 40px; height: 30px;background-color: #dcdcdc;', + }, + { + key: '9:16', + width: "9", + height: "16", + style: 'width: 30px; height: 50px;background-color: #dcdcdc;', + }, + { + key: '16:9', + width: "16", + height: "9", + style: 'width: 50px; height: 30px;background-color: #dcdcdc;', + }, +]) // size +selectImageSize.value = imageSizeList.value[0] + // 定义 Props const props = defineProps({}) @@ -112,6 +165,17 @@ const handlerHotWordClick = async (hotWord: string) => { prompt.value = hotWord } +/** + * size - click + */ +const handlerSizeClick = async (imageSize: ImageSizeVO) => { + if (selectImageSize.value === imageSize) { + selectImageSize.value = {} as ImageSizeVO + return + } + selectImageSize.value = imageSize +} + /** * 模型 - click */ @@ -131,6 +195,8 @@ const handlerGenerateImage = async () => { const req = { prompt: prompt.value, model: selectModel.value.key, + width: selectImageSize.value.width, + height: selectImageSize.value.height, base64Array: [], } as ImageMidjourneyImagineReqVO await ImageApi.midjourneyImagine(req)