Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
bdc
/
bdcjg-web
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
e3eaf360
authored
2023-03-14 16:14:04 +0800
by
任超
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
style:表头样式修改
2 parents
34318b99
944a09ed
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
15 deletions
src/permission.js
src/utils/request.js
src/views/loginjg/index.vue
src/views/loginsb/index.vue
src/permission.js
View file @
e3eaf36
...
...
@@ -18,13 +18,13 @@ router.beforeEach(async (to, from, next) => {
let
hasUser
=
store
.
state
.
user
.
hasUser
;
let
hasAddRoute
=
store
.
state
.
permission
.
addRoutes
;
if
(
to
.
path
==
"/sb"
||
to
.
path
==
"/jg"
)
{
session
Storage
.
removeItem
(
"token"
);
local
Storage
.
removeItem
(
"token"
);
sessionStorage
.
setItem
(
"psth"
,
to
.
path
)
next
();
}
else
{
let
code
=
sessionStorage
.
getItem
(
"psth"
)
==
"/sb"
?
"BDCSBPT"
:
"BDCJGPT"
//判断token是否存在
const
hasToken
=
session
Storage
.
getItem
(
"token"
);
const
hasToken
=
local
Storage
.
getItem
(
"token"
);
if
(
hasToken
)
{
//请求用户信息
if
(
!
hasUser
)
{
...
...
src/utils/request.js
View file @
e3eaf36
/*
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-03-1
3 14:11:50
* @LastEditTime: 2023-03-1
4 14:39:24
*/
/**
* 此文件主要创建 axios 实例,然后添加请求拦截器和响应拦截器
...
...
@@ -25,7 +25,7 @@ const service = axios.create({
service
.
interceptors
.
request
.
use
(
(
config
)
=>
{
//调用登录接口时无token,也不需要传token,其他接口都传入token
config
.
headers
.
Authorization
=
session
Storage
.
getItem
(
"token"
)
||
""
;
config
.
headers
.
Authorization
=
local
Storage
.
getItem
(
"token"
)
||
""
;
config
.
headers
.
Accept
=
"application/json"
;
return
config
;
},
...
...
@@ -35,6 +35,7 @@ service.interceptors.request.use(
}
);
window
.
tokenValid
=
true
// response interceptor
service
.
interceptors
.
response
.
use
(
(
response
)
=>
{
...
...
@@ -64,15 +65,20 @@ service.interceptors.response.use(
//对错误信息的处理函数
function
handleErrorData
(
status
)
{
switch
(
status
)
{
// case 401:
// Message.error("由于长时间未操作,请重新登录!");
// router.replace({
// path: "/login/jg",
// query: {
// redirect: router.history.current.fullPath,
// },
// });
// break;
case
401
:
// 多个请求不重复提示错误信息
if
(
window
.
tokenValid
)
{
window
.
tokenValid
=
false
;
Message
.
error
(
"由于长时间未操作,请重新登录!"
);
localStorage
.
removeItem
(
"token"
);
router
.
replace
({
path
:
"/jg"
,
query
:
{
redirect
:
router
.
history
.
current
.
fullPath
,
},
});
}
break
;
case
403
:
Message
.
error
(
"拒绝访问"
);
break
;
...
...
src/views/loginjg/index.vue
View file @
e3eaf36
...
...
@@ -96,7 +96,7 @@
.
then
((
res
)
=>
{
if
(
res
.
status
===
1
)
{
//存储token
session
Storage
.
setItem
(
"token"
,
`Bearer
${
res
.
content
}
`
);
local
Storage
.
setItem
(
"token"
,
`Bearer
${
res
.
content
}
`
);
//登录成功后需判断有无重定向,没有重定向则跳转首页
this
.
$router
.
replace
(
this
.
$route
.
query
.
redirect
||
"/"
);
}
else
{
...
...
src/views/loginsb/index.vue
View file @
e3eaf36
...
...
@@ -103,7 +103,7 @@
if
(
res
.
status
===
1
)
{
this
.
$store
.
dispatch
(
'business/setInitRules'
,
"layout1"
)
//存储token
session
Storage
.
setItem
(
"token"
,
`Bearer
${
res
.
content
}
`
);
local
Storage
.
setItem
(
"token"
,
`Bearer
${
res
.
content
}
`
);
//登录成功后需判断有无重定向,没有重定向则跳转首页
this
.
$router
.
replace
(
this
.
$route
.
query
.
redirect
||
"/"
);
}
else
{
...
...
Please
register
or
sign in
to post a comment