bill 1 year ago
parent
commit
9940369250
1 changed files with 7 additions and 5 deletions
  1. 7 5
      src/request/index.ts

+ 7 - 5
src/request/index.ts

@@ -44,11 +44,13 @@ axios.interceptors.request.use(async (config) => {
     return config;
   }
 
-  const { token, userId } = getAuth();
-  console.log(config.url, token, userId)
-  if (!token && !~notLoginUrls.indexOf(config.url)) {
-    router.replace({ name: RouteName.login });
-    throw "用户未登录";
+  const hasIgnore = config.params ? "ingoreRes" in config.params : false;
+  if (!hasIgnore) {
+    const { token, userId } = getAuth();
+    if (!token && !~notLoginUrls.indexOf(config.url)) {
+      router.replace({ name: RouteName.login });
+      throw "用户未登录";
+    }
   }
 
   config.headers.token = token;