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
ef90faf7
authored
Apr 30, 2025
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:关闭头像上传时,又自动打开
reactor:头像上传时,通过前端 httpRequest ,可支持前端直传
parent
165ce58a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
14 deletions
+19
-14
src/api/system/user/profile.ts
+5
-9
src/components/Cropper/src/CopperModal.vue
+2
-1
src/views/Profile/components/UserAvatar.vue
+12
-4
No files found.
src/api/system/user/profile.ts
View file @
ef90faf7
...
...
@@ -32,10 +32,11 @@ export interface ProfileVO {
}
export
interface
UserProfileUpdateReqVO
{
nickname
:
string
email
:
string
mobile
:
string
sex
:
number
nickname
?:
string
email
?:
string
mobile
?:
string
sex
?:
number
avatar
?:
string
}
// 查询用户个人信息
...
...
@@ -58,8 +59,3 @@ export const updateUserPassword = (oldPassword: string, newPassword: string) =>
}
})
}
// 用户头像上传
export
const
uploadAvatar
=
(
data
)
=>
{
return
request
.
upload
({
url
:
'/system/user/profile/update-avatar'
,
data
:
data
})
}
src/components/Cropper/src/CopperModal.vue
View file @
ef90faf7
<
template
>
<div>
<div
@
click
.
stop
>
<Dialog
v-model=
"dialogVisible"
:canFullscreen=
"false"
...
...
@@ -181,6 +181,7 @@ function openModal() {
}
function
closeModal
()
{
debugger
dialogVisible
.
value
=
false
}
...
...
src/views/Profile/components/UserAvatar.vue
View file @
ef90faf7
...
...
@@ -12,9 +12,11 @@
</
template
>
<
script
lang=
"ts"
setup
>
import
{
propTypes
}
from
'@/utils/propTypes'
import
{
up
loadAvatar
}
from
'@/api/system/user/profile'
import
{
up
dateUserProfile
}
from
'@/api/system/user/profile'
import
{
CropperAvatar
}
from
'@/components/Cropper'
import
{
useUserStore
}
from
'@/store/modules/user'
import
{
useUpload
}
from
'@/components/UploadFile/src/useUpload'
import
{
UploadRequestOptions
}
from
'element-plus/es/components/upload/src/upload'
// TODO @芋艿:合并到 ProfileUser 组件中,更简洁一点
defineOptions
({
name
:
'UserAvatar'
})
...
...
@@ -27,10 +29,16 @@ const userStore = useUserStore()
const
cropperRef
=
ref
()
const
handelUpload
=
async
({
data
})
=>
{
// TODO @芋艿:去掉这个接口,使用 url 直接上传
const
res
=
await
uploadAvatar
({
avatarFile
:
data
})
const
{
httpRequest
}
=
useUpload
()
const
avatar
=
((
await
httpRequest
({
file
:
data
,
filename
:
'avatar.png'
,
}
as
UploadRequestOptions
))
as
unknown
as
{
data
:
string
}).
data
await
updateUserProfile
({
avatar
})
// 关闭弹窗,并更新 userStore
cropperRef
.
value
.
close
()
userStore
.
setUserAvatarAction
(
res
.
data
)
await
userStore
.
setUserAvatarAction
(
avatar
)
}
</
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