Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fns_backend
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Zhang Xiaojie
fns_backend
Commits
d87495b3
Commit
d87495b3
authored
Sep 29, 2021
by
chenqikuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
管理员退出登录还是到管理员登录页
parent
1908ef99
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
12 deletions
+52
-12
index.ts
src/router/index.ts
+14
-8
index.ts
src/service/index.ts
+3
-1
index.ts
src/utils/router/index.ts
+24
-0
changePhone.vue
src/views/Root/Security/changePhone.vue
+4
-1
changePwd.vue
src/views/Root/Security/changePwd.vue
+4
-1
index.vue
src/views/Root/index.vue
+3
-1
No files found.
src/router/index.ts
View file @
d87495b3
...
@@ -64,37 +64,43 @@ const router = new VueRouter({
...
@@ -64,37 +64,43 @@ const router = new VueRouter({
})
})
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
//
console.log({ from, to })
console
.
log
({
from
,
to
})
const
usermsg
=
getUserMsg
()
const
usermsg
=
getUserMsg
()
if
(
usermsg
===
undefined
)
{
if
(
usermsg
===
undefined
)
{
/* 没有登录 */
/* 没有登录 */
if
(
to
.
name
==
'adminLogin'
||
to
.
name
==
'login'
)
{
if
(
to
.
name
==
'adminLogin'
||
to
.
name
==
'login'
)
{
console
.
log
(
1
)
next
()
next
()
}
else
{
}
else
{
console
.
log
(
2
)
next
({
next
({
name
:
'login'
,
name
:
'login'
,
})
})
}
}
}
else
{
}
else
{
console
.
log
(
3
)
/* 有登录 */
/* 有登录 */
const
roles
=
(
to
.
meta
as
{
roles
?:
eRole
[]
}).
roles
const
roles
=
(
to
.
meta
as
{
roles
?:
eRole
[]
}).
roles
const
oldRole
=
getOldRoleFromUserMsg
(
usermsg
)
const
oldRole
=
getOldRoleFromUserMsg
(
usermsg
)
// console.log(oldRole, roles, oldRole && roles && roles.includes(oldRole))
// console.log(oldRole, roles, oldRole && roles && roles.includes(oldRole))
const
userHasRoleInCurPage
=
oldRole
!==
undefined
&&
roles
!==
undefined
&&
roles
.
includes
(
oldRole
)
const
userHasRoleInCurPage
=
oldRole
!==
undefined
&&
roles
!==
undefined
&&
roles
.
includes
(
oldRole
)
if
(
userHasRoleInCurPage
)
{
if
(
userHasRoleInCurPage
)
{
// console.log(1
)
console
.
log
(
4
)
next
()
next
()
}
else
{
}
else
{
if
(
oldRole
==
eRole
.
platform_management
)
{
if
(
oldRole
==
eRole
.
platform_management
)
{
// console.log(2)
if
(
getUserMsg
()?.
phone
)
{
if
(
getUserMsg
()?.
phone
){
console
.
log
(
5
)
next
({
name
:
'platformUserManagement'
})
next
({
name
:
'platformUserManagement'
})
}
else
{
}
else
{
next
({
name
:
'changePhone'
})
console
.
log
(
6
)
next
({
name
:
'changePhone'
})
}
}
}
else
{
}
else
{
// console.log(3
)
console
.
log
(
7
)
next
({
name
:
'home'
})
next
({
name
:
'home'
})
}
}
}
}
...
...
src/service/index.ts
View file @
d87495b3
...
@@ -6,6 +6,7 @@ import axios, {
...
@@ -6,6 +6,7 @@ import axios, {
}
from
'axios'
}
from
'axios'
import
{
message
,
Modal
}
from
'ant-design-vue'
import
{
message
,
Modal
}
from
'ant-design-vue'
import
router
from
'@/router'
import
router
from
'@/router'
import
RouterUtil
from
'@/utils/router'
const
baseAxios
=
axios
.
create
({
const
baseAxios
=
axios
.
create
({
baseURL
:
'/proxyApi/api/v1'
,
baseURL
:
'/proxyApi/api/v1'
,
...
@@ -16,8 +17,9 @@ baseAxios.interceptors.response.use(
...
@@ -16,8 +17,9 @@ baseAxios.interceptors.response.use(
const
ret
=
value
.
data
const
ret
=
value
.
data
if
(
ret
.
code
!==
undefined
&&
ret
.
code
!==
200
)
{
if
(
ret
.
code
!==
undefined
&&
ret
.
code
!==
200
)
{
if
([
504
,
503
].
includes
(
ret
.
code
))
{
if
([
504
,
503
].
includes
(
ret
.
code
))
{
const
role
=
getUserMsg
()?.
newRole
window
.
localStorage
.
clear
()
window
.
localStorage
.
clear
()
router
.
push
(
'/login'
)
RouterUtil
.
getInstance
().
gotoLogin
(
role
)
// deleteUserMsg();
// deleteUserMsg();
}
}
message
.
error
(
ret
.
msg
)
message
.
error
(
ret
.
msg
)
...
...
src/utils/router/index.ts
0 → 100644
View file @
d87495b3
import
router
from
'@/router'
import
{
eNewRoleRelatedToBackEnd
,
eRole
}
from
'@/types/role'
export
default
class
RouterUtil
{
static
instance
:
RouterUtil
static
getInstance
()
{
if
(
!
RouterUtil
.
instance
)
{
RouterUtil
.
instance
=
new
RouterUtil
()
}
return
RouterUtil
.
instance
}
gotoLogin
(
role
:
eNewRoleRelatedToBackEnd
|
undefined
)
{
if
(
role
===
eNewRoleRelatedToBackEnd
.
PlatformAdmin
)
{
router
.
push
({
name
:
'adminLogin'
,
})
}
else
{
router
.
push
({
name
:
'login'
,
})
}
}
}
src/views/Root/Security/changePhone.vue
View file @
d87495b3
...
@@ -105,6 +105,7 @@ import { FormModel, Modal } from "ant-design-vue";
...
@@ -105,6 +105,7 @@ import { FormModel, Modal } from "ant-design-vue";
import
{
phoneValid
}
from
"./const"
;
import
{
phoneValid
}
from
"./const"
;
import
UserService
from
"@/service/UserManagementService"
;
import
UserService
from
"@/service/UserManagementService"
;
import
{
deleteUserMsg
,
getUserMsg
,
setUserMsg
}
from
"@/utils/userMsg/userMsg"
;
import
{
deleteUserMsg
,
getUserMsg
,
setUserMsg
}
from
"@/utils/userMsg/userMsg"
;
import
RouterUtil
from
"@/utils/router"
;
export
default
Vue
.
extend
({
export
default
Vue
.
extend
({
components
:
{
CodeInput
},
components
:
{
CodeInput
},
props
:
{
props
:
{
...
@@ -232,7 +233,9 @@ export default Vue.extend({
...
@@ -232,7 +233,9 @@ export default Vue.extend({
title
:
"手机号修改成功"
,
title
:
"手机号修改成功"
,
content
:
"请重新登陆"
,
content
:
"请重新登陆"
,
onOk
()
{
onOk
()
{
that
.
$router
.
push
({
name
:
"login"
});
const
role
=
getUserMsg
()?.
newRole
window
.
localStorage
.
clear
()
RouterUtil
.
getInstance
().
gotoLogin
(
role
)
},
},
});
});
}
else
{
}
else
{
...
...
src/views/Root/Security/changePwd.vue
View file @
d87495b3
...
@@ -61,6 +61,7 @@ import codeInput from "@/components/CodeInput/index.vue";
...
@@ -61,6 +61,7 @@ import codeInput from "@/components/CodeInput/index.vue";
import
UserService
from
"@/service/UserManagementService"
;
import
UserService
from
"@/service/UserManagementService"
;
import
{
deleteUserMsg
,
getUserMsg
}
from
"@/utils/userMsg/userMsg"
;
import
{
deleteUserMsg
,
getUserMsg
}
from
"@/utils/userMsg/userMsg"
;
import
{
Modal
}
from
"ant-design-vue"
import
{
Modal
}
from
"ant-design-vue"
import
RouterUtil
from
"@/utils/router"
;
export
default
Vue
.
extend
({
export
default
Vue
.
extend
({
components
:
{
codeInput
},
components
:
{
codeInput
},
...
@@ -148,7 +149,9 @@ export default Vue.extend({
...
@@ -148,7 +149,9 @@ export default Vue.extend({
title
:
"密码修改成功"
,
title
:
"密码修改成功"
,
content
:
"请重新登陆"
,
content
:
"请重新登陆"
,
onOk
()
{
onOk
()
{
that
.
$router
.
push
({
name
:
"login"
});
const
role
=
getUserMsg
()?.
newRole
window
.
localStorage
.
clear
()
RouterUtil
.
getInstance
().
gotoLogin
(
role
)
},
},
});
});
}
else
{
}
else
{
...
...
src/views/Root/index.vue
View file @
d87495b3
...
@@ -81,6 +81,7 @@ import { Fragment } from "vue-fragment";
...
@@ -81,6 +81,7 @@ import { Fragment } from "vue-fragment";
import
{
getUserMsg
}
from
"@/utils/userMsg/userMsg"
;
import
{
getUserMsg
}
from
"@/utils/userMsg/userMsg"
;
import
{
getOldRoleFromUserMsg
}
from
"@/utils/user"
;
import
{
getOldRoleFromUserMsg
}
from
"@/utils/user"
;
import
UserService
from
'@/service/UserManagementService'
import
UserService
from
'@/service/UserManagementService'
import
RouterUtil
from
"@/utils/router"
;
Vue
.
use
(
Menu
);
Vue
.
use
(
Menu
);
Vue
.
use
(
Icon
);
Vue
.
use
(
Icon
);
...
@@ -151,8 +152,9 @@ export default Vue.extend({
...
@@ -151,8 +152,9 @@ export default Vue.extend({
logout
()
{
logout
()
{
userService
.
logout
().
then
(
res
=>
{
userService
.
logout
().
then
(
res
=>
{
if
(
res
.
code
===
200
)
{
if
(
res
.
code
===
200
)
{
const
role
=
getUserMsg
()?.
newRole
window
.
localStorage
.
clear
()
window
.
localStorage
.
clear
()
this
.
$router
.
push
(
'/login'
)
RouterUtil
.
getInstance
().
gotoLogin
(
role
)
}
}
})
})
}
}
...
...
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