Commit 76e5e020 by liimin

优化

1 parent c0dc17a3
......@@ -8,9 +8,11 @@
<script>
import { mapActions, mapGetters } from 'vuex'
// import { utils } from 'glsx-common'
import { currentId } from './mixins/index'
export default {
name: 'LeftSideMenuLv1Item',
inject: ['bus'],
mixins: [currentId],
props: {
menuData: {
type: Object,
......@@ -28,14 +30,16 @@ export default {
},
methods: {
mouseenter: function () {
if (this.menu.hoverId === this.menu.id) return
this.setHoverId(this.menuData.id)
this.menu.isCollapse && this.bus.$emit('mouseenter', this.$refs['bt' + this.menuData.id], () => this.bus.$emit('menuChanged', { menus: this.menuData.children.noHidden() }))
this.menu.isCollapse && this.bus.$emit('mouseenter', this.$refs['bt' + this.menuData.id], this.emitter)
},
mouseleave: function () {
this.setHoverId('')
},
handleClick() {
!this.menu.isCollapse && this.emitter()
},
emitter() {
this.bus.$emit('menuChanged', { menus: this.menuData.children.noHidden() })
},
...mapActions('menu', ['setHoverId'])
......
......@@ -46,7 +46,7 @@ export default {
},
mounted() {
this.bus.$on('menuChanged', this.handleMenuChanged)
this.reload()
!this.menu.isCollapse && this.reload()
},
beforeDestroy() {
this.bus.$off('menuChanged', this.handleMenuChanged)
......@@ -59,18 +59,18 @@ export default {
return children.noHidden().length == 0
},
handleMenuChanged({ menus = [], isReload = false }) {
const pid1 = this.menus[0]?.id?.split('-')
const pid2 = menus[0]?.id?.split('-')
if (pid1 == pid2) return
if (isReload) {
this.reload()
return
}
// console.log('待修改:'+menus[0]?.title , '当前,'+this.menus[0]?.title);
this.menus = menus
this.bus.$emit('menuOpenedsChanged', { menus })
},
reload() {
const { lv1 } = this.current
const [pid] = this.menus[0]?.id.split('-') || []
if (lv1 == pid) return
const menus = this.app.menuList.find(({ id }) => id == lv1).children.noHidden()
this.handleMenuChanged({ menus })
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!