Commit 61bf6fb8 by YunaiV

【代码优化】AI:绘图 index.vue 代码梳理 60%(StableDiffusion.vue)

parent ac46a376
...@@ -12,11 +12,11 @@ export interface ImageVO { ...@@ -12,11 +12,11 @@ export interface ImageVO {
publicStatus: boolean // 公开状态 publicStatus: boolean // 公开状态
picUrl: string // 任务地址 picUrl: string // 任务地址
errorMessage: string // 错误信息 errorMessage: string // 错误信息
options: object // 配置 Map<string, string> options: any // 配置 Map<string, string>
taskId: number // 任务编号 taskId: number // 任务编号
buttons: ImageMidjourneyButtonsVO[] // mj 操作按钮 buttons: ImageMidjourneyButtonsVO[] // mj 操作按钮
createTime: string // 创建时间 createTime: Date // 创建时间
finishTime: string // 完成时间 finishTime: Date // 完成时间
} }
export interface ImageDrawReqVO { export interface ImageDrawReqVO {
......
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
<div class="item"> <div class="item">
<div class="tip">时间</div> <div class="tip">时间</div>
<div class="body"> <div class="body">
<div>提交时间:{{ detail.createTime }}</div> <div>提交时间:{{ formatTime(detail.createTime, 'yyyy-MM-dd HH:mm:ss') }}</div>
<div>生成时间:{{ detail.finishTime }}</div> <div>生成时间:{{ formatTime(detail.finishTime, 'yyyy-MM-dd HH:mm:ss') }}</div>
</div> </div>
</div> </div>
<!-- 模型 --> <!-- 模型 -->
...@@ -43,13 +43,73 @@ ...@@ -43,13 +43,73 @@
{{ detail.picUrl }} {{ detail.picUrl }}
</div> </div>
</div> </div>
<!-- 风格 --> <!-- StableDiffusion 专属区域 -->
<div class="item" v-if="detail?.options?.style"> <div
class="item"
v-if="detail.platform === AiPlatformEnum.STABLE_DIFFUSION && detail?.options?.sampler"
>
<div class="tip">采样方法</div>
<div class="body">
{{
StableDiffusionSamplers.find(
(item: ImageModelVO) => item.key === detail?.options?.sampler
)?.name
}}
</div>
</div>
<div
class="item"
v-if="
detail.platform === AiPlatformEnum.STABLE_DIFFUSION && detail?.options?.clipGuidancePreset
"
>
<div class="tip">CLIP</div>
<div class="body">
{{
StableDiffusionClipGuidancePresets.find(
(item: ImageModelVO) => item.key === detail?.options?.clipGuidancePreset
)?.name
}}
</div>
</div>
<div
class="item"
v-if="detail.platform === AiPlatformEnum.STABLE_DIFFUSION && detail?.options?.stylePreset"
>
<div class="tip">风格</div> <div class="tip">风格</div>
<div class="body"> <div class="body">
<!-- TODO @fan:貌似需要把 imageStyleList 搞到 api/image/index.ts 枚举起来? --> {{
<!-- TODO @fan:这里的展示,可能需要按照平台做区分 --> StableDiffusionStylePresets.find(
{{ detail?.options?.style }} (item: ImageModelVO) => item.key === detail?.options?.stylePreset
)?.name
}}
</div>
</div>
<div
class="item"
v-if="detail.platform === AiPlatformEnum.STABLE_DIFFUSION && detail?.options?.steps"
>
<div class="tip">迭代步数</div>
<div class="body">
{{ detail?.options?.steps }}
</div>
</div>
<div
class="item"
v-if="detail.platform === AiPlatformEnum.STABLE_DIFFUSION && detail?.options?.scale"
>
<div class="tip">引导系数</div>
<div class="body">
{{ detail?.options?.scale }}
</div>
</div>
<div
class="item"
v-if="detail.platform === AiPlatformEnum.STABLE_DIFFUSION && detail?.options?.seed"
>
<div class="tip">随机因子</div>
<div class="body">
{{ detail?.options?.seed }}
</div> </div>
</div> </div>
</el-drawer> </el-drawer>
...@@ -58,6 +118,14 @@ ...@@ -58,6 +118,14 @@
<script setup lang="ts"> <script setup lang="ts">
import { ImageApi, ImageVO } from '@/api/ai/image' import { ImageApi, ImageVO } from '@/api/ai/image'
import ImageCard from './ImageCard.vue' import ImageCard from './ImageCard.vue'
import {
AiPlatformEnum,
ImageModelVO,
StableDiffusionClipGuidancePresets,
StableDiffusionSamplers,
StableDiffusionStylePresets
} from '@/views/ai/utils/constants'
import { formatTime } from '@/utils'
const showDrawer = ref<boolean>(false) // 是否显示 const showDrawer = ref<boolean>(false) // 是否显示
const detail = ref<ImageVO>({} as ImageVO) // 图片详细信息 const detail = ref<ImageVO>({} as ImageVO) // 图片详细信息
......
...@@ -27,12 +27,12 @@ ...@@ -27,12 +27,12 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import Dall3 from './dall3/index.vue'
import Midjourney from './midjourney/index.vue'
import StableDiffusion from './stable-diffusion/index.vue'
import ImageList from './components/ImageList.vue' import ImageList from './components/ImageList.vue'
import { AiPlatformEnum } from '@/views/ai/utils/constants' import { AiPlatformEnum } from '@/views/ai/utils/constants'
import { ImageVO } from '@/api/ai/image' import { ImageVO } from '@/api/ai/image'
import Dall3 from './dall3/index.vue'
import Midjourney from './midjourney/index.vue'
import StableDiffusion from './components/stableDiffusion/index.vue'
const imageListRef = ref<any>() // image 列表 ref const imageListRef = ref<any>() // image 列表 ref
const dall3Ref = ref<any>() // openai ref const dall3Ref = ref<any>() // openai ref
......
...@@ -40,3 +40,173 @@ export const AiMusicStatusEnum = { ...@@ -40,3 +40,173 @@ export const AiMusicStatusEnum = {
SUCCESS: 20, // 已完成 SUCCESS: 20, // 已完成
FAIL: 30 // 已失败 FAIL: 30 // 已失败
} }
// ========== 【图片 UI】相关的枚举 ==========
export const ImageHotWords = [
'中国旗袍',
'古装美女',
'卡通头像',
'机甲战士',
'童话小屋',
'中国长城'
] // 图片热词
export const ImageHotEnglishWords = [
'Chinese Cheongsam',
'Ancient Beauty',
'Cartoon Avatar',
'Mech Warrior',
'Fairy Tale Cottage',
'The Great Wall of China'
] // 图片热词(英文)
export interface ImageModelVO {
key: string
name: string
}
export const StableDiffusionSamplers = ref<ImageModelVO[]>([
{
key: 'DDIM',
name: 'DDIM'
},
{
key: 'DDPM',
name: 'DDPM'
},
{
key: 'K_DPMPP_2M',
name: 'K_DPMPP_2M'
},
{
key: 'K_DPMPP_2S_ANCESTRAL',
name: 'K_DPMPP_2S_ANCESTRAL'
},
{
key: 'K_DPM_2',
name: 'K_DPM_2'
},
{
key: 'K_DPM_2_ANCESTRAL',
name: 'K_DPM_2_ANCESTRAL'
},
{
key: 'K_EULER',
name: 'K_EULER'
},
{
key: 'K_EULER_ANCESTRAL',
name: 'K_EULER_ANCESTRAL'
},
{
key: 'K_HEUN',
name: 'K_HEUN'
},
{
key: 'K_LMS',
name: 'K_LMS'
}
])
export const StableDiffusionStylePresets = ref<ImageModelVO[]>([
{
key: '3d-model',
name: '3d-model'
},
{
key: 'analog-film',
name: 'analog-film'
},
{
key: 'anime',
name: 'anime'
},
{
key: 'cinematic',
name: 'cinematic'
},
{
key: 'comic-book',
name: 'comic-book'
},
{
key: 'digital-art',
name: 'digital-art'
},
{
key: 'enhance',
name: 'enhance'
},
{
key: 'fantasy-art',
name: 'fantasy-art'
},
{
key: 'isometric',
name: 'isometric'
},
{
key: 'line-art',
name: 'line-art'
},
{
key: 'low-poly',
name: 'low-poly'
},
{
key: 'modeling-compound',
name: 'modeling-compound'
},
// neon-punk origami photographic pixel-art tile-texture
{
key: 'neon-punk',
name: 'neon-punk'
},
{
key: 'origami',
name: 'origami'
},
{
key: 'photographic',
name: 'photographic'
},
{
key: 'pixel-art',
name: 'pixel-art'
},
{
key: 'tile-texture',
name: 'tile-texture'
}
])
export const StableDiffusionClipGuidancePresets = ref<ImageModelVO[]>([
{
key: 'NONE',
name: 'NONE'
},
{
key: 'FAST_BLUE',
name: 'FAST_BLUE'
},
{
key: 'FAST_GREEN',
name: 'FAST_GREEN'
},
{
key: 'SIMPLE',
name: 'SIMPLE'
},
{
key: 'SLOW',
name: 'SLOW'
},
{
key: 'SLOWER',
name: 'SLOWER'
},
{
key: 'SLOWEST',
name: 'SLOWEST'
}
])
...@@ -8,6 +8,6 @@ ...@@ -8,6 +8,6 @@
*/ */
/** 判断字符串是否包含中文 */ /** 判断字符串是否包含中文 */
export const hasChinese = async (str) => { export const hasChinese = (str: string) => {
return /[\u4e00-\u9fa5]/.test(str) return /[\u4e00-\u9fa5]/.test(str)
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment