Browse Source

简化userInfo接口

初志鑫 4 years ago
parent
commit
5a25f7d169
2 changed files with 3 additions and 7 deletions
  1. 1 4
      src/api/user.js
  2. 2 3
      src/store/modules/user.js

+ 1 - 4
src/api/user.js

@@ -13,13 +13,10 @@ export async function login(data) {
   });
 }
 
-export function getUserInfo(accessToken) {
+export function getUserInfo() {
   return request({
     url: "/userInfo",
     method: "post",
-    data: {
-      accessToken,
-    },
   });
 }
 

+ 2 - 3
src/store/modules/user.js

@@ -68,8 +68,8 @@ const actions = {
       );
     }
   },
-  async getUserInfo({ commit, state }) {
-    const { data } = await getUserInfo(state.accessToken);
+  async getUserInfo({ commit }) {
+    const { data } = await getUserInfo();
     if (!data) {
       Vue.prototype.$baseMessage("验证失败,请重新登录...", "error");
       return false;
@@ -87,7 +87,6 @@ const actions = {
   },
   async logout({ dispatch }) {
     await logout(state.accessToken);
-    await dispatch("tagsBar/delAllRoutes", null, { root: true });
     await dispatch("resetAccessToken");
     await resetRouter();
   },