|
@@ -42,25 +42,35 @@ function getFirstMenu(routes) {
|
|
|
let firstMenu = null
|
|
|
routes.forEach(item => {
|
|
|
if(!firstMenu && item.children?.length > 0) {
|
|
|
- item.children.forEach(child => {
|
|
|
- if(!firstMenu && child.children?.length > 0) {
|
|
|
- child.children.forEach(sChild => {
|
|
|
- if(!firstMenu && !sChild.hidden) {
|
|
|
- firstMenu = child.path + '/' + sChild.path
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- if(!firstMenu && !child.hidden) {
|
|
|
- firstMenu = item.path + '/' + child.path
|
|
|
- }
|
|
|
+ firstMenu = pathErgodic(item)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return firstMenu
|
|
|
+}
|
|
|
+
|
|
|
+function pathErgodic(item) {
|
|
|
+ let firstMenu = null
|
|
|
+ item.children.forEach(i => {
|
|
|
+ if(!firstMenu && i.children?.length > 0) {
|
|
|
+ firstMenu = pathErgodic(i)
|
|
|
+ } else {
|
|
|
+ if(!firstMenu && checkPathUrl(i.path)) {
|
|
|
+ firstMenu = i.path
|
|
|
+ } else {
|
|
|
+ if(!firstMenu && !i.hidden) {
|
|
|
+ firstMenu = item.path + '/' + i.path
|
|
|
}
|
|
|
- })
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
- console.log(firstMenu)
|
|
|
return firstMenu
|
|
|
}
|
|
|
|
|
|
+// 判断path有没有带/,并且是第一个位置
|
|
|
+function checkPathUrl(path) {
|
|
|
+ return path.indexOf('/') === 0 ? true : false
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
router.beforeEach(async (to, from, next) => {
|
|
|
// from.query = to.query
|