Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vipSupplier
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王淑敏
vipSupplier
Commits
7a86e4ed
Commit
7a86e4ed
authored
Sep 09, 2020
by
chuzhixin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
:bug:修复代码合并出现的bug
parent
acc7c0f9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
+11
-9
src/utils/request.js
+11
-9
No files found.
src/utils/request.js
View file @
7a86e4ed
...
...
@@ -5,7 +5,7 @@ import {
contentType
,
debounce
,
invalidCode
,
no
Role
Code
,
no
Permission
Code
,
requestTimeout
,
successCode
,
tokenName
,
...
...
@@ -19,7 +19,7 @@ import { isArray } from "@/utils/validate";
let
loadingInstance
;
/**
* @
author
chuzhixin 1204505056@qq.com
* @
copyright
chuzhixin 1204505056@qq.com
* @description 判断当前url是否需要加loading
* @param {*} config
* @returns
...
...
@@ -35,7 +35,7 @@ const needLoading = (config) => {
};
/**
* @
author
chuzhixin 1204505056@qq.com
* @
copyright
chuzhixin 1204505056@qq.com
* @description 处理code异常
* @param {*} code
* @param {*} msg
...
...
@@ -44,15 +44,12 @@ const handleCode = (code, msg) => {
switch
(
code
)
{
case
invalidCode
:
Vue
.
prototype
.
$baseMessage
(
msg
||
`后端接口
${
code
}
异常`
,
"error"
);
store
.
dispatch
(
"user/resetAccessToken"
).
catch
(()
=>
{});
if
(
loginInterception
)
{
location
.
reload
();
}
break
;
case
no
Role
Code
:
case
no
Permission
Code
:
router
.
push
({
path
:
"/401"
}).
catch
(()
=>
{});
break
;
default
:
...
...
@@ -67,7 +64,6 @@ const instance = axios.create({
headers
:
{
"Content-Type"
:
contentType
,
},
//withCredentials: true,
});
instance
.
interceptors
.
request
.
use
(
...
...
@@ -75,6 +71,12 @@ instance.interceptors.request.use(
if
(
store
.
getters
[
"user/accessToken"
])
{
config
.
headers
[
tokenName
]
=
store
.
getters
[
"user/accessToken"
];
}
//这里会过滤所有为空、0、false的key,如果不需要请自行注释
if
(
config
.
data
)
config
.
data
=
Vue
.
prototype
.
$baseLodash
.
pickBy
(
config
.
data
,
Vue
.
prototype
.
$baseLodash
.
identity
);
if
(
contentType
===
"application/x-www-form-urlencoded;charset=UTF-8"
&&
...
...
@@ -97,7 +99,7 @@ instance.interceptors.response.use(
(
response
)
=>
{
if
(
loadingInstance
)
loadingInstance
.
close
();
const
{
data
,
config
}
=
response
;
const
{
status
,
data
,
config
}
=
response
;
const
{
code
,
msg
}
=
data
;
// 操作正常Code数组
const
codeVerificationArray
=
isArray
(
successCode
)
...
...
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