fix:关闭头像上传时,又自动打开
reactor:头像上传时,通过前端 httpRequest ,可支持前端直传
This commit is contained in:
parent
165ce58abb
commit
ef90faf77b
@ -32,10 +32,11 @@ export interface ProfileVO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface UserProfileUpdateReqVO {
|
export interface UserProfileUpdateReqVO {
|
||||||
nickname: string
|
nickname?: string
|
||||||
email: string
|
email?: string
|
||||||
mobile: string
|
mobile?: string
|
||||||
sex: number
|
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 })
|
|
||||||
}
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div @click.stop>
|
||||||
<Dialog
|
<Dialog
|
||||||
v-model="dialogVisible"
|
v-model="dialogVisible"
|
||||||
:canFullscreen="false"
|
:canFullscreen="false"
|
||||||
@ -181,6 +181,7 @@ function openModal() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function closeModal() {
|
function closeModal() {
|
||||||
|
debugger
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,9 +12,11 @@
|
|||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { propTypes } from '@/utils/propTypes'
|
import { propTypes } from '@/utils/propTypes'
|
||||||
import { uploadAvatar } from '@/api/system/user/profile'
|
import { updateUserProfile } from '@/api/system/user/profile'
|
||||||
import { CropperAvatar } from '@/components/Cropper'
|
import { CropperAvatar } from '@/components/Cropper'
|
||||||
import { useUserStore } from '@/store/modules/user'
|
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 组件中,更简洁一点
|
// TODO @芋艿:合并到 ProfileUser 组件中,更简洁一点
|
||||||
defineOptions({ name: 'UserAvatar' })
|
defineOptions({ name: 'UserAvatar' })
|
||||||
@ -27,10 +29,16 @@ const userStore = useUserStore()
|
|||||||
|
|
||||||
const cropperRef = ref()
|
const cropperRef = ref()
|
||||||
const handelUpload = async ({ data }) => {
|
const handelUpload = async ({ data }) => {
|
||||||
// TODO @芋艿:去掉这个接口,使用 url 直接上传
|
const { httpRequest } = useUpload()
|
||||||
const res = await uploadAvatar({ avatarFile: data })
|
const avatar = ((await httpRequest({
|
||||||
|
file: data,
|
||||||
|
filename: 'avatar.png',
|
||||||
|
} as UploadRequestOptions)) as unknown as { data: string }).data
|
||||||
|
await updateUserProfile({ avatar })
|
||||||
|
|
||||||
|
// 关闭弹窗,并更新 userStore
|
||||||
cropperRef.value.close()
|
cropperRef.value.close()
|
||||||
userStore.setUserAvatarAction(res.data)
|
await userStore.setUserAvatarAction(avatar)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user