From c74023901c6c152847bf6d7b83d3e7a7075d681b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98chen=2Ehome=E2=80=99?= <1147347984@qq.com> Date: Sat, 13 Aug 2022 09:30:19 +0800 Subject: [PATCH] =?UTF-8?q?chore(projects):=20=E5=A2=9E=E5=8A=A0vue?= =?UTF-8?q?=EF=BC=8CvueRouter=E7=9A=84hook=E8=87=AA=E5=8A=A8=E5=BC=95?= =?UTF-8?q?=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/service/http/instance.ts | 2 +- src/store/modules/auth.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/service/http/instance.ts b/src/service/http/instance.ts index f0abde0..6eb1fdf 100644 --- a/src/service/http/instance.ts +++ b/src/service/http/instance.ts @@ -50,7 +50,7 @@ export default class createAxiosInstance { switch (code) { case this.backendConfig.successCode: // code === 200 代表没有错误,直接返回约定的数据内容 - return apiData[this.backendConfig.dataKey]; + return apiData; default: // 不是正确的 Code,返回错误提示信息 return Promise.reject(new Error(`Error:${this.backendConfig.dataKey}`)); diff --git a/src/store/modules/auth.ts b/src/store/modules/auth.ts index bd32a4b..26a3cb2 100644 --- a/src/store/modules/auth.ts +++ b/src/store/modules/auth.ts @@ -21,10 +21,10 @@ export const useAuthStore = defineStore('auth-store', { /* 用户登录 */ async login(userName: string, password: string) { this.loginLoading = true; - const data = await fetchLogin({ userName, password }); + const { data } = await fetchLogin({ userName, password }); // 处理登录信息 - this.handleAfterLogin(data as any); + await this.handleAfterLogin(data as any); this.loginLoading = false; },