Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
80d87b8e
authored
Jul 08, 2024
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【代码优化】AI:绘图 index.vue 代码梳理 20%
parent
62246021
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
45 deletions
+33
-45
src/views/ai/image/index/components/ImageCard.vue
+0
-0
src/views/ai/image/index/components/ImageDetail.vue
+3
-3
src/views/ai/image/index/components/ImageList.vue
+10
-9
src/views/ai/image/index/index.vue
+20
-33
No files found.
src/views/ai/image/index/
ImageTask
Card.vue
→
src/views/ai/image/index/
components/Image
Card.vue
View file @
80d87b8e
File moved
src/views/ai/image/index/
ImageDetailDrawer
.vue
→
src/views/ai/image/index/
components/ImageDetail
.vue
View file @
80d87b8e
...
...
@@ -13,8 +13,8 @@
<!--
</div>
-->
<!--
</div>
-->
<div
class=
"body"
>
<!-- TODO @fan: 要不,这里只展示图片???不用 Image
Task
Card -->
<Image
Task
Card
:image-detail=
"imageDetail"
/>
<!-- TODO @fan: 要不,这里只展示图片???不用 ImageCard -->
<ImageCard
:image-detail=
"imageDetail"
/>
</div>
</div>
<!-- 时间 -->
...
...
@@ -60,7 +60,7 @@
<
script
setup
lang=
"ts"
>
import
{
ImageApi
,
ImageVO
}
from
'@/api/ai/image'
import
Image
TaskCard
from
'./ImageTask
Card.vue'
import
Image
Card
from
'./Image
Card.vue'
const
showDrawer
=
ref
<
boolean
>
(
false
)
// 是否显示
const
imageDetail
=
ref
<
ImageVO
>
({}
as
ImageVO
)
// 图片详细信息
...
...
src/views/ai/image/index/
ImageTask
.vue
→
src/views/ai/image/index/
components/ImageList
.vue
View file @
80d87b8e
<
template
>
<el-card
class=
"dr-task"
body-class=
"task-card"
shadow=
"never"
>
<template
#
header
>
绘画任务
</
template
>
<!-- 图片列表 -->
<div
class=
"task-image-list"
ref=
"imageTaskRef"
>
<Image
Task
Card
<ImageCard
v-for=
"image in imageList"
:key=
"image"
:key=
"image
.id
"
:image-detail=
"image"
@
on-btn-click=
"handleImageBtnClick"
@
on-mj-btn-click=
"handleImageMjBtnClick"
...
...
@@ -20,8 +21,9 @@
/>
</div>
</el-card>
<!-- 图片 detail 抽屉 -->
<ImageDetailDrawer
<!-- 图片详情 -->
<ImageDetail
:show=
"isShowImageDetail"
:id=
"showImageDetailId"
@
handle-drawer-close=
"handleDrawerClose"
...
...
@@ -29,8 +31,8 @@
</template>
<
script
setup
lang=
"ts"
>
import
{
ImageApi
,
ImageVO
,
ImageMjActionVO
,
ImageMjButtonsVO
}
from
'@/api/ai/image'
import
ImageDetail
Drawer
from
'./ImageDetailDrawer
.vue'
import
Image
TaskCard
from
'./ImageTask
Card.vue'
import
ImageDetail
from
'./ImageDetail
.vue'
import
Image
Card
from
'./Image
Card.vue'
import
{
ElLoading
,
LoadingOptionsResolved
}
from
'element-plus'
import
{
AiImageStatusEnum
}
from
'@/views/ai/utils/constants'
import
{
downloadImage
}
from
'@/utils/download'
...
...
@@ -181,6 +183,7 @@ onUnmounted(async () => {
})
</
script
>
<!-- TODO fan:这 2 个 scss 可以合并么? -->
<
style
lang=
"scss"
>
.task-card
{
margin
:
0
;
...
...
@@ -197,8 +200,7 @@ onUnmounted(async () => {
align-content
:
flex-start
;
height
:
100%
;
overflow
:
auto
;
padding
:
20px
;
padding-bottom
:
140px
;
padding
:
20px
20px
140px
;
box-sizing
:
border-box
;
/* 确保内边距不会增加高度 */
>
div
{
...
...
@@ -224,7 +226,6 @@ onUnmounted(async () => {
align-items
:
center
;
}
</
style
>
<
style
scoped
lang=
"scss"
>
.dr-task
{
width
:
100%
;
...
...
src/views/ai/image/index/index.vue
View file @
80d87b8e
...
...
@@ -12,10 +12,7 @@
@
on-draw-start=
"handleDrawStart"
@
on-draw-complete=
"handleDrawComplete"
/>
<Midjourney
v-if=
"selectPlatform === AiPlatformEnum.MIDJOURNEY"
ref=
"midjourneyRef"
/>
<Midjourney
v-if=
"selectPlatform === AiPlatformEnum.MIDJOURNEY"
ref=
"midjourneyRef"
/>
<StableDiffusion
v-if=
"selectPlatform === AiPlatformEnum.STABLE_DIFFUSION"
ref=
"stableDiffusionRef"
...
...
@@ -24,22 +21,20 @@
</div>
</div>
<div
class=
"main"
>
<Image
Task
ref=
"imageTask
Ref"
@
on-regeneration=
"handleRegeneration"
/>
<Image
List
ref=
"imageList
Ref"
@
on-regeneration=
"handleRegeneration"
/>
</div>
</div>
</
template
>
<
script
setup
lang=
"ts"
>
// TODO @fan:在整个挪到 /views/ai/image/index 目录。因为我想在 /views/ai/image/manager 做管理的功能,进行下区分!
import
Dall3
from
'./dall3/index.vue'
import
Midjourney
from
'./midjourney/index.vue'
import
StableDiffusion
from
'./stable-diffusion/index.vue'
import
Image
Task
from
'./ImageTask
.vue'
import
Image
List
from
'./components/ImageList
.vue'
import
{
AiPlatformEnum
}
from
'@/views/ai/utils/constants'
import
{
ImageVO
}
from
"@/api/ai/image"
;
import
{
ImageVO
}
from
'@/api/ai/image'
const
image
TaskRef
=
ref
<
any
>
()
// image task
ref
const
image
ListRef
=
ref
<
any
>
()
// image 列表
ref
const
dall3Ref
=
ref
<
any
>
()
// openai ref
const
midjourneyRef
=
ref
<
any
>
()
// midjourney ref
const
stableDiffusionRef
=
ref
<
any
>
()
// stable diffusion ref
...
...
@@ -61,35 +56,27 @@ const platformOptions = [
}
]
/** 绘画 - start */
const
handleDrawStart
=
async
(
type
)
=>
{
}
/** 绘画 start */
const
handleDrawStart
=
async
(
type
)
=>
{}
/**
绘画 -
complete */
/**
绘画
complete */
const
handleDrawComplete
=
async
(
type
)
=>
{
await
image
Task
Ref
.
value
.
getImageList
()
await
image
List
Ref
.
value
.
getImageList
()
}
/**
绘画 - 重新生成
*/
const
handleRegeneration
=
async
(
image
Detail
:
ImageVO
)
=>
{
/**
重新生成:将画图详情填充到对应平台
*/
const
handleRegeneration
=
async
(
image
:
ImageVO
)
=>
{
// 切换平台
selectPlatform
.
value
=
imageDetail
.
platform
console
.
log
(
'切换平台'
,
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
)
})
selectPlatform
.
value
=
image
.
platform
// 根据不同平台填充 image
await
nextTick
()
if
(
image
.
platform
===
AiPlatformEnum
.
MIDJOURNEY
)
{
midjourneyRef
.
value
.
settingValues
(
image
)
}
else
if
(
image
.
platform
===
AiPlatformEnum
.
OPENAI
)
{
dall3Ref
.
value
.
settingValues
(
image
)
}
else
if
(
image
.
platform
===
AiPlatformEnum
.
STABLE_DIFFUSION
)
{
stableDiffusionRef
.
value
.
settingValues
(
image
)
}
}
</
script
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment