Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
bdc
/
bdcsjsb-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
57334bfb
authored
2023-06-26 11:10:47 +0800
by
renchao@pashanhoo.com
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
style:权限
1 parent
bcb8e998
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
32 deletions
src/permission.js
src/permission.js
View file @
57334bf
...
...
@@ -13,7 +13,7 @@ import "nprogress/nprogress.css"; // progress bar style
import
getPageTitle
from
"@/utils/get-page-title"
;
import
getTheme
from
"@/utils/theme"
;
import
Cookies
from
"js-cookie"
;
import
{
getToken
,
getUrlParam
,
setToken
}
from
"@/utils/util"
;
import
{
getToken
,
getUrlParam
,
setToken
}
from
"@/utils/util"
;
NProgress
.
configure
({
showSpinner
:
false
});
...
...
@@ -27,7 +27,7 @@ router.beforeEach(async (to, from, next) => {
// cas操作
const
token
=
getToken
()
let
locationUrl
=
window
.
location
.
origin
+
window
.
location
.
pathname
;
function
casValidate
(
ticket
){
function
casValidate
(
ticket
)
{
axios
.
get
(
window
.
_config
.
services
.
management
+
"/management/cas/validate"
,
{
params
:
{
ticket
:
ticket
,
...
...
@@ -35,10 +35,10 @@ router.beforeEach(async (to, from, next) => {
},
}).
then
(
async
(
res
)
=>
{
if
(
res
.
data
.
status
===
1
)
{
setToken
(
res
.
data
.
content
.
accessToken
)
window
.
location
.
href
=
localStorage
.
getItem
(
'sjsb-location'
)
+
'#'
+
localStorage
.
getItem
(
'hash'
)
setToken
(
res
.
data
.
content
.
accessToken
)
window
.
location
.
href
=
localStorage
.
getItem
(
'sjsb-location'
)
+
'#'
+
localStorage
.
getItem
(
'hash'
)
}
else
{
alert
(
res
.
data
.
message
)
alert
(
res
.
data
.
message
)
}
}).
catch
((
e
)
=>
{
console
.
log
(
e
);
...
...
@@ -65,12 +65,7 @@ router.beforeEach(async (to, from, next) => {
...
accessRoutes
,
{
path
:
"*"
,
redirect
:
"/404"
,
hidden
:
true
}
]);
const
routeTo
=
Cookies
.
get
(
"routerTo"
);
if
(
routeTo
&&
routeTo
!==
"/"
)
{
next
({
...
to
,
replace
:
true
});
}
else
{
next
(
path
)
}
next
(
path
)
}
}
if
(
window
.
_config
.
casEnable
===
true
)
{
...
...
@@ -92,35 +87,35 @@ router.beforeEach(async (to, from, next) => {
if
(
ticket
)
{
casValidate
(
ticket
)
}
else
{
if
(
to
.
path
===
'/login'
)
{
if
(
getUrlParam
(
'_flag'
)
===
'1'
)
{
next
();
return
}
else
{
//todo: loginUrl 需要业务系统根据登录页面路由地址获取,这里只是简写
localStorage
.
setItem
(
'sjsb-location'
,
locationUrl
)
localStorage
.
setItem
(
'hash'
,
to
.
fullPath
)
window
.
location
.
href
=
window
.
_config
.
services
.
management
+
`/management/cas/status?loginUrl=
${
window
.
_config
.
baseUrl
}
/sjsb/&hash=/login&`
return
}
if
(
to
.
path
===
'/login'
)
{
if
(
getUrlParam
(
'_flag'
)
===
'1'
)
{
next
();
return
}
else
{
//todo: loginUrl 需要业务系统根据登录页面路由地址获取,这里只是简写
localStorage
.
setItem
(
'sjsb-location'
,
locationUrl
)
localStorage
.
setItem
(
'hash'
,
to
.
fullPath
)
window
.
location
.
href
=
window
.
_config
.
services
.
management
+
`/management/cas/status?loginUrl=
${
window
.
_config
.
baseUrl
}
/sjsb/&hash=/login&`
return
}
localStorage
.
setItem
(
'sjsb-location'
,
locationUrl
)
localStorage
.
setItem
(
'hash'
,
to
.
fullPath
)
//todo: loginUrl 需要业务系统根据登录页面路由地址获取,这里只是简写
window
.
location
.
href
=
window
.
_config
.
services
.
management
+
`/management/cas/status?loginUrl=
${
window
.
_config
.
baseUrl
}
/sjsb/&hash=/login`
}
localStorage
.
setItem
(
'sjsb-location'
,
locationUrl
)
localStorage
.
setItem
(
'hash'
,
to
.
fullPath
)
//todo: loginUrl 需要业务系统根据登录页面路由地址获取,这里只是简写
window
.
location
.
href
=
window
.
_config
.
services
.
management
+
`/management/cas/status?loginUrl=
${
window
.
_config
.
baseUrl
}
/sjsb/&hash=/login`
}
}
else
{
}
else
{
permission
()
if
(
to
.
path
===
'/login'
)
{
const
redirectUrl
=
getUrlParam
(
'redirectUrl'
);
if
(
redirectUrl
&&
redirectUrl
!==
''
)
{
window
.
location
.
href
=
redirectUrl
return
window
.
location
.
href
=
redirectUrl
return
}
else
{
next
(
'/'
);
return
next
(
'/'
);
return
}
}
permission
()
}
}
NProgress
.
done
()
...
...
Please
register
or
sign in
to post a comment