From c99cf5e53f057cdc332ab6c0635adf9c2d27de29 Mon Sep 17 00:00:00 2001
From: 无木 <netfan@foxmail.com>
Date: 星期二, 29 六月 2021 17:31:30 +0800
Subject: [PATCH] feat(axios): add `withToken` option

---
 src/utils/http/axios/index.ts |    4 +++-
 types/axios.d.ts              |    2 ++
 CHANGELOG.zh_CN.md            |    6 ++++++
 3 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/CHANGELOG.zh_CN.md b/CHANGELOG.zh_CN.md
index ebaa298..386c1a1 100644
--- a/CHANGELOG.zh_CN.md
+++ b/CHANGELOG.zh_CN.md
@@ -1,3 +1,7 @@
+### 鉁� Features
+
+- **Axios** 鏂板`withToken`閰嶇疆锛岀敤浜庢帶鍒惰姹傛槸鍚︽惡甯� token
+
 ### 馃悰 Bug Fixes
 
 - **Modal** 淇鐐瑰嚮閬僵涓嶈兘鍏抽棴
@@ -5,6 +9,8 @@
 - **Modal** 淇 `setModalProps` 涓嶆敮鎸佽缃� `defaultFullscreen`
 - **Sider** 淇渚ц竟鑿滃崟搴曢儴鐨勬姌鍙犳寜閽偣鍑绘棤鏁�
 - **SvgIcon** 淇鍥炬爣鏍峰紡闂
+- **Table** 淇涓� table 鎻愪緵 rowSelection.onChange 鏃讹紝鏃犳硶鎵嬪姩鍙樻洿 table 鐨勯�変腑椤圭殑闂
+- **Icon** 淇 SvgIcon 缂哄皯閮ㄥ垎鏍峰紡鐨勯棶棰�
 
 ## 2.5.2(2021-06-27)
 
diff --git a/src/utils/http/axios/index.ts b/src/utils/http/axios/index.ts
index ac52c33..dd2587e 100644
--- a/src/utils/http/axios/index.ts
+++ b/src/utils/http/axios/index.ts
@@ -122,7 +122,7 @@
   requestInterceptors: (config, options) => {
     // 璇锋眰涔嬪墠澶勭悊config
     const token = getToken();
-    if (token) {
+    if (token && options?.requestOptions?.withToken !== false) {
       // jwt token
       config.headers.Authorization = options.authenticationScheme
         ? `${options.authenticationScheme} ${token}`
@@ -214,6 +214,8 @@
           joinTime: true,
           // 蹇界暐閲嶅璇锋眰
           ignoreCancelToken: true,
+          // 鏄惁鎼哄甫token
+          withToken: true,
         },
       },
       opt || {}
diff --git a/types/axios.d.ts b/types/axios.d.ts
index aebbc9f..e325b65 100644
--- a/types/axios.d.ts
+++ b/types/axios.d.ts
@@ -19,6 +19,8 @@
   // Whether to add a timestamp
   joinTime?: boolean;
   ignoreCancelToken?: boolean;
+  // Whether to send token in header
+  withToken?: boolean;
 }
 
 export interface Result<T = any> {

--
Gitblit v1.8.0