diff --git a/src/components/menu/CustomTopMenu.vue b/src/components/menu/CustomTopMenu.vue index e163433..8c8b133 100644 --- a/src/components/menu/CustomTopMenu.vue +++ b/src/components/menu/CustomTopMenu.vue @@ -41,8 +41,15 @@ export default { methods: { onMenuSelect({ key }) { const childPath = this.getChildrenPath(this.menuItems.find(menu => menu.name === key)) - if (key == "abnormal-alarm" || key == "istatistics") { - const selectedKeys = window.sessionStorage.getItem('currMenu') + if (key == "abnormal-alarm" ) { + const selectedKeys = window.sessionStorage.getItem('currMenu_alarm') + if (selectedKeys) { + this.$router.push(selectedKeys) + } else { + this.$router.push(childPath) + } + } else if (key == "istatistics") { + const selectedKeys = window.sessionStorage.getItem('currMenu_web') if (selectedKeys) { this.$router.push(selectedKeys) } else { diff --git a/src/views/abnormalAlarm/RouteView.vue b/src/views/abnormalAlarm/RouteView.vue index e9abe4f..4b80b9b 100644 --- a/src/views/abnormalAlarm/RouteView.vue +++ b/src/views/abnormalAlarm/RouteView.vue @@ -108,7 +108,7 @@ export default { // 将从缓存中取出openKeys // const openKeys = window.sessionStorage.getItem('openKeys') // console.log(openKeys); - const selectedKeys = window.sessionStorage.getItem('currMenu') + const selectedKeys = window.sessionStorage.getItem('currMenu_alarm') if (selectedKeys) { // this.defaultSelectedKeys.push(selectedKeys) this.currSlecteKey.push(selectedKeys) @@ -128,23 +128,23 @@ export default { // this.openKeys = JSON.parse(openKeys) // } }, - watch: { - "$route": { - handler: function (val, oldVal) { - this.currSlecteKey=[] - console.log(val); - this.currSlecteKey.push(val.path) - window.sessionStorage.setItem('currMenu', val.path) - }, - deep:true, - immediate:true - } - }, + // watch: { + // "$route": { + // handler: function (val, oldVal) { + // this.currSlecteKey=[] + // console.log(val); + // this.currSlecteKey.push(val.path) + // window.sessionStorage.setItem('currMenu', val.path) + // }, + // deep:true, + // immediate:true + // } + // }, methods: { // 点击菜单,路由跳转,注意的是当点击MenuItem才会触发此函数 menuClick({ item, key, keyPath }) { this.currSlecteKey =[] - window.sessionStorage.setItem('currMenu', key) + window.sessionStorage.setItem('currMenu_alarm', key) // var parentPath = item._props.parentMenu._props.eventKey; // var parentTitle = parentPath.substring(parentPath.lastIndexOf("/") + 1, parentPath.length) // var par = {"type": "q"}