瀏覽代碼

feat(http): 处理token key全局

gemercheung 3 年之前
父節點
當前提交
58958fa109
共有 4 個文件被更改,包括 7 次插入7 次删除
  1. 2 2
      mock/_util.ts
  2. 1 1
      src/api/order/list.ts
  3. 1 1
      src/api/staff/list.ts
  4. 3 3
      src/utils/http/axios/index.ts

+ 2 - 2
mock/_util.ts

@@ -47,7 +47,7 @@ export function pagination<T = any>(pageNo: number, pageSize: number, array: T[]
 export interface requestParams {
   method: string;
   body: any;
-  headers?: { authorization?: string };
+  headers?: { token?: string };
   query: any;
 }
 
@@ -56,5 +56,5 @@ export interface requestParams {
  *
  */
 export function getRequestToken({ headers }: requestParams): string | undefined {
-  return headers?.authorization;
+  return headers?.token;
 }

+ 1 - 1
src/api/order/list.ts

@@ -2,7 +2,7 @@ import { defHttp } from '/@/utils/http/axios';
 import { PageParams, RentListGetResultModel } from './model';
 
 enum Api {
-  pageList = '/zfb-api/order/list',
+  pageList = '/basic-api/order/list',
 }
 
 /**

+ 1 - 1
src/api/staff/list.ts

@@ -2,7 +2,7 @@ import { defHttp } from '/@/utils/http/axios';
 import { PageParams, RentListGetResultModel } from './model';
 
 enum Api {
-  pageList = '/basic-api/staff/list',
+  pageList = '/basic-api/sys/user/staffList',
 }
 
 /**

+ 3 - 3
src/utils/http/axios/index.ts

@@ -151,9 +151,9 @@ const transform: AxiosTransform = {
     const token = getToken();
     if (token && (config as Recordable)?.requestOptions?.withToken !== false) {
       // jwt token
-      (config as Recordable).headers.Authorization = options.authenticationScheme
-        ? `${options.authenticationScheme} ${token}`
-        : token;
+      // (config as Recordable).headers.Authorization = options.authenticationScheme
+      //   ? `${options.authenticationScheme} ${token}`
+      //   : token;
       (config as Recordable).headers.token = options.authenticationScheme
         ? `${options.authenticationScheme} ${token}`
         : token;