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
d5f9919b
Commit
d5f9919b
authored
Jun 26, 2021
by
JinMao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: fix defHttp baseUrl work
parent
aed622bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletion
+5
-1
index.ts
src/utils/http/axios/index.ts
+5
-1
No files found.
src/utils/http/axios/index.ts
View file @
d5f9919b
...
@@ -80,6 +80,7 @@ const transform: AxiosTransform = {
...
@@ -80,6 +80,7 @@ const transform: AxiosTransform = {
// 请求之前处理config
// 请求之前处理config
beforeRequestHook
:
(
config
,
options
)
=>
{
beforeRequestHook
:
(
config
,
options
)
=>
{
const
{
baseURL
}
=
config
;
const
{
apiUrl
,
joinPrefix
,
joinParamsToUrl
,
formatDate
,
joinTime
=
true
}
=
options
;
const
{
apiUrl
,
joinPrefix
,
joinParamsToUrl
,
formatDate
,
joinTime
=
true
}
=
options
;
if
(
joinPrefix
)
{
if
(
joinPrefix
)
{
...
@@ -89,6 +90,9 @@ const transform: AxiosTransform = {
...
@@ -89,6 +90,9 @@ const transform: AxiosTransform = {
if
(
apiUrl
&&
isString
(
apiUrl
))
{
if
(
apiUrl
&&
isString
(
apiUrl
))
{
config
.
url
=
`
${
apiUrl
}${
config
.
url
}
`
;
config
.
url
=
`
${
apiUrl
}${
config
.
url
}
`
;
}
}
if
(
baseURL
&&
isString
(
baseURL
))
{
config
.
url
=
`
${
baseURL
}${
config
.
url
}
`
;
}
const
params
=
config
.
params
||
{};
const
params
=
config
.
params
||
{};
if
(
config
.
method
?.
toUpperCase
()
===
RequestEnum
.
GET
)
{
if
(
config
.
method
?.
toUpperCase
()
===
RequestEnum
.
GET
)
{
if
(
!
isString
(
params
))
{
if
(
!
isString
(
params
))
{
...
@@ -186,7 +190,7 @@ function createAxios(opt?: Partial<CreateAxiosOptions>) {
...
@@ -186,7 +190,7 @@ function createAxios(opt?: Partial<CreateAxiosOptions>) {
authenticationScheme
:
''
,
authenticationScheme
:
''
,
timeout
:
10
*
1000
,
timeout
:
10
*
1000
,
// 基础接口地址
// 基础接口地址
//
baseURL: globSetting.apiUrl,
baseURL
:
globSetting
.
apiUrl
,
// 接口可能会有通用的地址部分,可以统一抽取出来
// 接口可能会有通用的地址部分,可以统一抽取出来
urlPrefix
:
urlPrefix
,
urlPrefix
:
urlPrefix
,
headers
:
{
'
Content-Type
'
:
ContentTypeEnum
.
JSON
},
headers
:
{
'
Content-Type
'
:
ContentTypeEnum
.
JSON
},
...
...
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