|
@@ -70,6 +70,36 @@ import SideMenu from '@/components/Menu/SideMenu'
|
|
|
import GlobalHeader from '@/components/GlobalHeader'
|
|
|
import GlobalFooter from '@/components/GlobalFooter'
|
|
|
import SettingDrawer from '@/components/SettingDrawer'
|
|
|
+import cloneDeep from 'lodash.clonedeep'
|
|
|
+
|
|
|
+function convertRoutes (nodes) {
|
|
|
+ if (!nodes) return null
|
|
|
+
|
|
|
+ nodes = cloneDeep(nodes)
|
|
|
+
|
|
|
+ let queue = Array.isArray(nodes) ? nodes.concat() : [nodes]
|
|
|
+
|
|
|
+ while (queue.length) {
|
|
|
+ const levelSize = queue.length
|
|
|
+
|
|
|
+ for (let i = 0; i < levelSize; i++) {
|
|
|
+ const node = queue.shift()
|
|
|
+
|
|
|
+ if (!node.children || !node.children.length) continue
|
|
|
+
|
|
|
+ node.children.forEach(child => {
|
|
|
+ // 转化相对路径
|
|
|
+ if (child.path[0] !== '/') {
|
|
|
+ child.path = node.path.replace(/(\w*)[/]*$/, `$1/${child.path}`)
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ queue = queue.concat(node.children)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return nodes
|
|
|
+}
|
|
|
|
|
|
export default {
|
|
|
name: 'BasicLayout',
|
|
@@ -109,7 +139,8 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
created () {
|
|
|
- this.menus = this.mainMenu.find(item => item.path === '/').children
|
|
|
+ const routes = convertRoutes(this.mainMenu.find(item => item.path === '/'))
|
|
|
+ this.menus = (routes && routes.children) || []
|
|
|
this.collapsed = !this.sidebarOpened
|
|
|
},
|
|
|
mounted () {
|