bill 1 년 전
부모
커밋
9940369250
1개의 변경된 파일7개의 추가작업 그리고 5개의 파일을 삭제
  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;