代码提交

This commit is contained in:
黄少君
2023-11-15 19:59:37 +08:00
parent dcab74274f
commit 35b43ffd97
43 changed files with 1265 additions and 387 deletions

View File

@ -1,6 +1,7 @@
import { useMainStore } from "@/store/store";
import { useInterface } from "@/hooks/useInterface";
import { updateAvatar, updateUserInfo } from "@/api/user";
import { upload } from "@/api/api";
export function useRequest() {
const {loading, hideLoading, toast} = useInterface()
@ -12,12 +13,15 @@ export function useRequest() {
* @returns {Promise<void>}
*/
async function doUpdateAvatar(file) {
let data = new FormData()
data.append('avatarFile', file)
loading({title: '上传中...'})
await updateAvatar(data)
await userStore.getUserInfo()
hideLoading()
try {
await upload({
filePath: file.url,
name: 'avatarFile'
});
await userStore.getUserInfo()
} catch (e) {
console.error(e)
}
}
async function doUpdateUserInfo() {

View File

@ -44,8 +44,7 @@ const modelRef = ref()
* @returns {Promise<void>}
*/
async function afterChooseFile(event) {
const imgObj = await objectURLToBlob(event.file.url)
await doUpdateAvatar(new File([imgObj], '', {type: imgObj.type}))
await doUpdateAvatar(event.file)
}
function sexChange(event) {