Commit c99cf5e53f057cdc332ab6c0635adf9c2d27de29
1 parent
df0f0008
feat(axios): add `withToken` option
添加withToken配置,用于控制request是否提交token
Showing
3 changed files
with
11 additions
and
1 deletions
CHANGELOG.zh_CN.md
1 | +### ✨ Features | |
2 | + | |
3 | +- **Axios** 新增`withToken`配置,用于控制请求是否携带 token | |
4 | + | |
1 | 5 | ### 🐛 Bug Fixes |
2 | 6 | |
3 | 7 | - **Modal** 修复点击遮罩不能关闭 |
... | ... | @@ -5,6 +9,8 @@ |
5 | 9 | - **Modal** 修复 `setModalProps` 不支持设置 `defaultFullscreen` |
6 | 10 | - **Sider** 修复侧边菜单底部的折叠按钮点击无效 |
7 | 11 | - **SvgIcon** 修复图标样式问题 |
12 | +- **Table** 修复为 table 提供 rowSelection.onChange 时,无法手动变更 table 的选中项的问题 | |
13 | +- **Icon** 修复 SvgIcon 缺少部分样式的问题 | |
8 | 14 | |
9 | 15 | ## 2.5.2(2021-06-27) |
10 | 16 | ... | ... |
src/utils/http/axios/index.ts
... | ... | @@ -122,7 +122,7 @@ const transform: AxiosTransform = { |
122 | 122 | requestInterceptors: (config, options) => { |
123 | 123 | // 请求之前处理config |
124 | 124 | const token = getToken(); |
125 | - if (token) { | |
125 | + if (token && options?.requestOptions?.withToken !== false) { | |
126 | 126 | // jwt token |
127 | 127 | config.headers.Authorization = options.authenticationScheme |
128 | 128 | ? `${options.authenticationScheme} ${token}` |
... | ... | @@ -214,6 +214,8 @@ function createAxios(opt?: Partial<CreateAxiosOptions>) { |
214 | 214 | joinTime: true, |
215 | 215 | // 忽略重复请求 |
216 | 216 | ignoreCancelToken: true, |
217 | + // 是否携带token | |
218 | + withToken: true, | |
217 | 219 | }, |
218 | 220 | }, |
219 | 221 | opt || {} | ... | ... |
types/axios.d.ts