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 @@
画面描述
- 建议使用“形容词+动词+风格”的格式,使用“,”隔开
+ 建议使用“形容词 + 动词 + 风格”的格式,使用“,”隔开
-
+
{{ drawIn ? '生成中' : '生成内容' }}
@@ -143,9 +150,19 @@ import {
StableDiffusionSamplers,
StableDiffusionStylePresets
} 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('') // 选中的热词
@@ -160,8 +177,6 @@ const scale = ref(7.5) // 引导系数
const clipGuidancePreset = ref('NONE') // 文本提示相匹配的图像(clip_guidance_preset) 简称 CLIP
const stylePreset = ref('3d-model') // 风格
-const emits = defineEmits(['onDrawStart', 'onDrawComplete']) // 定义 emits
-
/** 选择热词 */
const handleHotWordClick = async (hotWord: string) => {
// 情况一:取消选中
@@ -177,6 +192,16 @@ const handleHotWordClick = async (hotWord: string) => {
/** 图片生成 */
const handleGenerateImage = async () => {
+ // 从 models 中查找匹配的模型
+ const selectModel = 'stable-diffusion-v1-6'
+ const matchedModel = props.models.find(
+ (item) => item.model === selectModel && item.platform === AiPlatformEnum.STABLE_DIFFUSION
+ )
+ if (!matchedModel) {
+ message.error('该模型不可用,请选择其它模型')
+ return
+ }
+
// 二次确认
if (hasChinese(prompt.value)) {
message.alert('暂不支持中文!')
@@ -191,8 +216,7 @@ const handleGenerateImage = async () => {
emits('onDrawStart', AiPlatformEnum.STABLE_DIFFUSION)
// 发送请求
const form = {
- platform: AiPlatformEnum.STABLE_DIFFUSION,
- model: 'stable-diffusion-v1-6',
+ modelId: matchedModel.id,
prompt: prompt.value, // 提示词
width: width.value, // 图片宽度
height: height.value, // 图片高度