@@ -32,7 +32,7 @@ import PageFooter from './footer/PageFooter'
import Drawer from '../components/tool/Drawer'
import SideMenu from '../components/menu/SideMenu'
import Setting from '../components/setting/Setting'
-import {mapState, mapMutations} from 'vuex'
+import {mapState, mapMutations, mapGetters} from 'vuex'
const minHeight = window.innerHeight - 64 - 24 - 122
@@ -46,30 +46,61 @@ export default {
showSetting: false
}
},
+ watch: {
+ $route(val) {
+ this.setActivated(val)
+ },
+ layout() {
+ this.setActivated(this.$route)
+ }
+ },
computed: {
...mapState('setting', ['isMobile', 'theme', 'layout', 'footerLinks', 'copyright', 'fixedHeader', 'fixedSideBar',
'hideSetting', 'menuData']),
+ ...mapGetters('setting', ['firstMenu', 'subMenu']),
sideMenuWidth() {
return this.collapsed ? '80px' : '256px'
},
headerStyle() {
- let width = (this.fixedHeader && this.layout == 'side' && !this.isMobile) ? `calc(100% - ${this.sideMenuWidth})` : '100%'
+ let width = (this.fixedHeader && this.layout !== 'head' && !this.isMobile) ? `calc(100% - ${this.sideMenuWidth})` : '100%'
let position = this.fixedHeader ? 'fixed' : 'static'
let transition = this.fixedHeader ? 'transition: width 0.2s' : ''
return `width: ${width}; position: ${position}; ${transition}`
+ },
+ headMenuData() {
+ const {layout, menuData, firstMenu} = this
+ return layout === 'mix' ? firstMenu : menuData
+ },
+ sideMenuData() {
+ const {layout, menuData, subMenu} = this
+ return layout === 'mix' ? subMenu : menuData
}
},
methods: {
- ...mapMutations('setting', ['correctPageMinHeight']),
+ ...mapMutations('setting', ['correctPageMinHeight', 'setActivatedFirst']),
toggleCollapse () {
this.collapsed = !this.collapsed
},
onMenuSelect () {
this.toggleCollapse()
},
+ setActivated(route) {
+ if (this.layout === 'mix') {
+ let matched = route.matched
+ matched = matched.slice(0, matched.length - 1)
+ const {firstMenu} = this
+ for (let menu of firstMenu) {
+ if (matched.findIndex(item => item.path === menu.fullPath) !== -1) {
+ this.setActivatedFirst(menu.fullPath)
+ break
+ }
+ }
+ }
+ }
},
created() {
this.correctPageMinHeight(minHeight - 1)
+ this.setActivated(this.$route)
},
beforeDestroy() {
this.correctPageMinHeight(-minHeight + 1)
diff --git a/src/layouts/header/AdminHeader.vue b/src/layouts/header/AdminHeader.vue
index b320432..a65b0ad 100644
--- a/src/layouts/header/AdminHeader.vue
+++ b/src/layouts/header/AdminHeader.vue
@@ -6,12 +6,12 @@
{{systemName}}
-
-