Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
najiu-admin-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
najiu-frontend
najiu-admin-template
Commits
c99cf5e5
Commit
c99cf5e5
authored
Jun 29, 2021
by
无木
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(axios): add `withToken` option
添加withToken配置,用于控制request是否提交token
parent
df0f0008
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
1 deletion
+11
-1
CHANGELOG.zh_CN.md
CHANGELOG.zh_CN.md
+6
-0
index.ts
src/utils/http/axios/index.ts
+3
-1
axios.d.ts
types/axios.d.ts
+2
-0
No files found.
CHANGELOG.zh_CN.md
View file @
c99cf5e5
### ✨ Features
-
**Axios**
新增
`withToken`
配置,用于控制请求是否携带 token
### 🐛 Bug Fixes
### 🐛 Bug Fixes
-
**Modal**
修复点击遮罩不能关闭
-
**Modal**
修复点击遮罩不能关闭
...
@@ -5,6 +9,8 @@
...
@@ -5,6 +9,8 @@
-
**Modal**
修复
`setModalProps`
不支持设置
`defaultFullscreen`
-
**Modal**
修复
`setModalProps`
不支持设置
`defaultFullscreen`
-
**Sider**
修复侧边菜单底部的折叠按钮点击无效
-
**Sider**
修复侧边菜单底部的折叠按钮点击无效
-
**SvgIcon**
修复图标样式问题
-
**SvgIcon**
修复图标样式问题
-
**Table**
修复为 table 提供 rowSelection.onChange 时,无法手动变更 table 的选中项的问题
-
**Icon**
修复 SvgIcon 缺少部分样式的问题
## 2.5.2(2021-06-27)
## 2.5.2(2021-06-27)
...
...
src/utils/http/axios/index.ts
View file @
c99cf5e5
...
@@ -122,7 +122,7 @@ const transform: AxiosTransform = {
...
@@ -122,7 +122,7 @@ const transform: AxiosTransform = {
requestInterceptors
:
(
config
,
options
)
=>
{
requestInterceptors
:
(
config
,
options
)
=>
{
// 请求之前处理config
// 请求之前处理config
const
token
=
getToken
();
const
token
=
getToken
();
if
(
token
)
{
if
(
token
&&
options
?.
requestOptions
?.
withToken
!==
false
)
{
// jwt token
// jwt token
config
.
headers
.
Authorization
=
options
.
authenticationScheme
config
.
headers
.
Authorization
=
options
.
authenticationScheme
?
`
${
options
.
authenticationScheme
}
${
token
}
`
?
`
${
options
.
authenticationScheme
}
${
token
}
`
...
@@ -214,6 +214,8 @@ function createAxios(opt?: Partial<CreateAxiosOptions>) {
...
@@ -214,6 +214,8 @@ function createAxios(opt?: Partial<CreateAxiosOptions>) {
joinTime
:
true
,
joinTime
:
true
,
// 忽略重复请求
// 忽略重复请求
ignoreCancelToken
:
true
,
ignoreCancelToken
:
true
,
// 是否携带token
withToken
:
true
,
},
},
},
},
opt
||
{}
opt
||
{}
...
...
types/axios.d.ts
View file @
c99cf5e5
...
@@ -19,6 +19,8 @@ export interface RequestOptions {
...
@@ -19,6 +19,8 @@ export interface RequestOptions {
// Whether to add a timestamp
// Whether to add a timestamp
joinTime
?:
boolean
;
joinTime
?:
boolean
;
ignoreCancelToken
?:
boolean
;
ignoreCancelToken
?:
boolean
;
// Whether to send token in header
withToken
?:
boolean
;
}
}
export
interface
Result
<
T
=
any
>
{
export
interface
Result
<
T
=
any
>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment