Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
test_platform_web
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
Wallen姚文辉
test_platform_web
Commits
3268c1d6
Commit
3268c1d6
authored
May 28, 2024
by
Wallen姚文辉
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复不存在路径会无限循环的问题
parent
7a630bd7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
7 deletions
+9
-7
main.js
src/main.js
+9
-7
No files found.
src/main.js
View file @
3268c1d6
...
@@ -90,10 +90,15 @@ router.beforeEach(async (to, from, next) => {
...
@@ -90,10 +90,15 @@ router.beforeEach(async (to, from, next) => {
}
}
}
}
const
findMenu
=
(
menu
,
each
)
=>
{
const
findMenu
=
(
menu
,
each
)
=>
{
for
(
let
ele
in
menu
)
{
if
(
ele
.
router
==
each
)
return
true
menu
.
forEach
(
element
=>
{
if
(
ele
.
children
)
return
findMenu
(
ele
.
children
,
each
)
if
(
element
.
router
==
each
&&
each
)
return
true
}
if
(
element
.
children
&&
findMenu
(
element
.
children
))
return
true
});
// for (let ele of menu) {
// if (ele.router == each) return true
// if (ele.children) return findMenu(ele.children, each)
// }
}
}
if
(
to
.
path
==
'/login'
)
return
next
();
if
(
to
.
path
==
'/login'
)
return
next
();
if
(
localStorage
.
getItem
(
'token'
))
{
if
(
localStorage
.
getItem
(
'token'
))
{
...
@@ -107,8 +112,6 @@ router.beforeEach(async (to, from, next) => {
...
@@ -107,8 +112,6 @@ router.beforeEach(async (to, from, next) => {
const
menu
=
userinfo
.
menu
const
menu
=
userinfo
.
menu
if
(
findMenu
(
menu
,
to
.
name
)
&&
!
router
.
hasRoute
(
to
.
name
))
{
if
(
findMenu
(
menu
,
to
.
name
)
&&
!
router
.
hasRoute
(
to
.
name
))
{
a
(
menu
)
a
(
menu
)
// console.info(router.getRoutes())
console
.
info
(
to
)
return
next
(
to
)
return
next
(
to
)
}
}
return
next
()
return
next
()
...
@@ -123,7 +126,6 @@ function request(method, url, data, apply, successFun = () => { }, failFun = ()
...
@@ -123,7 +126,6 @@ function request(method, url, data, apply, successFun = () => { }, failFun = ()
if
(
method
!=
"get"
&&
apply
)
apply
.
$Message
.
success
(
data
.
message
);
if
(
method
!=
"get"
&&
apply
)
apply
.
$Message
.
success
(
data
.
message
);
successFun
(
res
.
data
)
successFun
(
res
.
data
)
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
console
.
info
(
error
)
try
{
try
{
if
(
error
.
response
.
data
.
code
==
401
)
{
if
(
error
.
response
.
data
.
code
==
401
)
{
apply
.
$Message
.
error
(
error
.
response
.
data
.
message
);
apply
.
$Message
.
error
(
error
.
response
.
data
.
message
);
...
...
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