Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dsk-cr20g
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
Administrator
dsk-cr20g
Commits
79ca5926
Commit
79ca5926
authored
Apr 11, 2024
by
tianhongyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
第三方登录逻辑处理优化
parent
cd65252f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
14 deletions
+32
-14
permission.js
dsk-operate-ui/src/permission.js
+15
-3
user.js
dsk-operate-ui/src/store/modules/user.js
+0
-1
auth.js
dsk-operate-ui/src/utils/auth.js
+16
-4
vue.config.js
dsk-operate-ui/vue.config.js
+1
-6
No files found.
dsk-operate-ui/src/permission.js
View file @
79ca5926
...
@@ -3,18 +3,27 @@ import store from './store';
...
@@ -3,18 +3,27 @@ import store from './store';
import
{
Message
}
from
'element-ui'
;
import
{
Message
}
from
'element-ui'
;
import
NProgress
from
'nprogress'
;
import
NProgress
from
'nprogress'
;
import
'nprogress/nprogress.css'
;
import
'nprogress/nprogress.css'
;
import
{
getToken
,
getThirdPlatform
}
from
'@/utils/auth'
;
import
{
getToken
,
getThirdPlatform
,
checkThirdPlatformChange
,
removeThirdPlatform
,
setThirdPlatform
}
from
'@/utils/auth'
;
import
{
isRelogin
}
from
'@/utils/request'
;
import
{
isRelogin
}
from
'@/utils/request'
;
NProgress
.
configure
({
showSpinner
:
false
});
NProgress
.
configure
({
showSpinner
:
false
});
const
whiteList
=
[
'/login'
,
"/404"
,
"/401"
];
const
whiteList
=
[
'/login'
,
"/404"
,
"/401"
];
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
router
.
beforeEach
(
async
(
to
,
from
,
next
)
=>
{
// 存在platFormkey但是 已经更换 或本地session不存在 已经存在其它token 重写拉取所有信息
const
onlyUrlKey
=
getThirdPlatform
(
true
);
if
(
onlyUrlKey
&&
checkThirdPlatformChange
(
onlyUrlKey
))
{
// 前端退出登录
await
store
.
dispatch
(
"FedLogOut"
);
removeThirdPlatform
();
setThirdPlatform
(
onlyUrlKey
);
}
// 默认跳转路径 本系统跳转首页,第三方跳转宏观市场
// 默认跳转路径 本系统跳转首页,第三方跳转宏观市场
const
platFormKey
=
getThirdPlatform
();
const
platFormKey
=
getThirdPlatform
();
let
defaultRedirectPath
=
platFormKey
?
"/macro/nationalEconomies"
:
"/"
;
let
defaultRedirectPath
=
platFormKey
?
"/macro/nationalEconomies"
:
"/"
;
NProgress
.
start
();
NProgress
.
start
();
// 正常登录 不带第三方
if
(
getToken
())
{
if
(
getToken
())
{
// tab页签title
// tab页签title
const
{
tabTitle
,
url
}
=
to
.
query
;
const
{
tabTitle
,
url
}
=
to
.
query
;
...
@@ -29,7 +38,10 @@ router.beforeEach((to, from, next) => {
...
@@ -29,7 +38,10 @@ router.beforeEach((to, from, next) => {
if
(
!
store
.
state
?.
user
?.
userId
&&
!
store
.
state
?.
user
?.
roles
?.
length
)
{
if
(
!
store
.
state
?.
user
?.
userId
&&
!
store
.
state
?.
user
?.
roles
?.
length
)
{
isRelogin
.
show
=
true
;
isRelogin
.
show
=
true
;
// 判断当前用户是否已拉取完user_info信息
// 判断当前用户是否已拉取完user_info信息
store
.
dispatch
(
'GetInfo'
).
then
(()
=>
{
store
.
dispatch
(
'GetInfo'
).
then
(
async
(
res
)
=>
{
if
(
res
?.
data
?.
isThirdPlatformLogin
&&
!
platFormKey
)
{
throw
new
Error
(
"第三方登录重置,请重新使用platFormKey进入"
);
}
isRelogin
.
show
=
false
;
isRelogin
.
show
=
false
;
store
.
dispatch
(
'GenerateRoutes'
).
then
(
accessRoutes
=>
{
store
.
dispatch
(
'GenerateRoutes'
).
then
(
accessRoutes
=>
{
// 根据roles权限生成可访问的路由表
// 根据roles权限生成可访问的路由表
...
...
dsk-operate-ui/src/store/modules/user.js
View file @
79ca5926
...
@@ -115,7 +115,6 @@ const user = {
...
@@ -115,7 +115,6 @@ const user = {
try
{
try
{
if
(
!
payload
)
throw
new
Error
(
"缺少platFormKey"
);
if
(
!
payload
)
throw
new
Error
(
"缺少platFormKey"
);
const
tokenInfo
=
await
thirdPlatformLoginApi
(
payload
);
const
tokenInfo
=
await
thirdPlatformLoginApi
(
payload
);
console
.
log
(
tokenInfo
);
if
(
tokenInfo
.
code
==
200
)
{
if
(
tokenInfo
.
code
==
200
)
{
setToken
(
tokenInfo
.
data
.
token
);
setToken
(
tokenInfo
.
data
.
token
);
commit
(
'SET_TOKEN'
,
tokenInfo
.
data
.
token
);
commit
(
'SET_TOKEN'
,
tokenInfo
.
data
.
token
);
...
...
dsk-operate-ui/src/utils/auth.js
View file @
79ca5926
...
@@ -34,20 +34,32 @@ export function setBiAuth(token) {
...
@@ -34,20 +34,32 @@ export function setBiAuth(token) {
/**
/**
* 获取第三方app key
* 获取第三方app key
* @param {*} onlyUrl 是否仅从url获取
* @returns
* @returns
*/
*/
export
function
getThirdPlatform
()
{
export
function
getThirdPlatform
(
onlyUrl
=
false
)
{
if
(
!
onlyUrl
)
{
const
platForm
=
sessionStorage
.
getItem
(
"PLAT_FORM"
);
const
platForm
=
sessionStorage
.
getItem
(
"PLAT_FORM"
);
if
(
platForm
)
return
platForm
;
if
(
platForm
)
return
platForm
;
}
// sessiongStorage 未获取到appkey 寻找url上的参数
// sessiongStorage 未获取到appkey 寻找url上的参数
const
{
platFormKey
}
=
getUrlSearchQuery
();
const
{
platFormKey
}
=
getUrlSearchQuery
();
if
(
platFormKey
)
{
if
(
platFormKey
)
{
return
setThirdPlatform
(
platFormKey
)
?
platFormKey
:
""
;
return
platFormKey
;
}
else
{
}
else
{
return
""
;
return
""
;
};
};
}
}
/**
* 检测 appkey是否存在变动
* @param {*} appkey
*/
export
function
checkThirdPlatformChange
(
appkey
)
{
const
platForm
=
sessionStorage
.
getItem
(
"PLAT_FORM"
);
return
platForm
!==
appkey
;
}
/**
/**
* 储存第三方app key
* 储存第三方app key
* @param {*} appkey
* @param {*} appkey
...
...
dsk-operate-ui/vue.config.js
View file @
79ca5926
...
@@ -35,12 +35,7 @@ module.exports = {
...
@@ -35,12 +35,7 @@ module.exports = {
proxy
:
{
proxy
:
{
// detail: https://cli.vuejs.org/config/#devserver-proxy
// detail: https://cli.vuejs.org/config/#devserver-proxy
[
process
.
env
.
VUE_APP_BASE_API
]:
{
[
process
.
env
.
VUE_APP_BASE_API
]:
{
target
:
`http://120.46.64.239:9099/prod-api`
,
//测试
target
:
`http://123.60.218.188:9099/prod-api`
,
//测试
// target: `https://szhapi.jiansheku.com`,//线上
// target: `http://122.9.160.122:9011`, //线上
// target: `http://192.168.0.165:9098`,//施-无线
// target: `http://192.168.60.46:9098`,//施-有线
// target: `http://192.168.60.6:9098`,//谭
changeOrigin
:
true
,
changeOrigin
:
true
,
pathRewrite
:
{
pathRewrite
:
{
[
'^'
+
process
.
env
.
VUE_APP_BASE_API
]:
''
[
'^'
+
process
.
env
.
VUE_APP_BASE_API
]:
''
...
...
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