Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
NLT-e-cigarette
Project
Project
Details
Activity
Releases
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
张伯涛
NLT-e-cigarette
Commits
b011dfcc
Commit
b011dfcc
authored
Jul 27, 2022
by
张伯涛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改
parent
0488b90c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
7 deletions
+8
-7
permission.js
src/permission.js
+6
-6
permission.js
src/store/modules/permission.js
+1
-0
login.vue
src/views/login/login.vue
+1
-1
No files found.
src/permission.js
View file @
b011dfcc
...
@@ -14,6 +14,7 @@ NProgress.configure({ showSpinner: false }) // NProgress Configuration
...
@@ -14,6 +14,7 @@ NProgress.configure({ showSpinner: false }) // NProgress Configuration
const
whiteList
=
[
'/auth-redirect'
,
'/bind'
,
'/register'
,
'/login'
,
'/forgetPwd'
]
const
whiteList
=
[
'/auth-redirect'
,
'/bind'
,
'/register'
,
'/login'
,
'/forgetPwd'
]
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
console
.
log
(
'beforeEach'
,
to
)
NProgress
.
start
()
NProgress
.
start
()
if
(
getToken
())
{
if
(
getToken
())
{
/* has token*/
/* has token*/
...
@@ -33,14 +34,13 @@ router.beforeEach((to, from, next) => {
...
@@ -33,14 +34,13 @@ router.beforeEach((to, from, next) => {
// 判断用户是否有路由
// 判断用户是否有路由
if
(
routers
.
accessedRoutes
&&
routers
.
accessedRoutes
.
length
>
0
&&
routers
.
getRouters
&&
routers
.
getRouters
.
length
>
0
)
{
if
(
routers
.
accessedRoutes
&&
routers
.
accessedRoutes
.
length
>
0
&&
routers
.
getRouters
&&
routers
.
getRouters
.
length
>
0
)
{
console
.
log
(
'routers.accessedRoutes'
,
routers
.
accessedRoutes
)
console
.
log
(
'routers.accessedRoutes'
,
routers
.
accessedRoutes
)
router
.
addRoutes
(
routers
.
accessedRoutes
)
// 动态添加可访问路由表
console
.
log
(
'routers.accessedRoutes[0].children[0].path'
,
routers
.
accessedRoutes
[
0
].
children
[
0
].
path
)
console
.
log
(
'routers.accessedRoutes[0].children[0].path'
,
routers
.
accessedRoutes
[
0
].
children
[
0
].
path
)
router
.
push
({
path
:
routers
.
accessedRoutes
[
0
].
children
[
0
].
path
})
//
router.push({ path: routers.accessedRoutes[0].children[0].path })
next
()
//
next()
// next({ path: routers.accessedRoutes[0].children[0].path, replace: true }
)
console
.
log
(
'tototo'
,
to
)
//
router.addRoutes(routers.accessedRoutes) // 动态添加可访问路由表
router
.
addRoutes
(
routers
.
accessedRoutes
)
// 动态添加可访问路由表
// next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
// next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
next
({
path
:
routers
.
accessedRoutes
[
0
].
children
[
0
].
path
,
replace
:
true
})
// 测试 默认静态页面
// 测试 默认静态页面
// store.dispatch('permission/generateRoutes', { roles }).then(accessRoutes => {
// store.dispatch('permission/generateRoutes', { roles }).then(accessRoutes => {
// 根据roles权限生成可访问的路由表
// 根据roles权限生成可访问的路由表
...
...
src/store/modules/permission.js
View file @
b011dfcc
...
@@ -33,6 +33,7 @@ const permission = {
...
@@ -33,6 +33,7 @@ const permission = {
}
}
if
(
accessedRoutes
[
0
])
{
if
(
accessedRoutes
[
0
])
{
const
firstChild
=
getFirstChild
(
accessedRoutes
[
0
])
const
firstChild
=
getFirstChild
(
accessedRoutes
[
0
])
console
.
log
(
'firstChild'
,
firstChild
)
accessedRoutes
.
push
({
path
:
'*'
,
redirect
:
'/404'
,
hidden
:
true
})
accessedRoutes
.
push
({
path
:
'*'
,
redirect
:
'/404'
,
hidden
:
true
})
accessedRoutes
.
push
({
path
:
'/'
,
redirect
:
firstChild
,
hidden
:
true
})
accessedRoutes
.
push
({
path
:
'/'
,
redirect
:
firstChild
,
hidden
:
true
})
commit
(
'SET_ROUTES'
,
accessedRoutes
)
commit
(
'SET_ROUTES'
,
accessedRoutes
)
...
...
src/views/login/login.vue
View file @
b011dfcc
...
@@ -149,7 +149,7 @@ export default {
...
@@ -149,7 +149,7 @@ export default {
// this.$router.push({ path: `http://main.court.com${this.redirect || "/"}` });
// this.$router.push({ path: `http://main.court.com${this.redirect || "/"}` });
this
.
loading
=
false
this
.
loading
=
false
// this.$router.push('/welcome')
// this.$router.push('/welcome')
this
.
$router
.
push
(
'/
Home
'
)
this
.
$router
.
push
(
'/
test
'
)
this
.
$store
.
commit
(
'SET_NAME'
,
res
.
data
.
user
.
username
)
this
.
$store
.
commit
(
'SET_NAME'
,
res
.
data
.
user
.
username
)
})
})
.
catch
(()
=>
{
.
catch
(()
=>
{
...
...
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