From 2ef484e7006f25cc937da41d9799b5322520eb2e Mon Sep 17 00:00:00 2001 From: YunaiV Date: Mon, 3 Mar 2025 21:47:59 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BB=A3=E7=A0=81=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E3=80=91AI=EF=BC=9A=E2=80=9C=E8=81=8A=E5=A4=A9=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E2=80=9D=E9=87=8D=E6=9E=84=E4=B8=BA=E2=80=9C=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E2=80=9D=EF=BC=8C=E6=94=AF=E6=8C=81=20type=20?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../index/components/midjourney/index.vue | 30 +++++++++++++-- .../components/stableDiffusion/index.vue | 38 +++++++++++++++---- 2 files changed, 58 insertions(+), 10 deletions(-) diff --git a/src/views/ai/image/index/components/midjourney/index.vue b/src/views/ai/image/index/components/midjourney/index.vue index 1d7fda18..1200a5ee 100644 --- a/src/views/ai/image/index/components/midjourney/index.vue +++ b/src/views/ai/image/index/components/midjourney/index.vue @@ -95,7 +95,13 @@
- + {{ drawIn ? '生成中' : '生成内容' }}
@@ -112,9 +118,19 @@ import { MidjourneyVersions, NijiVersionList } from '@/views/ai/utils/constants' +import { ModelVO } from '@/api/ai/model/model' const message = useMessage() // 消息弹窗 +// 接收父组件传入的模型列表 +const props = defineProps({ + models: { + type: Array, + default: () => [] as ModelVO[] + } +}) +const emits = defineEmits(['onDrawStart', 'onDrawComplete']) // 定义 emits + // 定义属性 const drawIn = ref(false) // 生成中 const selectHotWord = ref('') // 选中的热词 @@ -125,7 +141,6 @@ const selectModel = ref('midjourney') // 选中的模型 const selectSize = ref('1:1') // 选中 size const selectVersion = ref('6.0') // 选中的 version const versionList = ref(MidjourneyVersions) // version 列表 -const emits = defineEmits(['onDrawStart', 'onDrawComplete']) // 定义 emits /** 选择热词 */ const handleHotWordClick = async (hotWord: string) => { @@ -158,6 +173,15 @@ const handleModelClick = async (model: ImageModelVO) => { /** 图片生成 */ const handleGenerateImage = async () => { + // 从 models 中查找匹配的模型 + const matchedModel = props.models.find( + (item) => item.model === selectModel.value && item.platform === AiPlatformEnum.MIDJOURNEY + ) + if (!matchedModel) { + message.error('该模型不可用,请选择其它模型') + return + } + // 二次确认 await message.confirm(`确认生成内容?`) try { @@ -171,7 +195,7 @@ const handleGenerateImage = async () => { ) as ImageSizeVO const req = { prompt: prompt.value, - model: selectModel.value, + modelId: matchedModel.id, width: imageSize.width, height: imageSize.height, version: selectVersion.value, diff --git a/src/views/ai/image/index/components/stableDiffusion/index.vue b/src/views/ai/image/index/components/stableDiffusion/index.vue index 169938f4..cf5e5bdf 100644 --- a/src/views/ai/image/index/components/stableDiffusion/index.vue +++ b/src/views/ai/image/index/components/stableDiffusion/index.vue @@ -2,11 +2,11 @@