diff --git a/src/components/layout/GloablLayout.vue b/src/components/layout/GloablLayout.vue index d365217..2404dfc 100644 --- a/src/components/layout/GloablLayout.vue +++ b/src/components/layout/GloablLayout.vue @@ -7,7 +7,6 @@

Vue Ant Pro

- @@ -24,7 +23,6 @@ import ALayout from 'vue-antd-ui/es/layout' import GloablHeader from './GloablHeader' import AIcon from 'vue-antd-ui/es/icon/icon' -import GloablMenu from './GloablMenu' import IMenu from '../menu/menu' const ALayoutSider = ALayout.Sider @@ -38,7 +36,6 @@ let menuData = [] export default { name: 'GloablLayout', components: { - GloablMenu, AIcon, GloablHeader, ALayout, diff --git a/src/components/layout/GloablMenu.vue b/src/components/layout/GloablMenu.vue deleted file mode 100644 index 89b01fa..0000000 --- a/src/components/layout/GloablMenu.vue +++ /dev/null @@ -1,57 +0,0 @@ - - - - - diff --git a/src/components/menu/menu.js b/src/components/menu/menu.js index d335767..e448751 100644 --- a/src/components/menu/menu.js +++ b/src/components/menu/menu.js @@ -44,6 +44,12 @@ export default { default: 'inline' } }, + data () { + return { + rootSubmenuKeys: ['/form', '/list', '/detail', '/exception', '/result'], + openKeys: ['/form'] + } + }, methods: { renderIcon: function (h, icon) { return icon === 'none' ? null @@ -103,6 +109,14 @@ export default { menuArr.push(this2_.renderItem(h, menu, '0', i)) }) return menuArr + }, + onOpenChange (openKeys) { + const latestOpenKey = openKeys.find(key => this.openKeys.indexOf(key) === -1) + if (this.rootSubmenuKeys.indexOf(latestOpenKey) === -1) { + this.openKeys = openKeys + } else { + this.openKeys = latestOpenKey ? [latestOpenKey] : [] + } } }, render (h) { @@ -112,7 +126,11 @@ export default { props: { theme: this.$props.theme, mode: this.$props.mode, - inlineCollapsed: false + inlineCollapsed: false, + openKeys: this.openKeys + }, + on: { + openChange: this.onOpenChange } }, this.renderMenu(h, this.menuData) )