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
b6ff9ede
authored
Jul 04, 2024
by
cherishsince
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【解决todo】handle命名
parent
bb34c2b7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
57 additions
and
61 deletions
+57
-61
src/views/ai/image/ImageDetailDrawer.vue
+5
-5
src/views/ai/image/ImageTask.vue
+10
-10
src/views/ai/image/ImageTaskCard.vue
+10
-10
src/views/ai/image/dall3/index.vue
+12
-15
src/views/ai/image/index.vue
+7
-7
src/views/ai/image/midjourney/index.vue
+12
-13
src/views/ai/image/stable-diffusion/index.vue
+1
-1
No files found.
src/views/ai/image/ImageDetailDrawer.vue
View file @
b6ff9ede
...
...
@@ -2,7 +2,7 @@
<el-drawer
v-model=
"showDrawer"
title=
"图片详细"
@
close=
"handle
r
DrawerClose"
@
close=
"handleDrawerClose"
custom-class=
"drawer-class"
>
<!-- 图片 -->
...
...
@@ -79,8 +79,8 @@ const props = defineProps({
})
/** 抽屉 - close */
const
handle
r
DrawerClose
=
async
()
=>
{
emits
(
'handle
r
DrawerClose'
)
const
handleDrawerClose
=
async
()
=>
{
emits
(
'handleDrawerClose'
)
}
/** 获取 - 图片 detail */
...
...
@@ -90,7 +90,7 @@ const getImageDetail = async (id) => {
}
/** 任务 - detail */
const
handle
r
TaskDetail
=
async
()
=>
{
const
handleTaskDetail
=
async
()
=>
{
showDrawer
.
value
=
true
}
...
...
@@ -107,7 +107,7 @@ watch(id, async (newVal, oldVal) => {
}
})
//
const
emits
=
defineEmits
([
'handle
r
DrawerClose'
])
const
emits
=
defineEmits
([
'handleDrawerClose'
])
//
onMounted
(
async
()
=>
{})
</
script
>
...
...
src/views/ai/image/ImageTask.vue
View file @
b6ff9ede
...
...
@@ -6,8 +6,8 @@
v-for=
"image in imageList"
:key=
"image"
:image-detail=
"image"
@
on-btn-click=
"handle
r
ImageBtnClick"
@
on-mj-btn-click=
"handle
r
ImageMjBtnClick"
@
on-btn-click=
"handleImageBtnClick"
@
on-mj-btn-click=
"handleImageMjBtnClick"
/>
</div>
<div
class=
"task-image-pagination"
>
...
...
@@ -16,7 +16,7 @@
layout=
"prev, pager, next"
:default-page-size=
"pageSize"
:total=
"pageTotal"
@
change=
"handle
r
PageChange"
@
change=
"handlePageChange"
/>
</div>
</el-card>
...
...
@@ -24,7 +24,7 @@
<ImageDetailDrawer
:show=
"isShowImageDetail"
:id=
"showImageDetailId"
@
handle
r-drawer-close=
"handler
DrawerClose"
@
handle
-drawer-close=
"handle
DrawerClose"
/>
</template>
<
script
setup
lang=
"ts"
>
...
...
@@ -49,12 +49,12 @@ const pageSize = ref<number>(10) // page size
const
pageTotal
=
ref
<
number
>
(
0
)
// page size
/** 抽屉 - close */
const
handle
r
DrawerClose
=
async
()
=>
{
const
handleDrawerClose
=
async
()
=>
{
isShowImageDetail
.
value
=
false
}
/** 任务 - detail */
const
handle
r
DrawerOpen
=
async
()
=>
{
const
handleDrawerOpen
=
async
()
=>
{
isShowImageDetail
.
value
=
true
}
...
...
@@ -117,12 +117,12 @@ const refreshWatchImages = async () => {
}
/** 图片 - btn click */
const
handle
r
ImageBtnClick
=
async
(
type
:
string
,
imageDetail
:
ImageVO
)
=>
{
const
handleImageBtnClick
=
async
(
type
:
string
,
imageDetail
:
ImageVO
)
=>
{
// 获取 image detail id
showImageDetailId
.
value
=
imageDetail
.
id
// 处理不用 btn
if
(
type
===
'more'
)
{
await
handle
r
DrawerOpen
()
await
handleDrawerOpen
()
}
else
if
(
type
===
'delete'
)
{
await
message
.
confirm
(
`是否删除照片?`
)
await
ImageApi
.
deleteImageMy
(
imageDetail
.
id
)
...
...
@@ -138,7 +138,7 @@ const handlerImageBtnClick = async (type: string, imageDetail: ImageVO) => {
}
/** 图片 - mj btn click */
const
handle
r
ImageMjBtnClick
=
async
(
button
:
ImageMjButtonsVO
,
imageDetail
:
ImageVO
)
=>
{
const
handleImageMjBtnClick
=
async
(
button
:
ImageMjButtonsVO
,
imageDetail
:
ImageVO
)
=>
{
// 1、构建 params 参数
const
data
=
{
id
:
imageDetail
.
id
,
...
...
@@ -171,7 +171,7 @@ const downloadImage = async (imageUrl) => {
}
// page change
const
handle
r
PageChange
=
async
(
page
)
=>
{
const
handlePageChange
=
async
(
page
)
=>
{
pageNo
.
value
=
page
await
getImageList
(
false
)
}
...
...
src/views/ai/image/ImageTaskCard.vue
View file @
b6ff9ede
...
...
@@ -23,21 +23,21 @@
class=
"btn"
text
:icon=
"Download"
@
click=
"handle
r
BtnClick('download', imageDetail)"
@
click=
"handleBtnClick('download', imageDetail)"
/>
<el-button
class=
"btn"
text
:icon=
"RefreshRight"
@
click=
"handle
r
BtnClick('regeneration', imageDetail)"
@
click=
"handleBtnClick('regeneration', imageDetail)"
/>
<el-button
class=
"btn"
text
:icon=
"Delete"
@
click=
"handle
r
BtnClick('delete', imageDetail)"
@
click=
"handleBtnClick('delete', imageDetail)"
/>
<el-button
class=
"btn"
text
:icon=
"More"
@
click=
"handle
r
BtnClick('more', imageDetail)"
/>
<el-button
class=
"btn"
text
:icon=
"More"
@
click=
"handleBtnClick('more', imageDetail)"
/>
</div>
</div>
<div
class=
"image-wrapper"
ref=
"cardImageRef"
>
...
...
@@ -54,7 +54,7 @@
v-for=
"button in imageDetail?.buttons"
:key=
"button"
style=
"min-width: 40px; margin-left: 0; margin-right: 10px; margin-top: 5px"
@
click=
"handle
r
MjBtnClick(button)"
@
click=
"handleMjBtnClick(button)"
>
{{
button
.
label
}}{{
button
.
emoji
}}
</el-button>
...
...
@@ -79,11 +79,11 @@ const props = defineProps({
})
/** 按钮 - 点击事件 */
const
handle
r
BtnClick
=
async
(
type
,
imageDetail
:
ImageVO
)
=>
{
const
handleBtnClick
=
async
(
type
,
imageDetail
:
ImageVO
)
=>
{
emits
(
'onBtnClick'
,
type
,
imageDetail
)
}
const
handle
r
Loading
=
async
(
status
:
number
)
=>
{
const
handleLoading
=
async
(
status
:
number
)
=>
{
// TODO @fan:这个搞成 Loading 组件,然后通过数据驱动,这样搞可以哇?
if
(
status
===
AiImageStatusEnum
.
IN_PROGRESS
)
{
cardImageLoadingInstance
.
value
=
ElLoading
.
service
({
...
...
@@ -99,7 +99,7 @@ const handlerLoading = async (status: number) => {
}
/** mj 按钮 click */
const
handle
r
MjBtnClick
=
async
(
button
:
ImageMjButtonsVO
)
=>
{
const
handleMjBtnClick
=
async
(
button
:
ImageMjButtonsVO
)
=>
{
// 确认窗体
await
message
.
confirm
(
`确认操作 "
${
button
.
label
}
${
button
.
emoji
}
" ?`
)
emits
(
'onMjBtnClick'
,
button
,
props
.
imageDetail
)
...
...
@@ -108,7 +108,7 @@ const handlerMjBtnClick = async (button: ImageMjButtonsVO) => {
// watch
const
{
imageDetail
}
=
toRefs
(
props
)
watch
(
imageDetail
,
async
(
newVal
,
oldVal
)
=>
{
await
handle
r
Loading
(
newVal
.
status
as
string
)
await
handleLoading
(
newVal
.
status
as
string
)
})
// emits
...
...
@@ -116,7 +116,7 @@ const emits = defineEmits(['onBtnClick', 'onMjBtnClick'])
//
onMounted
(
async
()
=>
{
await
handle
r
Loading
(
props
.
imageDetail
.
status
as
string
)
await
handleLoading
(
props
.
imageDetail
.
status
as
string
)
})
</
script
>
...
...
src/views/ai/image/dall3/index.vue
View file @
b6ff9ede
...
...
@@ -25,7 +25,7 @@
:type=
"(selectHotWord === hotWord ? 'primary' : 'default')"
v-for=
"hotWord in hotWords"
:key=
"hotWord"
@
click=
"handle
r
HotWordClick(hotWord)"
@
click=
"handleHotWordClick(hotWord)"
>
{{
hotWord
}}
</el-button>
...
...
@@ -45,7 +45,7 @@
<el-image
:src=
"model.image"
fit=
"contain"
@
click=
"handle
r
ModelClick(model)"
@
click=
"handleModelClick(model)"
/>
<div
class=
"model-font"
>
{{
model
.
name
}}
</div>
</div>
...
...
@@ -64,7 +64,7 @@
<el-image
:src=
"imageStyle.image"
fit=
"contain"
@
click=
"handle
r
StyleClick(imageStyle)"
@
click=
"handleStyleClick(imageStyle)"
/>
<div
class=
"style-font"
>
{{
imageStyle
.
name
}}
</div>
</div>
...
...
@@ -78,7 +78,7 @@
<div
class=
"size-item"
v-for=
"imageSize in imageSizeList"
:key=
"imageSize.key"
@
click=
"handle
r
SizeClick(imageSize)"
>
@
click=
"handleSizeClick(imageSize)"
>
<div
:class=
"selectImageSize === imageSize.key ? 'size-wrapper selectImageSize' : 'size-wrapper'"
>
<div
:style=
"imageSize.style"
></div>
</div>
...
...
@@ -91,7 +91,7 @@
size=
"large"
round
:loading=
"drawIn"
@
click=
"handle
r
GenerateImage"
>
@
click=
"handleGenerateImage"
>
{{
drawIn
?
'生成中'
:
'生成内容'
}}
</el-button>
</div>
...
...
@@ -183,10 +183,8 @@ const props = defineProps({})
// 定义 emits
const
emits
=
defineEmits
([
'onDrawStart'
,
'onDrawComplete'
])
// TODO @fan:如果是简单注释,建议用 /** */,主要是现在项目里是这种风格哈,保持一致好点~
// TODO @fan:handler 应该改成 handle 哈
/** 热词 - click */
const
handle
r
HotWordClick
=
async
(
hotWord
:
string
)
=>
{
const
handleHotWordClick
=
async
(
hotWord
:
string
)
=>
{
// 取消选中
if
(
selectHotWord
.
value
==
hotWord
)
{
selectHotWord
.
value
=
''
...
...
@@ -199,22 +197,22 @@ const handlerHotWordClick = async (hotWord: string) => {
}
/** 模型 - click */
const
handle
r
ModelClick
=
async
(
model
:
ImageModelVO
)
=>
{
const
handleModelClick
=
async
(
model
:
ImageModelVO
)
=>
{
selectModel
.
value
=
model
.
key
}
/** 样式 - click */
const
handle
r
StyleClick
=
async
(
imageStyle
:
ImageModelVO
)
=>
{
const
handleStyleClick
=
async
(
imageStyle
:
ImageModelVO
)
=>
{
selectImageStyle
.
value
=
imageStyle
.
key
}
/** size - click */
const
handle
r
SizeClick
=
async
(
imageSize
:
ImageSizeVO
)
=>
{
const
handleSizeClick
=
async
(
imageSize
:
ImageSizeVO
)
=>
{
selectImageSize
.
value
=
imageSize
.
key
}
/** 图片生产 */
const
handle
r
GenerateImage
=
async
()
=>
{
const
handleGenerateImage
=
async
()
=>
{
// 二次确认
await
message
.
confirm
(
`确认生成内容?`
)
try
{
...
...
@@ -251,15 +249,14 @@ const settingValues = async (imageDetail: ImageVO) => {
selectImageStyle
.
value
=
imageDetail
.
options
?.
style
//
const
imageSize
=
imageSizeList
.
value
.
find
(
item
=>
item
.
key
===
`
${
imageDetail
.
width
}
x
${
imageDetail
.
height
}
`
)
as
ImageSizeVO
console
.
log
(
'imageSize'
,
imageSize
)
await
handlerSizeClick
(
imageSize
)
await
handleSizeClick
(
imageSize
)
}
/** 暴露组件方法 */
defineExpose
({
settingValues
})
</
script
>
<
style
scoped
lang=
"scss"
>
//
提示词
.prompt
{
}
...
...
src/views/ai/image/index.vue
View file @
b6ff9ede
...
...
@@ -9,8 +9,8 @@
<Dall3
v-if=
"selectPlatform === AiPlatformEnum.OPENAI"
ref=
"dall3Ref"
@
on-draw-start=
"handle
r
DrawStart"
@
on-draw-complete=
"handle
r
DrawComplete"
@
on-draw-start=
"handleDrawStart"
@
on-draw-complete=
"handleDrawComplete"
/>
<Midjourney
v-if=
"selectPlatform === AiPlatformEnum.MIDJOURNEY"
...
...
@@ -19,12 +19,12 @@
<StableDiffusion
v-if=
"selectPlatform === AiPlatformEnum.STABLE_DIFFUSION"
ref=
"stableDiffusionRef"
@
on-draw-complete=
"handle
r
DrawComplete"
@
on-draw-complete=
"handleDrawComplete"
/>
</div>
</div>
<div
class=
"main"
>
<ImageTask
ref=
"imageTaskRef"
@
on-regeneration=
"handle
r
Regeneration"
/>
<ImageTask
ref=
"imageTaskRef"
@
on-regeneration=
"handleRegeneration"
/>
</div>
</div>
</
template
>
...
...
@@ -63,20 +63,20 @@ const platformOptions = [
const
drawIn
=
ref
<
boolean
>
(
false
)
// 生成中
/** 绘画 - start */
const
handle
r
DrawStart
=
async
(
type
)
=>
{
const
handleDrawStart
=
async
(
type
)
=>
{
// todo @fan:这个是不是没用啦?
drawIn
.
value
=
true
}
/** 绘画 - complete */
const
handle
r
DrawComplete
=
async
(
type
)
=>
{
const
handleDrawComplete
=
async
(
type
)
=>
{
drawIn
.
value
=
false
// todo
await
imageTaskRef
.
value
.
getImageList
()
}
/** 绘画 - 重新生成 */
const
handle
r
Regeneration
=
async
(
imageDetail
:
ImageVO
)
=>
{
const
handleRegeneration
=
async
(
imageDetail
:
ImageVO
)
=>
{
// 切换平台
selectPlatform
.
value
=
imageDetail
.
platform
console
.
log
(
'切换平台'
,
imageDetail
.
platform
)
...
...
src/views/ai/image/midjourney/index.vue
View file @
b6ff9ede
...
...
@@ -24,7 +24,7 @@
:type=
"(selectHotWord === hotWord ? 'primary' : 'default')"
v-for=
"hotWord in hotWords"
:key=
"hotWord"
@
click=
"handle
r
HotWordClick(hotWord)"
@
click=
"handleHotWordClick(hotWord)"
>
{{
hotWord
}}
</el-button>
...
...
@@ -38,7 +38,7 @@
<div
class=
"size-item"
v-for=
"imageSize in imageSizeList"
:key=
"imageSize.key"
@
click=
"handle
r
SizeClick(imageSize)"
>
@
click=
"handleSizeClick(imageSize)"
>
<div
:class=
"selectImageSize === imageSize.key ? 'size-wrapper selectImageSize' : 'size-wrapper'"
>
<div
:style=
"imageSize.style"
></div>
</div>
...
...
@@ -57,7 +57,7 @@
clearable
placeholder=
"请选择版本"
style=
"width: 350px"
@
change=
"handle
r
ChangeVersion"
@
change=
"handleChangeVersion"
>
<el-option
v-for=
"item in versionList"
...
...
@@ -82,7 +82,7 @@
<el-image
:src=
"model.image"
fit=
"contain"
@
click=
"handle
r
ModelClick(model)"
@
click=
"handleModelClick(model)"
/>
<div
class=
"model-font"
>
{{
model
.
name
}}
</div>
</div>
...
...
@@ -98,7 +98,7 @@
</div>
<div
class=
"btns"
>
<!--
<el-button
size=
"large"
round
>
重置内容
</el-button>
-->
<el-button
type=
"primary"
size=
"large"
round
@
click=
"handle
r
GenerateImage"
>
生成内容
</el-button>
<el-button
type=
"primary"
size=
"large"
round
@
click=
"handleGenerateImage"
>
生成内容
</el-button>
</div>
</
template
>
<
script
setup
lang=
"ts"
>
...
...
@@ -211,7 +211,7 @@ let versionList = ref<any>([]) // version 列表
versionList
.
value
=
midjourneyVersionList
.
value
// 默认选择 midjourney
/** 热词 - click */
const
handle
r
HotWordClick
=
async
(
hotWord
:
string
)
=>
{
const
handleHotWordClick
=
async
(
hotWord
:
string
)
=>
{
// 取消
if
(
selectHotWord
.
value
==
hotWord
)
{
selectHotWord
.
value
=
''
...
...
@@ -224,12 +224,12 @@ const handlerHotWordClick = async (hotWord: string) => {
}
/** size - click */
const
handle
r
SizeClick
=
async
(
imageSize
:
ImageSizeVO
)
=>
{
const
handleSizeClick
=
async
(
imageSize
:
ImageSizeVO
)
=>
{
selectImageSize
.
value
=
imageSize
.
key
}
/** 模型 - click */
const
handle
r
ModelClick
=
async
(
model
:
ImageModelVO
)
=>
{
const
handleModelClick
=
async
(
model
:
ImageModelVO
)
=>
{
selectModel
.
value
=
model
.
key
if
(
model
.
key
===
'niji'
)
{
versionList
.
value
=
nijiVersionList
.
value
// 默认选择 niji
...
...
@@ -240,21 +240,20 @@ const handlerModelClick = async (model: ImageModelVO) => {
}
/** version - click */
const
handle
r
ChangeVersion
=
async
(
version
)
=>
{
const
handleChangeVersion
=
async
(
version
)
=>
{
console
.
log
(
'version'
,
version
)
}
/** 图片生产 */
const
handle
r
GenerateImage
=
async
()
=>
{
const
handleGenerateImage
=
async
()
=>
{
// 二次确认
await
message
.
confirm
(
`确认生成内容?`
)
// todo @范 图片生产逻辑
try
{
console
.
log
(
'referImage.value'
,
referImage
.
value
)
// 回调
emits
(
'onDrawStart'
,
selectModel
.
value
)
// 发送请求
const
imageSize
=
imageSizeList
.
value
.
find
(
item
=>
selectImageSize
===
item
.
key
)
as
ImageSizeVO
const
imageSize
=
imageSizeList
.
value
.
find
(
item
=>
selectImageSize
.
value
===
item
.
key
)
as
ImageSizeVO
const
req
=
{
prompt
:
prompt
.
value
,
model
:
selectModel
.
value
,
...
...
@@ -279,7 +278,7 @@ const settingValues = async (imageDetail: ImageVO) => {
selectImageSize
.
value
=
imageSize
.
key
// 选中模型
const
model
=
models
.
value
.
find
(
item
=>
item
.
key
===
imageDetail
.
options
?.
model
)
as
ImageModelVO
await
handle
r
ModelClick
(
model
)
await
handleModelClick
(
model
)
// 版本
selectVersion
.
value
=
versionList
.
value
.
find
(
item
=>
item
.
value
===
imageDetail
.
options
?.
version
).
value
// image
...
...
src/views/ai/image/stable-diffusion/index.vue
View file @
b6ff9ede
...
...
@@ -351,7 +351,7 @@ const handleGenerateImage = async () => {
steps
:
steps
.
value
,
// 图片生成步数
scale
:
scale
.
value
,
// 引导系数
sampler
:
selectSampler
.
value
,
// 采样算法
clipGuidancePreset
:
selectClipGuidancePreset
.
value
.
key
,
// 文本提示相匹配的图像 CLIP
clipGuidancePreset
:
selectClipGuidancePreset
.
value
,
// 文本提示相匹配的图像 CLIP
stylePreset
:
selectStylePreset
.
value
,
// 风格
}
}
as
ImageDrawReqVO
...
...
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