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
3f66810f
Commit
3f66810f
authored
Mar 21, 2024
by
tianhongyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
央企接入第三方 前端鉴定方式更改
parent
312d3a84
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
365 additions
and
216 deletions
+365
-216
login.js
dsk-operate-ui/src/api/login.js
+32
-20
Navbar.vue
dsk-operate-ui/src/layout/components/Navbar.vue
+6
-3
index.vue
dsk-operate-ui/src/layout/components/Sidebar/index.vue
+8
-1
permission.js
dsk-operate-ui/src/permission.js
+43
-12
index.js
dsk-operate-ui/src/router/index.js
+129
-131
permission.js
dsk-operate-ui/src/store/modules/permission.js
+9
-6
user.js
dsk-operate-ui/src/store/modules/user.js
+30
-2
auth.js
dsk-operate-ui/src/utils/auth.js
+39
-0
401.vue
dsk-operate-ui/src/views/error/401.vue
+69
-41
No files found.
dsk-operate-ui/src/api/login.js
View file @
3f66810f
import
request
from
'@/utils/request'
import
request
from
'@/utils/request'
;
// 登录方法
export
function
login
(
username
,
password
,
code
,
uuid
)
{
...
...
@@ -7,7 +7,7 @@ export function login(username, password, code, uuid) {
password
,
code
,
uuid
}
}
;
return
request
({
url
:
'/login'
,
headers
:
{
...
...
@@ -15,7 +15,7 @@ export function login(username, password, code, uuid) {
},
method
:
'post'
,
data
:
data
})
})
;
}
// 注册方法
...
...
@@ -27,7 +27,7 @@ export function register(data) {
},
method
:
'post'
,
data
:
data
})
})
;
}
// 获取用户详细信息
...
...
@@ -35,7 +35,7 @@ export function getInfo() {
return
request
({
url
:
'/getInfo'
,
method
:
'get'
})
})
;
}
// 退出方法
...
...
@@ -43,7 +43,7 @@ export function logout() {
return
request
({
url
:
'/logout'
,
method
:
'post'
})
})
;
}
// 获取验证码
...
...
@@ -55,7 +55,7 @@ export function getCodeImg() {
},
method
:
'get'
,
timeout
:
20000
})
})
;
}
//获取租户企业列表
...
...
@@ -63,7 +63,7 @@ export function getTenants() {
return
request
({
url
:
'/user/tenants'
,
method
:
'post'
,
})
})
;
}
// 获取默认租户
...
...
@@ -71,15 +71,15 @@ export function defaultTenantid() {
return
request
({
url
:
'/user/default/tenant'
,
method
:
'post'
,
})
})
;
}
// 切换租户
export
function
changeTenants
(
data
)
{
return
request
({
url
:
'/switch/tenant?tenantId='
+
data
,
url
:
'/switch/tenant?tenantId='
+
data
,
method
:
'post'
,
})
})
;
}
//发送短信验证码(删除组织使用)
...
...
@@ -87,7 +87,7 @@ export function captchaSms() {
return
request
({
url
:
'/getTempSmsCode'
,
method
:
'get'
,
})
})
;
}
//验证短信验证码(删除组织使用)
...
...
@@ -95,8 +95,8 @@ export function checkSmsCode(data) {
return
request
({
url
:
'/checkSmsCode'
,
method
:
'POST'
,
params
:
data
})
params
:
data
})
;
}
//根据用户账号获取用户绑定的租户列表
...
...
@@ -104,8 +104,8 @@ export function userTenantList(data) {
return
request
({
url
:
'/user/tenant/list'
,
method
:
'POST'
,
params
:
data
})
params
:
data
})
;
}
//登录获取验证码
...
...
@@ -113,17 +113,29 @@ export function logincaptchaSms(data) {
return
request
({
url
:
'/captchaSms'
,
method
:
'get'
,
params
:
data
})
params
:
data
})
;
}
//短信登录
export
function
smsLogin
(
data
)
{
return
request
({
url
:
'/smsLogin'
,
method
:
'post'
,
data
:
data
})
data
:
data
})
;
}
/**
* 第三方植入系统
* @param {string} thirdPlatformKey
* @returns
*/
export
const
thirdPlatformLoginApi
=
(
thirdPlatformKey
)
=>
request
({
method
:
"post"
,
url
:
"/thirdPlatformLogin"
,
data
:
{
thirdPlatformKey
}
})
dsk-operate-ui/src/layout/components/Navbar.vue
View file @
3f66810f
...
...
@@ -4,7 +4,7 @@
<div
class=
"left-menu"
:style=
"
{width: scrollerWidth}">
<tags-view
/>
</div>
<div
ref=
"rightMenu"
class=
"flex-box right-menu"
>
<div
ref=
"rightMenu"
class=
"flex-box right-menu"
v-if=
"!isThirdPlatformLogin"
>
<!--
<div
class=
"menu-bells"
><img
src=
"@/assets/images/message.png"
><i
/></div>
-->
<!--
<i
class=
"menu-line"
/>
-->
<el-dropdown
class=
"avatar-container"
trigger=
"hover"
ref=
"mydrodown"
:hide-on-click=
"false"
placement=
"bottom-start"
>
...
...
@@ -40,7 +40,7 @@
<
script
>
import
store
from
"@/store"
;
import
{
mapGetters
}
from
'vuex'
import
{
mapGetters
,
mapState
}
from
'vuex'
import
elementResizeDetectorMaker
from
"element-resize-detector"
import
TagsView
from
'./TagsView'
import
{
getTenants
,
changeTenants
}
from
"@/api/login"
;
...
...
@@ -63,7 +63,10 @@ export default {
'sidebar'
,
'avatar'
,
'name'
])
]),
...
mapState
({
isThirdPlatformLogin
:
state
=>
state
.
user
.
isThirdPlatformLogin
})
},
watch
:
{
offsetWidth
(
newValue
,
oldValue
){
...
...
dsk-operate-ui/src/layout/components/Sidebar/index.vue
View file @
3f66810f
...
...
@@ -4,7 +4,7 @@
<logo
v-if=
"showLogo"
:collapse=
"isCollapse"
/>
<el-scrollbar
:class=
"settings.sideTheme"
wrap-class=
"scrollbar-wrapper"
>
<el-menu
:default-active=
"activeMenu"
:collapse=
"isCollapse"
:background-color=
"variables.menuBg"
:text-color=
"variables.menuText"
:unique-opened=
"true"
:active-text-color=
"settings.theme"
:collapse-transition=
"false"
mode=
"vertical"
>
:unique-opened=
"true"
:active-text-color=
"settings.theme"
:collapse-transition=
"false"
mode=
"vertical"
class=
"left-top-level-menu"
>
<sidebar-item
v-for=
"(route, index) in hidechildren"
:key=
"route.path + index"
:is-collapse=
"isCollapse"
:active-menu=
"activeMenu"
:item=
"route"
:base-path=
"route.path"
:class=
"route.fixed&&route.fixed.isFixed?'sideFoot':''"
:style=
"route.fixed&&route.fixed.isFixed?
{'bottom': route.fixed.number*50+'px'}: bottomMenu
&&
index==routes.length-bottomMenu-2?{'padding-bottom': bottomMenu*50+'px'}:''" />
...
...
@@ -91,3 +91,10 @@ export default {
},
};
</
script
>
<
style
lang=
"scss"
scoped
>
.left-top-level-menu
{
padding
:
20px
0px
;
box-sizing
:
border-box
;
}
</
style
>
dsk-operate-ui/src/permission.js
View file @
3f66810f
...
...
@@ -3,14 +3,17 @@ import store from './store';
import
{
Message
}
from
'element-ui'
;
import
NProgress
from
'nprogress'
;
import
'nprogress/nprogress.css'
;
import
{
getToken
}
from
'@/utils/auth'
;
import
{
getToken
,
getThirdPlatform
}
from
'@/utils/auth'
;
import
{
isRelogin
}
from
'@/utils/request'
;
NProgress
.
configure
({
showSpinner
:
false
});
const
whiteList
=
[
'/login'
,
'/register'
];
const
whiteList
=
[
'/login'
,
"/404"
,
"/401"
];
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
// 默认跳转路径 本系统跳转首页,第三方跳转宏观市场
const
platFormKey
=
getThirdPlatform
();
let
defaultRedirectPath
=
platFormKey
?
"/macro/nationalEconomies"
:
"/"
;
NProgress
.
start
();
if
(
getToken
())
{
// tab页签title
...
...
@@ -20,10 +23,10 @@ router.beforeEach((to, from, next) => {
to
.
meta
.
title
&&
store
.
dispatch
(
'settings/setTitle'
,
to
.
meta
.
title
);
/* has token*/
if
(
to
.
path
===
'/login'
)
{
next
({
path
:
'/'
});
next
({
path
:
defaultRedirectPath
});
NProgress
.
done
();
}
else
{
if
(
store
.
getters
.
roles
.
length
===
0
)
{
if
(
!
store
.
state
?.
user
?.
userId
&&
!
store
.
state
?.
user
?.
roles
?.
length
)
{
isRelogin
.
show
=
true
;
// 判断当前用户是否已拉取完user_info信息
store
.
dispatch
(
'GetInfo'
).
then
(()
=>
{
...
...
@@ -34,24 +37,52 @@ router.beforeEach((to, from, next) => {
next
({
...
to
,
replace
:
true
});
// hack方法 确保addRoutes已完成
});
}).
catch
(
err
=>
{
store
.
dispatch
(
'LogOut'
).
then
(()
=>
{
Message
.
error
(
err
);
sessionStorage
.
removeItem
(
'views'
);
next
({
path
:
'/'
});
});
if
(
platFormKey
)
{
store
.
dispatch
(
'FedLogOut'
).
then
(()
=>
{
next
({
path
:
"/401"
,
query
:
{
isSecretFreeLogin
:
true
}
});
});
}
else
{
store
.
dispatch
(
'LogOut'
).
then
(()
=>
{
Message
.
error
(
err
);
sessionStorage
.
removeItem
(
'views'
);
next
({
path
:
'/'
});
});
}
});
}
else
{
next
();
}
}
}
else
{
// 没有token
if
(
whiteList
.
indexOf
(
to
.
path
)
!==
-
1
)
{
// 在免登录白名单,直接进入
next
();
}
else
{
next
(
`/login?redirect=
${
to
.
fullPath
}
`
);
// 否则全部重定向到登录页
NProgress
.
done
();
// 非白名单 没有token 判断是否有app key 属于第三方平台
// 第三方平台 获取到 platFormKey 直接通过key 登录
if
(
platFormKey
)
{
store
.
dispatch
(
"secretFreeLogin"
,
platFormKey
).
then
((
res
)
=>
{
next
({
path
:
defaultRedirectPath
});
}).
catch
(
err
=>
{
// appkey 登陆失败 跳转到401
next
({
path
:
"/401"
,
query
:
{
isSecretFreeLogin
:
true
}
});
});
}
else
{
next
(
`/login?redirect=
${
to
.
fullPath
}
`
);
// 否则全部重定向到登录页
NProgress
.
done
();
}
}
}
});
...
...
dsk-operate-ui/src/router/index.js
View file @
3f66810f
This diff is collapsed.
Click to expand it.
dsk-operate-ui/src/store/modules/permission.js
View file @
3f66810f
import
auth
from
'@/plugins/auth'
;
import
router
,
{
constantRoutes
,
dynamicRoutes
}
from
'@/router'
;
import
router
,
{
constantRoutes
,
dynamicRoutes
,
isThirdPlatformRoutes
}
from
'@/router'
;
import
{
getRouters
}
from
'@/api/menu'
;
import
Layout
from
'@/layout/index'
;
import
ParentView
from
'@/components/ParentView'
;
...
...
@@ -19,7 +19,7 @@ const permission = {
state
.
routes
=
constantRoutes
.
concat
(
routes
);
},
SET_DEFAULT_ROUTES
:
(
state
,
routes
)
=>
{
state
.
defaultRoutes
=
constantRoutes
.
concat
(
routes
)
;
state
.
defaultRoutes
=
routes
;
},
SET_TOPBAR_ROUTES
:
(
state
,
routes
)
=>
{
state
.
topbarRouters
=
routes
;
...
...
@@ -30,21 +30,24 @@ const permission = {
},
actions
:
{
// 生成路由
GenerateRoutes
({
commit
})
{
GenerateRoutes
({
commit
,
rootState
})
{
return
new
Promise
(
resolve
=>
{
// 向后端请求路由数据
getRouters
().
then
(
res
=>
{
const
isThirdPlatformLogin
=
rootState
.
user
.
isThirdPlatformLogin
;
let
_array
=
isThirdPlatformLogin
?
[
isThirdPlatformRoutes
[
1
]]
:
[
isThirdPlatformRoutes
[
0
]];
const
sdata
=
JSON
.
parse
(
JSON
.
stringify
(
res
.
data
));
const
rdata
=
JSON
.
parse
(
JSON
.
stringify
(
res
.
data
));
const
sidebarRoutes
=
filterAsyncRouter
(
sdata
);
const
rewriteRoutes
=
filterAsyncRouter
(
rdata
,
false
,
true
);
const
asyncRoutes
=
filterDynamicRoutes
(
dynamicRoutes
);
rewriteRoutes
.
unshift
(...
_array
);
rewriteRoutes
.
push
({
path
:
'*'
,
redirect
:
'/404'
,
hidden
:
true
});
router
.
addRoutes
(
asyncRoutes
);
commit
(
'SET_ROUTES'
,
rewriteRoutes
);
commit
(
'SET_SIDEBAR_ROUTERS'
,
constantRoutes
.
concat
(
sidebarRoutes
));
commit
(
'SET_DEFAULT_ROUTES'
,
sidebarRoutes
);
commit
(
'SET_TOPBAR_ROUTES'
,
sidebarRoutes
);
commit
(
'SET_SIDEBAR_ROUTERS'
,
constantRoutes
.
concat
(
_array
).
concat
(
sidebarRoutes
));
commit
(
'SET_DEFAULT_ROUTES'
,
constantRoutes
.
concat
(
_array
).
concat
(
sidebarRoutes
)
);
commit
(
'SET_TOPBAR_ROUTES'
,
constantRoutes
.
concat
(
_array
).
concat
(
sidebarRoutes
)
);
resolve
(
rewriteRoutes
);
});
});
...
...
dsk-operate-ui/src/store/modules/user.js
View file @
3f66810f
import
{
login
,
logout
,
getInfo
}
from
'@/api/login'
;
import
{
getToken
,
setToken
,
removeToken
,
setTenantid
}
from
'@/utils/auth'
;
import
{
login
,
logout
,
getInfo
,
thirdPlatformLoginApi
}
from
'@/api/login'
;
import
{
getToken
,
setToken
,
removeToken
,
setTenantid
,
removeThirdPlatform
}
from
'@/utils/auth'
;
const
user
=
{
state
:
{
...
...
@@ -10,6 +10,7 @@ const user = {
permissions
:
[],
userId
:
''
,
phonenumber
:
''
,
isThirdPlatformLogin
:
false
},
mutations
:
{
...
...
@@ -33,6 +34,9 @@ const user = {
},
SET_USERPHONE
:
(
state
,
phonenumber
)
=>
{
state
.
phonenumber
=
phonenumber
;
},
SET_IS_THIRD_PLATFORM
:
(
state
,
isThirdPlatformLogin
)
=>
{
state
.
isThirdPlatformLogin
=
isThirdPlatformLogin
?
true
:
false
;
}
},
...
...
@@ -71,6 +75,7 @@ const user = {
commit
(
'SET_AVATAR'
,
avatar
);
commit
(
'SET_USERID'
,
user
.
userId
);
commit
(
'SET_USERPHONE'
,
user
.
phonenumber
);
commit
(
"SET_IS_THIRD_PLATFORM"
,
res
.
data
.
isThirdPlatformLogin
);
resolve
(
res
);
}).
catch
(
error
=>
{
reject
(
error
);
...
...
@@ -97,10 +102,33 @@ const user = {
FedLogOut
({
commit
})
{
return
new
Promise
(
resolve
=>
{
commit
(
'SET_TOKEN'
,
''
);
commit
(
'SET_USERID'
,
""
);
commit
(
'SET_ROLES'
,
[]);
removeToken
();
resolve
();
});
},
// 免密登录 通过appkey登录
async
secretFreeLogin
({
commit
,
state
},
payload
)
{
try
{
if
(
!
payload
)
throw
new
Error
(
"缺少platFormKey"
);
const
tokenInfo
=
await
thirdPlatformLoginApi
(
payload
);
console
.
log
(
tokenInfo
);
if
(
tokenInfo
.
code
==
200
)
{
setToken
(
tokenInfo
.
data
.
token
);
commit
(
'SET_TOKEN'
,
tokenInfo
.
data
.
token
);
setTenantid
(
tokenInfo
.
data
.
tenantId
);
return
true
;
}
else
{
throw
new
Error
(
"appkey登录失败"
);
}
}
catch
(
error
)
{
throw
error
;
}
}
}
};
...
...
dsk-operate-ui/src/utils/auth.js
View file @
3f66810f
import
Cookies
from
'js-cookie'
;
import
{
getUrlSearchQuery
}
from
'@/utils'
;
const
TokenKey
=
'Admin-Token'
;
const
Tenantid
=
'Tenantid'
;
...
...
@@ -30,3 +31,41 @@ export function setBiAuth(token) {
sessionStorage
.
setItem
(
"DSK_SYSTEM_AUTH_TOKEN"
,
token
);
return
true
;
}
/**
* 获取第三方app key
* @returns
*/
export
function
getThirdPlatform
()
{
const
platForm
=
sessionStorage
.
getItem
(
"PLAT_FORM"
);
if
(
platForm
)
return
platForm
;
// sessiongStorage 未获取到appkey 寻找url上的参数
const
{
platFormKey
}
=
getUrlSearchQuery
();
if
(
platFormKey
)
{
return
setThirdPlatform
(
platFormKey
)
?
platFormKey
:
""
;
}
else
{
return
""
;
};
}
/**
* 储存第三方app key
* @param {*} appkey
* @returns
*/
export
function
setThirdPlatform
(
appkey
)
{
try
{
if
(
!
appkey
)
throw
new
Error
(
""
);
sessionStorage
.
setItem
(
"PLAT_FORM"
,
appkey
);
return
true
;
}
catch
(
error
)
{
return
false
;
}
}
/**
* 移除第三方app key
*/
export
function
removeThirdPlatform
()
{
sessionStorage
.
removeItem
(
"PLAT_FORM"
);
}
dsk-operate-ui/src/views/error/401.vue
View file @
3f66810f
<
template
>
<div
class=
"errPage-container"
>
<el-button
icon=
"arrow-left"
class=
"pan-back-btn"
@
click=
"
back
"
>
返回
<el-button
icon=
"arrow-left"
class=
"pan-back-btn"
@
click=
"
isSecretFreeLogin === false ? back() : aginLogin()
"
>
{{
isSecretFreeLogin
===
false
?
"返回"
:
"重新登录"
}}
</el-button>
<el-row>
<el-col
:span=
"12"
>
...
...
@@ -9,8 +9,8 @@
401错误!
</h1>
<h2>
您没有访问权限!
</h2>
<h6>
对不起,您没有访问权限,请不要进行非法操作!
您可以返回主页面
</h6>
<ul
class=
"list-unstyled"
>
<h6>
对不起,您没有访问权限,请不要进行非法操作!
{{
isSecretFreeLogin
===
true
?
"您可以尝试使用appkey重新登录系统"
:
"您可以返回主界面"
}}
</h6>
<ul
class=
"list-unstyled"
v-if=
"isSecretFreeLogin === false"
>
<li
class=
"link-type"
>
<router-link
to=
"/"
>
回首页
...
...
@@ -26,21 +26,46 @@
</
template
>
<
script
>
import
errGif
from
'@/assets/images/401/401.gif'
import
errGif
from
'@/assets/images/401/401.gif'
;
import
{
getThirdPlatform
}
from
"@/utils/auth"
;
export
default
{
name
:
'Page401'
,
data
()
{
return
{
errGif
:
errGif
+
'?'
+
+
new
Date
()
errGif
:
errGif
+
'?'
+
+
new
Date
(),
isSecretFreeLogin
:
null
};
},
created
()
{
const
{
isSecretFreeLogin
}
=
this
.
$route
.
query
;
try
{
this
.
isSecretFreeLogin
=
JSON
.
parse
(
isSecretFreeLogin
);
}
catch
(
error
)
{
}
},
methods
:
{
back
()
{
if
(
this
.
$route
.
query
.
noGoBack
)
{
this
.
$router
.
push
({
path
:
'/'
})
this
.
$router
.
push
({
path
:
'/'
});
}
else
{
this
.
$router
.
go
(
-
1
);
}
},
aginLogin
()
{
const
platFormKey
=
getThirdPlatform
();
if
(
platFormKey
)
{
this
.
$router
.
replace
({
path
:
"/"
,
query
:
{
platFormKey
}
});
}
else
{
this
.
$router
.
go
(
-
1
)
this
.
$router
.
replace
({
path
:
"/login"
});
}
}
}
...
...
@@ -48,41 +73,44 @@ export default {
</
script
>
<
style
lang=
"scss"
scoped
>
.errPage-container
{
width
:
800px
;
max-width
:
100%
;
margin
:
100px
auto
;
.pan-back-btn
{
background
:
#008489
;
color
:
#fff
;
border
:
none
!
important
;
}
.pan-gif
{
margin
:
0
auto
;
display
:
block
;
}
.pan-img
{
display
:
block
;
margin
:
0
auto
;
width
:
100%
;
}
.text-jumbo
{
font-size
:
60px
;
font-weight
:
700
;
color
:
#484848
;
.errPage-container
{
width
:
800px
;
max-width
:
100%
;
margin
:
100px
auto
;
.pan-back-btn
{
background
:
#008489
;
color
:
#fff
;
border
:
none
!
important
;
}
.pan-gif
{
margin
:
0
auto
;
display
:
block
;
}
.pan-img
{
display
:
block
;
margin
:
0
auto
;
width
:
100%
;
}
.text-jumbo
{
font-size
:
60px
;
font-weight
:
700
;
color
:
#484848
;
}
.list-unstyled
{
font-size
:
14px
;
li
{
padding-bottom
:
5px
;
}
.list-unstyled
{
font-size
:
14px
;
li
{
padding-bottom
:
5px
;
}
a
{
color
:
#008489
;
text-decoration
:
none
;
&
:hover
{
text-decoration
:
underline
;
}
a
{
color
:
#008489
;
text-decoration
:
none
;
&
:hover
{
text-decoration
:
underline
;
}
}
}
h6
{
line-height
:
22px
;
}
}
</
style
>
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