2024-05-25 15:36:21 +08:00
|
|
|
|
<!-- image -->
|
|
|
|
|
<template>
|
|
|
|
|
<div class="ai-image">
|
|
|
|
|
<div class="left">
|
|
|
|
|
<div class="segmented">
|
2024-07-03 13:52:00 +08:00
|
|
|
|
<el-segmented v-model="selectPlatform" :options="platformOptions" />
|
2024-05-25 15:36:21 +08:00
|
|
|
|
</div>
|
|
|
|
|
<div class="modal-switch-container">
|
2024-07-03 13:52:00 +08:00
|
|
|
|
<Dall3
|
|
|
|
|
v-if="selectPlatform === AiPlatformEnum.OPENAI"
|
2024-07-03 22:04:59 +08:00
|
|
|
|
ref="dall3Ref"
|
2024-07-03 13:52:00 +08:00
|
|
|
|
@on-draw-start="handlerDrawStart"
|
|
|
|
|
@on-draw-complete="handlerDrawComplete"
|
|
|
|
|
/>
|
2024-07-03 22:04:59 +08:00
|
|
|
|
<Midjourney
|
|
|
|
|
v-if="selectPlatform === AiPlatformEnum.MIDJOURNEY"
|
|
|
|
|
ref="midjourneyRef"
|
|
|
|
|
/>
|
2024-07-03 13:52:00 +08:00
|
|
|
|
<StableDiffusion
|
|
|
|
|
v-if="selectPlatform === AiPlatformEnum.STABLE_DIFFUSION"
|
2024-07-03 22:04:59 +08:00
|
|
|
|
ref="stableDiffusionRef"
|
2024-07-03 13:52:00 +08:00
|
|
|
|
@on-draw-complete="handlerDrawComplete"
|
|
|
|
|
/>
|
2024-05-25 15:36:21 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="main">
|
2024-07-03 22:04:59 +08:00
|
|
|
|
<ImageTask ref="imageTaskRef" @on-regeneration="handlerRegeneration" />
|
2024-05-25 15:36:21 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
2024-05-25 16:21:00 +08:00
|
|
|
|
|
2024-05-25 15:36:21 +08:00
|
|
|
|
<script setup lang="ts">
|
2024-06-01 16:49:42 +08:00
|
|
|
|
// TODO @fan:在整个挪到 /views/ai/image/index 目录。因为我想在 /views/ai/image/manager 做管理的功能,进行下区分!
|
2024-05-25 15:36:21 +08:00
|
|
|
|
import Dall3 from './dall3/index.vue'
|
2024-05-25 21:12:36 +08:00
|
|
|
|
import Midjourney from './midjourney/index.vue'
|
2024-06-21 15:26:08 +08:00
|
|
|
|
import StableDiffusion from './stable-diffusion/index.vue'
|
2024-05-26 21:00:00 +08:00
|
|
|
|
import ImageTask from './ImageTask.vue'
|
2024-07-03 13:52:00 +08:00
|
|
|
|
import { AiPlatformEnum } from '@/views/ai/utils/constants'
|
2024-07-03 22:04:59 +08:00
|
|
|
|
import {ImageVO} from "@/api/ai/image";
|
|
|
|
|
|
2024-05-25 15:36:21 +08:00
|
|
|
|
|
2024-05-27 17:35:50 +08:00
|
|
|
|
const imageTaskRef = ref<any>() // image task ref
|
2024-07-03 22:04:59 +08:00
|
|
|
|
const dall3Ref = ref<any>() // image task ref
|
|
|
|
|
const midjourneyRef = ref<any>() // image task ref
|
|
|
|
|
const stableDiffusionRef = ref<any>() // image task ref
|
2024-05-27 17:35:50 +08:00
|
|
|
|
|
2024-05-25 16:21:00 +08:00
|
|
|
|
// 定义属性
|
2024-07-03 13:52:00 +08:00
|
|
|
|
const selectPlatform = ref('StableDiffusion')
|
|
|
|
|
const platformOptions = [
|
|
|
|
|
{
|
|
|
|
|
label: 'DALL3 绘画',
|
|
|
|
|
value: AiPlatformEnum.OPENAI
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'MJ 绘画',
|
|
|
|
|
value: AiPlatformEnum.MIDJOURNEY
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'Stable Diffusion',
|
|
|
|
|
value: AiPlatformEnum.STABLE_DIFFUSION
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
const drawIn = ref<boolean>(false) // 生成中
|
2024-05-25 15:36:21 +08:00
|
|
|
|
|
2024-06-03 10:16:56 +08:00
|
|
|
|
/** 绘画 - start */
|
2024-05-27 17:35:50 +08:00
|
|
|
|
const handlerDrawStart = async (type) => {
|
2024-07-03 13:52:00 +08:00
|
|
|
|
// todo @fan:这个是不是没用啦?
|
2024-05-27 18:17:37 +08:00
|
|
|
|
drawIn.value = true
|
2024-05-27 17:35:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-03 10:16:56 +08:00
|
|
|
|
/** 绘画 - complete */
|
2024-05-27 17:35:50 +08:00
|
|
|
|
const handlerDrawComplete = async (type) => {
|
2024-05-27 18:17:37 +08:00
|
|
|
|
drawIn.value = false
|
2024-05-27 17:35:50 +08:00
|
|
|
|
// todo
|
|
|
|
|
await imageTaskRef.value.getImageList()
|
|
|
|
|
}
|
2024-07-03 22:04:59 +08:00
|
|
|
|
|
|
|
|
|
/** 绘画 - 重新生成 */
|
|
|
|
|
const handlerRegeneration = async (imageDetail: ImageVO) => {
|
|
|
|
|
// 切换平台
|
|
|
|
|
selectPlatform.value = imageDetail.platform
|
|
|
|
|
|
|
|
|
|
// 根据不同平台填充 imageDetail
|
|
|
|
|
if (imageDetail.platform === AiPlatformEnum.MIDJOURNEY) {
|
|
|
|
|
await nextTick(async () => {
|
|
|
|
|
midjourneyRef.value.settingValues(imageDetail)
|
|
|
|
|
})
|
|
|
|
|
} else if (imageDetail.platform === AiPlatformEnum.OPENAI) {
|
|
|
|
|
await nextTick(async () => {
|
|
|
|
|
dall3Ref.value.settingValues(imageDetail)
|
|
|
|
|
})
|
|
|
|
|
} else if (imageDetail.platform === AiPlatformEnum.STABLE_DIFFUSION) {
|
|
|
|
|
await nextTick(async () => {
|
|
|
|
|
stableDiffusionRef.value.settingValues(imageDetail)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2024-05-25 15:36:21 +08:00
|
|
|
|
</script>
|
2024-05-25 16:21:00 +08:00
|
|
|
|
|
2024-05-25 15:36:21 +08:00
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
.ai-image {
|
|
|
|
|
position: absolute;
|
|
|
|
|
left: 0;
|
|
|
|
|
right: 0;
|
|
|
|
|
bottom: 0;
|
|
|
|
|
top: 0;
|
|
|
|
|
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
height: 100%;
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
|
|
|
|
.left {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
padding: 20px;
|
2024-05-25 16:21:00 +08:00
|
|
|
|
width: 350px;
|
|
|
|
|
|
|
|
|
|
.segmented {
|
|
|
|
|
}
|
2024-05-25 15:36:21 +08:00
|
|
|
|
|
|
|
|
|
.segmented .el-segmented {
|
|
|
|
|
--el-border-radius-base: 16px;
|
|
|
|
|
--el-segmented-item-selected-color: #fff;
|
|
|
|
|
background-color: #ececec;
|
|
|
|
|
width: 350px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.modal-switch-container {
|
|
|
|
|
height: 100%;
|
|
|
|
|
overflow-y: auto;
|
2024-05-25 16:21:00 +08:00
|
|
|
|
margin-top: 30px;
|
2024-05-25 15:36:21 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.main {
|
|
|
|
|
flex: 1;
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.right {
|
|
|
|
|
width: 350px;
|
|
|
|
|
background-color: #f7f8fa;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|