Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Fedex
/
imac-vue
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
jinhui.wang
2023-08-18 09:11:34 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0725e50e701527ef20cd7fc66c09b46ab9b42a65
0725e50e
1 parent
e5dbbb83
配置文件更新
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
13 deletions
src/permission.js
src/settings.js
src/utils/request.js
src/permission.js
View file @
0725e50
import
router
from
'./router'
import
store
from
'./store'
import
{
Message
}
from
'element-ui'
import
{
getToken
,
removeToken
}
from
'@/utils/auth'
import
{
getToken
,
setToken
,
removeToken
}
from
'@/utils/auth'
import
settings
from
"@/settings"
const
whiteList
=
[
'/login'
,
'/auth-redirect'
,
'/bind'
,
'/register'
]
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
if
(
getToken
())
{
/* has token*/
...
...
@@ -14,16 +16,19 @@ router.beforeEach((to, from, next) => {
if
(
store
.
getters
.
roles
.
length
===
0
)
{
// 判断当前用户是否已拉取完user_info信息
store
.
dispatch
(
'GetInfo'
).
then
(()
=>
{
//获取用户表头
store
.
dispatch
(
'GetTableHeaders'
).
then
(()
=>
{
// 根据roles权限生成可访问的路由表
store
.
dispatch
(
'GenerateRoutes'
).
then
(
accessRoutes
=>
{
// 根据roles权限生成可访问的路由表
router
.
addRoutes
(
accessRoutes
)
// 动态添加可访问路由表
next
({
...
to
,
replace
:
true
})
// hack方法 确保addRoutes已完成
})
})
}).
catch
(
err
=>
{
Message
.
error
(
err
)
// store.dispatch('LogOut').then(() => {
// // next({ path: '/' })
// window.location.href = settings.loginURL;//wsso系统跳转
// })
})
}
else
{
next
()
...
...
@@ -38,7 +43,12 @@ router.beforeEach((to, from, next) => {
setToken
(
token
)
next
({
path
:
'/'
})
}
else
{
next
(
`/login?redirect=
${
to
.
fullPath
}
`
)
// 否则全部重定向到登录页
if
(
whiteList
.
indexOf
(
to
.
path
)
!==
-
1
)
{
// 在免登录白名单,直接进入
next
()
}
else
{
window
.
location
.
href
=
settings
.
loginURL
;
//wsso系统跳转
}
}
}
})
...
...
src/settings.js
View file @
0725e50
...
...
@@ -49,7 +49,7 @@ module.exports = {
* 后端接口
*/
baseURL
:
`https://imacuat.zmd.apac.fedex.com/iMAC`
,
downLoadURL
:
`https://imacuat.zmd.apac.fedex.com/iMAC`
,
//下载、导出地址
downLoadURL
:
`https://imacuat.zmd.apac.fedex.com/iMAC`
,
//下载、导出地址
/**
* 项目存放地址
...
...
src/utils/request.js
View file @
0725e50
...
...
@@ -9,9 +9,9 @@ axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
// 创建axios实例
const
service
=
axios
.
create
({
// axios中请求配置有baseURL选项,表示请求URL公共部分
baseURL
:
settings
.
baseURL
,
//接口地址
baseURL
:
settings
.
baseURL
,
// 超时
timeout
:
30000
timeout
:
90000
,
})
// request拦截器
...
...
@@ -52,14 +52,14 @@ service.interceptors.request.use(config => {
// 响应拦截器
service
.
interceptors
.
response
.
use
(
res
=>
{
if
(
res
.
headers
[
'token'
])
{
setToken
(
decodeURI
(
res
.
headers
[
'token'
])
)
setToken
(
res
.
headers
[
'token'
]
)
}
// 未设置状态码则默认成功状态
const
code
=
res
.
data
.
code
||
200
;
// 获取错误信息
const
msg
=
errorCode
[
code
]
||
res
.
data
.
msg
||
errorCode
[
'default'
]
if
(
code
===
301
)
{
MessageBox
.
confirm
(
'登录状态已过期,需重新登录
'
,
'系统提示'
,
{
MessageBox
.
confirm
(
'登录状态已过期,需重新登录
!msg:'
+
msg
,
'系统提示'
,
{
closeOnClickModal
:
false
,
showCancelButton
:
false
,
confirmButtonText
:
'重新登录'
,
...
...
@@ -67,9 +67,10 @@ service.interceptors.response.use(res => {
}
).
then
(()
=>
{
store
.
dispatch
(
'LogOut'
).
then
(()
=>
{
location
.
href
=
settings
.
routerBase
+
'/index'
;
// location.href = '/';
window
.
location
.
href
=
settings
.
loginURL
;
//wsso系统跳转
})
})
})
;
}
else
if
(
code
===
403
)
{
//无权限页面
location
.
href
=
'/401'
;
...
...
@@ -80,7 +81,7 @@ service.interceptors.response.use(res => {
type
:
'error'
})
return
Promise
.
reject
(
new
Error
(
msg
))
}
else
if
(
code
!==
200
&&
code
!==
201
&&
code
!==
202
&&
code
!=
203
&&
code
!
=
603
)
{
}
else
if
(
code
!==
200
&&
code
!==
201
&&
code
!==
202
&&
code
!==
603
)
{
Message
({
message
:
msg
,
type
:
'error'
...
...
Please
register
or
login
to post a comment