初版定稿
This commit is contained in:
@@ -149,7 +149,8 @@ import {
|
||||
QuestionCircleOutlined,
|
||||
ShopOutlined
|
||||
} from '@ant-design/icons-vue'
|
||||
import { message, Modal, UploadProps } from 'ant-design-vue'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import type { UploadProps } from 'ant-design-vue'
|
||||
import { authApi } from '@/api/auth'
|
||||
import { userApi, type UserVO } from '@/api/user'
|
||||
import { fileApi } from '@/api/file'
|
||||
@@ -221,7 +222,7 @@ const fetchUserInfo = async () => {
|
||||
console.log('开始获取用户信息...')
|
||||
const res = await userApi.getUserInfo()
|
||||
console.log('获取到的用户信息:', res)
|
||||
userInfo.value = res
|
||||
userInfo.value = res as unknown as UserVO
|
||||
console.log('设置后的 userInfo:', userInfo.value)
|
||||
} catch (error) {
|
||||
console.error('获取用户信息失败:', error)
|
||||
@@ -256,7 +257,7 @@ const handleAvatarUpload = async (options: any) => {
|
||||
uploading.value = true
|
||||
try {
|
||||
const res = await fileApi.uploadAvatar(file)
|
||||
editForm.value.avatar = res
|
||||
editForm.value.avatar = res as unknown as string
|
||||
message.success('头像上传成功')
|
||||
} catch (error) {
|
||||
console.error('头像上传失败:', error)
|
||||
@@ -270,8 +271,16 @@ const handleDeleteAvatar = () => {
|
||||
Modal.confirm({
|
||||
title: '确认删除',
|
||||
content: '确定要删除头像吗?',
|
||||
onOk: () => {
|
||||
onOk: async () => {
|
||||
editForm.value.avatar = ''
|
||||
userInfo.value.avatar = ''
|
||||
try {
|
||||
await userApi.updateUserInfo({ avatar: '' })
|
||||
message.success('头像删除成功')
|
||||
} catch (error) {
|
||||
console.error('删除头像失败:', error)
|
||||
message.error('删除头像失败')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user