Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
RuoYi Vue
Commits
c43f9bc3
Commit
c43f9bc3
authored
Jul 24, 2021
by
RuoYi
Browse files
顶部菜单排除隐藏的默认路由
parent
46b43b1b
Changes
2
Hide whitespace changes
Inline
Side-by-side
ruoyi-ui/src/components/TopNav/index.vue
View file @
c43f9bc3
...
@@ -87,7 +87,7 @@ export default {
...
@@ -87,7 +87,7 @@ export default {
// 默认激活的菜单
// 默认激活的菜单
activeMenu
()
{
activeMenu
()
{
const
path
=
this
.
$route
.
path
;
const
path
=
this
.
$route
.
path
;
let
activePath
=
this
.
routers
[
0
].
path
;
let
activePath
=
this
.
defaultRouter
()
;
if
(
path
.
lastIndexOf
(
"
/
"
)
>
0
)
{
if
(
path
.
lastIndexOf
(
"
/
"
)
>
0
)
{
const
tmpPath
=
path
.
substring
(
1
,
path
.
length
);
const
tmpPath
=
path
.
substring
(
1
,
path
.
length
);
activePath
=
"
/
"
+
tmpPath
.
substring
(
0
,
tmpPath
.
indexOf
(
"
/
"
));
activePath
=
"
/
"
+
tmpPath
.
substring
(
0
,
tmpPath
.
indexOf
(
"
/
"
));
...
@@ -100,7 +100,7 @@ export default {
...
@@ -100,7 +100,7 @@ export default {
}
}
var
routes
=
this
.
activeRoutes
(
activePath
);
var
routes
=
this
.
activeRoutes
(
activePath
);
if
(
routes
.
length
===
0
)
{
if
(
routes
.
length
===
0
)
{
activePath
=
this
.
currentIndex
||
this
.
routers
[
0
].
path
activePath
=
this
.
currentIndex
||
this
.
defaultRouter
()
this
.
activeRoutes
(
activePath
);
this
.
activeRoutes
(
activePath
);
}
}
return
activePath
;
return
activePath
;
...
@@ -121,6 +121,17 @@ export default {
...
@@ -121,6 +121,17 @@ export default {
const
width
=
document
.
body
.
getBoundingClientRect
().
width
/
3
;
const
width
=
document
.
body
.
getBoundingClientRect
().
width
/
3
;
this
.
visibleNumber
=
parseInt
(
width
/
85
);
this
.
visibleNumber
=
parseInt
(
width
/
85
);
},
},
// 默认激活的路由
defaultRouter
()
{
let
router
;
Object
.
keys
(
this
.
routers
).
some
((
key
)
=>
{
if
(
!
this
.
routers
[
key
].
hidden
)
{
router
=
this
.
routers
[
key
].
path
;
return
true
;
}
});
return
router
;
},
// 菜单选择事件
// 菜单选择事件
handleSelect
(
key
,
keyPath
)
{
handleSelect
(
key
,
keyPath
)
{
this
.
currentIndex
=
key
;
this
.
currentIndex
=
key
;
...
...
ruoyi-ui/src/router/index.js
View file @
c43f9bc3
...
@@ -5,8 +5,6 @@ Vue.use(Router)
...
@@ -5,8 +5,6 @@ Vue.use(Router)
/* Layout */
/* Layout */
import
Layout
from
'
@/layout
'
import
Layout
from
'
@/layout
'
import
ParentView
from
'
@/components/ParentView
'
;
import
InnerLink
from
'
@/layout/components/InnerLink
'
/**
/**
* Note: 路由配置项
* Note: 路由配置项
...
...
Write
Preview
Supports
Markdown
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