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
d5d783af
authored
Jul 30, 2024
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【代码优化】AI:image 作品中心的代码
parent
1fe40b61
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
48 deletions
+76
-48
src/api/ai/image/index.ts
+2
-6
src/router/modules/remaining.ts
+21
-20
src/views/ai/image/index/components/ImageList.vue
+13
-1
src/views/ai/image/square/index.vue
+40
-21
No files found.
src/api/ai/image/index.ts
View file @
d5d783af
...
...
@@ -53,13 +53,9 @@ export interface ImageMidjourneyButtonsVO {
// AI 图片 API
export
const
ImageApi
=
{
// 获取【我的】绘图分页
getImagePageMy
:
async
(
params
:
PageParam
)
=>
{
getImagePageMy
:
async
(
params
:
any
)
=>
{
return
await
request
.
get
({
url
:
`/ai/image/my-page`
,
params
})
},
// 获取公开的绘图记录
getImagePagePublic
:
async
(
params
)
=>
{
return
await
request
.
get
({
url
:
`/ai/image/public-page`
,
params
})
},
// 获取【我的】绘图记录
getImageMy
:
async
(
id
:
number
)
=>
{
return
await
request
.
get
({
url
:
`/ai/image/get-my?id=
${
id
}
`
})
...
...
@@ -97,7 +93,7 @@ export const ImageApi = {
// 更新绘画发布状态
updateImage
:
async
(
data
:
any
)
=>
{
return
await
request
.
put
({
url
:
'/ai/image/update
-public-status
'
,
data
})
return
await
request
.
put
({
url
:
'/ai/image/update'
,
data
})
},
// 删除绘画
...
...
src/router/modules/remaining.ts
View file @
d5d783af
...
...
@@ -70,26 +70,6 @@ const remainingRouter: AppRouteRecordRaw[] = [
}
]
},
// {
// path: '/ai/music',
// component: Layout,
// redirect: '/index',
// name: 'AIMusic',
// meta: {},
// children: [
// {
// path: 'index',
// component: () => import('@/views/ai/music/components/index.vue'),
// name: 'AIMusicIndex',
// meta: {
// title: 'AI 音乐',
// icon: 'ep:home-filled',
// noCache: false,
// affix: true
// }
// }
// ]
// },
{
path
:
'/user'
,
component
:
Layout
,
...
...
@@ -593,6 +573,27 @@ const remainingRouter: AppRouteRecordRaw[] = [
component
:
()
=>
import
(
'@/views/crm/product/detail/index.vue'
)
}
]
},
{
path
:
'/ai'
,
component
:
Layout
,
name
:
'Ai'
,
meta
:
{
hidden
:
true
},
children
:
[
{
path
:
'image/square'
,
component
:
()
=>
import
(
'@/views/ai/image/square/index.vue'
),
name
:
'AiImageSquare'
,
meta
:
{
title
:
'绘图作品'
,
icon
:
'ep:home-filled'
,
noCache
:
false
,
affix
:
true
}
}
]
}
]
...
...
src/views/ai/image/index/components/ImageList.vue
View file @
d5d783af
<
template
>
<el-card
class=
"dr-task"
body-class=
"task-card"
shadow=
"never"
>
<template
#
header
>
绘画任务
</
template
>
<template
#
header
>
绘画任务
<!-- TODO @fan:看看,怎么优化下这个样子哈。 -->
<el-button
@
click=
"handleViewPublic"
>
绘画作品
</el-button>
</
template
>
<!-- 图片列表 -->
<div
class=
"task-image-list"
ref=
"imageListRef"
>
<ImageCard
...
...
@@ -42,6 +46,7 @@ import { AiImageStatusEnum } from '@/views/ai/utils/constants'
import
download
from
'@/utils/download'
const
message
=
useMessage
()
// 消息弹窗
const
router
=
useRouter
()
// 路由
// 图片分页相关的参数
const
queryParams
=
reactive
({
...
...
@@ -59,6 +64,13 @@ const inProgressTimer = ref<any>() // 葉 image 摰嚗蔭霂Y
const
isShowImageDetail
=
ref
<
boolean
>
(
false
)
// 图片详情是否展示
const
showImageDetailId
=
ref
<
number
>
(
0
)
// 图片详情的图片编号
/** 处理查看绘图作品 */
const
handleViewPublic
=
()
=>
{
router
.
push
({
name
:
'AiImageSquare'
})
}
/** 查看图片的详情 */
const
handleDetailOpen
=
async
()
=>
{
isShowImageDetail
.
value
=
true
...
...
src/views/ai/image/square/index.vue
View file @
d5d783af
<
template
>
<div
class=
"square-container"
>
<!-- TODO @fan:style 建议换成 unocss -->
<!-- TODO @fan:Search 可以换成 Icon 组件么? -->
<el-input
v-model=
"
searchTex
t"
v-model=
"
queryParams.promp
t"
style=
"width: 100%; margin-bottom: 20px"
size=
"large"
placeholder=
"请输入要搜索的内容"
:suffix-icon=
"Search"
@
keyup
.
enter=
"handle
Search
"
@
keyup
.
enter=
"handle
Query
"
/>
<div
class=
"gallery"
>
<div
v-for=
"item in publicList"
:key=
"item.id"
class=
"gallery-item"
>
<!-- TODO @fan:这个图片的风格,要不和 ImageCard.vue 界面一致?(只有卡片,没有操作);因为看着更有相框的感觉~~~ -->
<div
v-for=
"item in list"
:key=
"item.id"
class=
"gallery-item"
>
<img
:src=
"item.picUrl"
class=
"img"
/>
</div>
</div>
<!-- TODO @fan:缺少翻页 -->
<!-- 分页 -->
<Pagination
:total=
"total"
v-model:page=
"queryParams.pageNo"
v-model:limit=
"queryParams.pageSize"
@
pagination=
"getList"
/>
</div>
</
template
>
<
script
setup
lang=
"ts"
>
import
{
ImageApi
,
ImageVO
}
from
'@/api/ai/image'
import
{
Search
}
from
'@element-plus/icons-vue'
/** 属性 */
// TODO @fan:queryParams 里面搞分页哈。
const
pageNo
=
ref
<
number
>
(
1
)
const
pageSize
=
ref
<
number
>
(
20
)
const
publicList
=
ref
<
ImageVO
[]
>
([])
const
searchText
=
ref
<
string
>
(
''
)
// TODO @fan:加个 loading 加载中的状态
const
loading
=
ref
(
true
)
// 列表的加载中
const
list
=
ref
<
ImageVO
[]
>
([])
// 列表的数据
const
total
=
ref
(
0
)
// 列表的总页数
const
queryParams
=
reactive
({
pageNo
:
1
,
pageSize
:
10
,
publicStatus
:
true
,
prompt
:
undefined
})
/** 获取数据 */
const
getListData
=
async
()
=>
{
const
res
=
await
ImageApi
.
getImagePagePublic
({
pageNo
:
pageNo
.
value
,
pageSize
:
pageSize
.
value
,
prompt
:
searchText
.
value
})
publicList
.
value
=
res
.
list
as
ImageVO
[]
/** 查询列表 */
const
getList
=
async
()
=>
{
loading
.
value
=
true
try
{
const
data
=
await
ImageApi
.
getImagePageMy
(
queryParams
)
list
.
value
=
data
.
list
total
.
value
=
data
.
total
}
finally
{
loading
.
value
=
false
}
}
/** 搜索 */
const
handleSearch
=
async
()
=>
{
await
getListData
()
/** 搜索按钮操作 */
const
handleQuery
=
()
=>
{
queryParams
.
pageNo
=
1
getList
()
}
/** 初始化 */
onMounted
(
async
()
=>
{
await
getList
Data
()
await
getList
()
})
</
script
>
<
style
scoped
lang=
"scss"
>
...
...
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