feat: avatar upload

pull/4/MERGE
xingyu 2023-03-30 23:02:45 +08:00
parent 7f7281355c
commit 75edf99f6c
3 changed files with 26 additions and 6 deletions

View File

@ -1,5 +1,4 @@
import { defHttp } from '@/utils/http/axios'
import { UploadFileParams } from '@/types/axios'
export interface ProfileDept {
id: number
@ -87,10 +86,7 @@ export function updateUserPwdApi(oldPassword: string, newPassword: string) {
// 用户头像上传
export function uploadAvatarApi(data) {
const params: UploadFileParams = {
file: data
}
return defHttp.uploadFile({ url: Api.uploadAvatarApi }, params)
return defHttp.put({ url: Api.uploadAvatarApi, data: { file: data } })
}
// 社交绑定,使用 code 授权码

View File

@ -9,6 +9,7 @@
<div class="mb-2">头像</div>
<CropperAvatar
:value="avatar"
:uploadApi="uploadAvatarApi as any"
btnText="更换头像"
:btnProps="{ preIcon: 'ant-design:cloud-upload-outlined' }"
@change="updateAvatar"
@ -56,7 +57,6 @@ async function updateAvatar({ src, data }) {
const userinfo = userStore.getUserInfo
userinfo.user.avatar = src
userStore.setUserInfo(userinfo)
console.log('data', data)
}
async function handleSubmit() {

View File

@ -12,6 +12,30 @@ export interface ListItem {
color?: string
}
// tab的list
export const settingList = [
{
key: '1',
name: '基本设置',
component: 'BaseSetting'
},
{
key: '2',
name: '安全设置',
component: 'SecureSetting'
},
{
key: '3',
name: '账号绑定',
component: 'AccountBind'
},
{
key: '4',
name: '新消息通知',
component: 'MsgNotify'
}
]
// 基础设置 form
export const baseSetschemas: FormSchema[] = [
{