Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
6
608-pdm-web-5g
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pdm
608-pdm-web-5g
Commits
e74dad1b
Commit
e74dad1b
authored
Jul 19, 2024
by
xioln
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
免登录处理
parent
ed56bb88
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
12 deletions
+48
-12
permission.js
src/permission.js
+7
-2
http.js
src/utils/http.js
+9
-9
index.vue
src/views/home/index.vue
+32
-1
No files found.
src/permission.js
View file @
e74dad1b
...
@@ -8,6 +8,7 @@ const whiteList = ['/login', '/auth-redirect'] // no redirect whitelist
...
@@ -8,6 +8,7 @@ const whiteList = ['/login', '/auth-redirect'] // no redirect whitelist
let
path
=
''
let
path
=
''
router
.
beforeEach
(
async
(
to
,
from
,
next
)
=>
{
router
.
beforeEach
(
async
(
to
,
from
,
next
)
=>
{
const
hasToken
=
getToken
()
const
hasToken
=
getToken
()
const
isLogin
=
sessionStorage
.
getItem
(
'isLogin'
)
if
(
hasToken
)
{
if
(
hasToken
)
{
if
(
!
to
.
matched
.
length
)
{
if
(
!
to
.
matched
.
length
)
{
from
.
name
?
next
({
name
:
from
.
name
})
:
next
(
'/home'
)
from
.
name
?
next
({
name
:
from
.
name
})
:
next
(
'/home'
)
...
@@ -38,7 +39,12 @@ router.beforeEach(async (to, from, next) => {
...
@@ -38,7 +39,12 @@ router.beforeEach(async (to, from, next) => {
next
()
next
()
}
}
}
else
{
}
else
{
if
(
util
.
getCookie
(
'portal'
))
{
if
(
!
isLogin
)
{
sessionStorage
.
setItem
(
'isLogin'
,
'1'
)
next
()
}
else
if
(
isLogin
===
'2'
)
{
next
()
}
else
if
(
util
.
getCookie
(
'portal'
))
{
singleLogin
(
false
)
singleLogin
(
false
)
}
else
if
(
whiteList
.
indexOf
(
to
.
path
)
!==
-
1
)
{
}
else
if
(
whiteList
.
indexOf
(
to
.
path
)
!==
-
1
)
{
next
()
next
()
...
@@ -49,7 +55,6 @@ router.beforeEach(async (to, from, next) => {
...
@@ -49,7 +55,6 @@ router.beforeEach(async (to, from, next) => {
})
})
function
singleLogin
(
state
)
{
function
singleLogin
(
state
)
{
const
params
=
{}
const
params
=
{}
console
.
log
(
'util.getCookie'
,
util
.
getCookie
(
'url'
))
if
(
util
.
getCookie
(
'url'
))
{
if
(
util
.
getCookie
(
'url'
))
{
const
search
=
util
.
getCookie
(
'url'
)
const
search
=
util
.
getCookie
(
'url'
)
let
query
=
search
.
substring
(
search
.
indexOf
(
'?'
)
+
1
,
search
?.
length
)
let
query
=
search
.
substring
(
search
.
indexOf
(
'?'
)
+
1
,
search
?.
length
)
...
...
src/utils/http.js
View file @
e74dad1b
...
@@ -31,22 +31,22 @@ axios.interceptors.request.use(
...
@@ -31,22 +31,22 @@ axios.interceptors.request.use(
delete
config
.
data
.
userAction
delete
config
.
data
.
userAction
}
}
if
(
store
.
getters
.
token
)
{
if
(
store
.
getters
.
token
)
{
config
.
headers
.
authorization
=
getToken
()
config
.
headers
[
'Dex-Token'
]
=
getToken
()
config
.
headers
[
'Dex-Auth-Type'
]
=
'Token'
if
(
!
getToken
())
{
delete
config
.
headers
.
authorization
delete
config
.
headers
[
'Dex-Token'
]
}
}
else
if
(
sessionStorage
.
getItem
(
'isLogin'
))
{
const
queryUserAccount
=
queryURLParams
(
window
.
location
.
href
).
userAccount
||
sessionStorage
.
getItem
(
'Login-free-userAccount'
)
||
''
const
queryUserAccount
=
queryURLParams
(
window
.
location
.
href
).
userAccount
||
sessionStorage
.
getItem
(
'Login-free-userAccount'
)
||
''
// eslint-disable-next-line no-prototype-builtins
if
(
queryUserAccount
)
{
if
(
queryUserAccount
)
{
const
rsaUserAccount
=
RSA
.
rsaPublicData
(
queryUserAccount
)
const
rsaUserAccount
=
RSA
.
rsaPublicData
(
queryUserAccount
)
sessionStorage
.
setItem
(
'Login-free-userAccount'
,
queryUserAccount
)
sessionStorage
.
setItem
(
'Login-free-userAccount'
,
queryUserAccount
)
sessionStorage
.
setItem
(
'isLogin'
,
'2'
)
config
.
headers
.
authorization
=
rsaUserAccount
config
.
headers
.
authorization
=
rsaUserAccount
config
.
headers
[
'Dex-Ukey-Token'
]
=
rsaUserAccount
config
.
headers
[
'Dex-Ukey-Token'
]
=
rsaUserAccount
config
.
headers
[
'Dex-Auth-Type'
]
=
'Ukey'
config
.
headers
[
'Dex-Auth-Type'
]
=
'Ukey'
}
else
{
config
.
headers
.
authorization
=
getToken
()
config
.
headers
[
'Dex-Token'
]
=
getToken
()
config
.
headers
[
'Dex-Auth-Type'
]
=
'Token'
}
if
(
!
getToken
())
{
delete
config
.
headers
.
authorization
delete
config
.
headers
[
'Dex-Token'
]
}
}
}
}
return
config
return
config
...
...
src/views/home/index.vue
View file @
e74dad1b
...
@@ -92,8 +92,39 @@ export default {
...
@@ -92,8 +92,39 @@ export default {
// 避免堆栈溢出,多次创建、多次触发
// 避免堆栈溢出,多次创建、多次触发
window
.
removeEventListener
(
'popstate'
,
this
.
popstate
,
false
)
window
.
removeEventListener
(
'popstate'
,
this
.
popstate
,
false
)
},
},
mounted
()
{
},
mounted
()
{
this
.
$nextTick
(()
=>
{
console
.
log
(
'this.$router.query.userAccount'
,
this
.
$route
.
query
?.
userAccount
)
if
(
this
.
$route
.
query
?.
userAccount
)
{
this
.
setUserLocalData
()
}
})
},
methods
:
{
methods
:
{
setUserLocalData
()
{
const
params
=
{
searchItems
:
{
items
:
[
{
fieldName
:
'userAccount'
,
operator
:
'EQ'
,
value
:
this
.
$route
.
query
?.
userAccount
}
],
operator
:
'AND'
}
}
this
.
$api
.
searchApi
(
'DxUserInfo'
,
params
).
then
(
res
=>
{
if
(
res
.
items
.
content
)
{
const
userVO
=
res
.
items
.
content
[
0
]
localStorage
.
setItem
(
'user'
,
userVO
.
name
)
localStorage
.
setItem
(
'userAccount'
,
userVO
.
userAccount
)
localStorage
.
setItem
(
'fullName'
,
userVO
.
nickName
)
localStorage
.
setItem
(
'userId'
,
userVO
.
id
)
localStorage
.
setItem
(
'org'
,
userVO
.
dxOrganizationId
)
}
})
},
popstate
()
{
popstate
()
{
Dialog
.
confirm
({
Dialog
.
confirm
({
title
:
'是否退出?'
title
:
'是否退出?'
...
...
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