Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
hrs_app_h5
/
bill
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
2d337ea3
authored
Apr 17, 2020
by
展昭
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
删除 router中的mgr逻辑
parent
782460b8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 additions
and
53 deletions
src/router/index.js
src/router/index.js
View file @
2d337ea3
...
@@ -4,7 +4,7 @@ import moreRouters from './more-router.js'
...
@@ -4,7 +4,7 @@ import moreRouters from './more-router.js'
import
billRouters
from
'./bill-router.js'
import
billRouters
from
'./bill-router.js'
import
{
vuexOidcCreateRouterMiddleware
}
from
'vuex-oidc'
import
{
vuexOidcCreateRouterMiddleware
}
from
'vuex-oidc'
import
store
from
'../store'
import
store
from
'../store'
import
Mgr
from
"../assets/js/SecurityService"
Vue
.
use
(
VueRouter
)
Vue
.
use
(
VueRouter
)
...
@@ -30,58 +30,6 @@ const router = new VueRouter({
...
@@ -30,58 +30,6 @@ const router = new VueRouter({
}
}
})
})
const
mgr
=
new
Mgr
();
function
loginByAuthcode
(
authCode
)
{
let
loginArgs
=
{
extraQueryParams
:
{
authcode
:
authCode
}
};
mgr
.
signIn
(
loginArgs
);
}
function
autoLogin
(
comid
,
authcode
,
next
)
{
localStorage
.
setItem
(
"comid"
,
comid
);
mgr
.
getUser
().
then
(
user
=>
{
if
(
user
==
null
)
{
loginByAuthcode
(
authcode
);
}
else
{
let
companyId
=
localStorage
.
getItem
(
"companyId"
);
if
(
comid
!=
companyId
)
{
//如果已经登录,则先退出
localStorage
.
setItem
(
"authcode"
,
authcode
);
mgr
.
signOut
();
}
else
{
next
();
}
}
})
}
router
.
beforeEach
(
vuexOidcCreateRouterMiddleware
(
store
));
router
.
beforeEach
(
vuexOidcCreateRouterMiddleware
(
store
));
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
let
authcode
=
localStorage
.
getItem
(
"authcode"
)
if
(
authcode
)
{
localStorage
.
removeItem
(
"authcode"
);
loginByAuthcode
(
authcode
)
}
else
{
authcode
=
to
.
query
.
authcode
;
const
comid
=
to
.
query
.
comId
||
to
.
query
.
comid
;
if
(
comid
&&
authcode
)
{
localStorage
.
setItem
(
"autoCallback"
,
to
.
path
);
autoLogin
(
comid
,
authcode
,
next
);
}
else
{
mgr
.
getUser
().
then
(
user
=>
{
if
(
user
==
null
)
{
mgr
.
signIn
();
}
else
{
next
()
}
});
}
}
});
export
default
router
export
default
router
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