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
fdeedcfe
authored
May 28, 2024
by
cherishsince
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【增加】Image card 增加图片下载
parent
2211618a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
14 deletions
+31
-14
src/views/ai/image/ImageTask.vue
+24
-0
src/views/ai/image/ImageTaskCard.vue
+7
-14
No files found.
src/views/ai/image/ImageTask.vue
View file @
fdeedcfe
...
...
@@ -66,8 +66,32 @@ const handlerImageBtnClick = async (type, imageDetail: ImageDetailVO) => {
await
ImageApi
.
deleteImage
(
imageDetail
.
id
)
await
getImageList
()
await
message
.
success
(
"删除成功!"
)
}
else
if
(
type
===
'download'
)
{
downloadImage
(
imageDetail
.
picUrl
)
}
}
/**
* 下载 - image
*/
const
downloadImage
=
async
(
imageUrl
)
=>
{
const
image
=
new
Image
()
image
.
setAttribute
(
'crossOrigin'
,
'anonymous'
)
image
.
src
=
imageUrl
image
.
onload
=
()
=>
{
const
canvas
=
document
.
createElement
(
'canvas'
)
canvas
.
width
=
image
.
width
canvas
.
height
=
image
.
height
const
ctx
=
canvas
.
getContext
(
'2d'
)
ctx
.
drawImage
(
image
,
0
,
0
,
image
.
width
,
image
.
height
)
const
url
=
canvas
.
toDataURL
(
'image/png'
)
const
a
=
document
.
createElement
(
'a'
)
a
.
href
=
url
a
.
download
=
'image.png'
a
.
click
()
}
}
//
defineExpose
({
getImageList
})
//
...
...
src/views/ai/image/ImageTaskCard.vue
View file @
fdeedcfe
<
template
>
<el-card
body-class=
""
class=
"image-card"
>
<div
class=
"image-operation"
>
...
...
@@ -8,13 +7,14 @@
<el-button
type=
""
text
bg
v-else-if=
"imageDetail.status === 'complete'"
>
已完成
</el-button>
</div>
<div>
<el-button
class=
"btn"
text
:icon=
"Download"
@
click=
"handlerBtnClick('download', imageDetail)"
/>
<el-button
class=
"btn"
text
:icon=
"Delete"
@
click=
"handlerBtnClick('delete', imageDetail)"
/>
<el-button
class=
"btn"
text
:icon=
"More"
@
click=
"handlerBtnClick('more', imageDetail)"
/>
<el-button
class=
"btn"
text
:icon=
"Download"
@
click=
"handlerBtnClick('download', imageDetail)"
/>
<el-button
class=
"btn"
text
:icon=
"Delete"
@
click=
"handlerBtnClick('delete', imageDetail)"
/>
<el-button
class=
"btn"
text
:icon=
"More"
@
click=
"handlerBtnClick('more', imageDetail)"
/>
</div>
</div>
<div
class=
"image-wrapper"
ref=
"cardImageRef"
>
<img
class=
"image"
:src=
"imageDetail?.picUrl"
/>
<img
class=
"image"
:src=
"imageDetail?.picUrl"
/>
</div>
</el-card>
</
template
>
...
...
@@ -37,22 +37,15 @@ const props = defineProps({
/**
* 按钮 - 点击事件
*/
const
handlerBtnClick
=
async
(
type
,
imageDetail
:
ImageDetailVO
)
=>
{
const
handlerBtnClick
=
async
(
type
,
imageDetail
:
ImageDetailVO
)
=>
{
emits
(
'onBtnClick'
,
type
,
imageDetail
)
}
// 监听 imageDetail
// const { imageDetail } = toRefs(props)
// watch(imageDetail, async (newVal, oldValue) => {
// console.log('首次 watch')
//
// })
// emits
const
emits
=
defineEmits
([
'onBtnClick'
])
//
onMounted
(
async
()
=>
{
onMounted
(
async
()
=>
{
if
(
props
.
imageDetail
.
status
===
'in_progress'
)
{
cardImageLoadingInstance
.
value
=
ElLoading
.
service
({
target
:
cardImageRef
.
value
,
...
...
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