Browse Source

chore(utils): 暂时注释tolen获取逻辑

wangshun 4 days ago
parent
commit
ac705a209b
1 changed files with 13 additions and 11 deletions
  1. 13 11
      src/utils/index.ts

+ 13 - 11
src/utils/index.ts

@@ -1,11 +1,11 @@
 import dayjs from 'dayjs';
 import { kebabCase } from 'lodash-es';
 
-import { useUserInfoStore } from '@/stores/user-info';
+// import { useUserInfoStore } from '@/stores/user-info';
 import { t } from '@/i18n';
 import { fileContentTypeRegExp, TimeScaleType } from '@/constants';
 
-import { removeToken } from './auth';
+// import { removeToken } from './auth';
 import { fetchWithTimeout } from './fetch';
 
 import type { SorterResult } from 'ant-design-vue/es/table/interface';
@@ -19,12 +19,14 @@ export const request = async <T>(url: string, init: RequestInit = {}, timeout?:
   if (typeof init?.body === 'string') {
     headers['Content-Type'] = 'application/json;charset=UTF-8';
   }
-  const { token, resetToken } = useUserInfoStore();
-  if (token) {
-    Object.assign(headers, {
-      Authorization: 'Bearer ' + token,
-    });
-  }
+  // const { token, resetToken } = useUserInfoStore();
+  // if (token) {
+  //   Object.assign(headers, {
+  //     Authorization: 'Bearer ' + token,
+  //   });
+  // }
+
+  headers['Authorization'] = 'Bearer ' + import.meta.env.VITE_TEMP_TOKEN;
 
   Object.assign(headers, init?.headers);
 
@@ -38,9 +40,9 @@ export const request = async <T>(url: string, init: RequestInit = {}, timeout?:
   );
 
   if (res.status === 401) {
-    removeToken();
-    resetToken();
-    location.replace('/login');
+    // removeToken();
+    // resetToken();
+    // location.replace('/login');
     throw new Error(t('common.reLogin'));
   }