bill 1 年之前
父節點
當前提交
e58f9d01e3
共有 1 個文件被更改,包括 4 次插入4 次删除
  1. 4 4
      src/request/index.ts

+ 4 - 4
src/request/index.ts

@@ -44,18 +44,18 @@ axios.interceptors.request.use(async (config) => {
     return config;
   }
 
+  const { token, userId } = getAuth();
+  config.headers.token = token;
+  config.headers.userid = userId;
+
   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;
-  config.headers.userid = userId;
-
   if (~GetUrls.indexOf(config.url)) {
     config.method = "GET";
   } else if (~PostUrls.indexOf(config.url)) {