Ver código fonte

fix(#6080): 实现头像上传功能

ethanfly 4 dias atrás
pai
commit
d511581586
1 arquivos alterados com 2 adições e 4 exclusões
  1. 2 4
      client/src/views/Profile/index.vue

+ 2 - 4
client/src/views/Profile/index.vue

@@ -168,7 +168,7 @@ async function handleAvatarChange(file: UploadFile) {
   const formData = new FormData();
   formData.append('image', file.raw);
 
-  // 使用 axios 直接上传(需要手动设置 baseURL)
+  // 使用 fetch 直接上传(需要手动设置 baseURL)
   const serverStore = (await import('@/stores/server')).useServerStore();
   const baseUrl = serverStore.currentServer?.url;
   if (!baseUrl) {
@@ -177,12 +177,10 @@ async function handleAvatarChange(file: UploadFile) {
     return;
   }
 
-  const authStoreLocal = (await import('@/stores/auth')).useAuthStore();
-
   fetch(`${baseUrl}/api/upload/avatar`, {
     method: 'POST',
     headers: {
-      Authorization: `Bearer ${authStoreLocal.accessToken}`,
+      Authorization: `Bearer ${authStore.accessToken}`,
     },
     body: formData,
   })