diff --git a/src/api/user.ts b/src/api/user.ts index be660af9..f03edef3 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -138,9 +138,9 @@ class UserAPI { } /** 获取个人中心用户信息 */ - static getProfile(id: number) { + static getProfile() { return request({ - url: `${USER_BASE_URL}/${id}/profile`, + url: `${USER_BASE_URL}/profile`, method: "get", }); } diff --git a/src/views/profile/index.vue b/src/views/profile/index.vue index aa98d27d..6152e89f 100644 --- a/src/views/profile/index.vue +++ b/src/views/profile/index.vue @@ -304,11 +304,8 @@ import UserAPI, { import FileAPI from "@/api/file"; -import { useUserStore } from "@/store/modules/user"; import { Camera } from "@element-plus/icons-vue"; -const userStore = useUserStore(); - const userProfile = ref({}); enum DialogType { @@ -496,7 +493,7 @@ const handleFileChange = async (event: Event) => { // 更新用户头像 userProfile.value.avatar = data.url; // 更新用户信息 - await UserAPI.updateProfile(userProfile.value.id as number, { + await UserAPI.updateProfile({ avatar: data.url, }); } catch (error) { @@ -507,7 +504,7 @@ const handleFileChange = async (event: Event) => { /** 加载用户信息 */ const loadUserProfile = async () => { - const data = await UserAPI.getProfile(userStore.user.userId); + const data = await UserAPI.getProfile(); userProfile.value = data; };