Commit 6810631f by liimin

4级菜单及样式优化

1 parent 6399a7da
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
"gltracker": "^0.1.3", "gltracker": "^0.1.3",
"md5": "^2.3.0", "md5": "^2.3.0",
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
"qiankun": "^2.10.5", "qiankun": "^2.10.13",
"vue": "2.6.11", "vue": "2.6.11",
"vue-router": "^3.5.3", "vue-router": "^3.5.3",
"vuex": "^3.4.0" "vuex": "^3.4.0"
...@@ -9046,9 +9046,9 @@ ...@@ -9046,9 +9046,9 @@
} }
}, },
"node_modules/import-html-entry": { "node_modules/import-html-entry": {
"version": "1.14.6", "version": "1.15.1",
"resolved": "https://registry.npmjs.org/import-html-entry/-/import-html-entry-1.14.6.tgz", "resolved": "https://registry.npmjs.org/import-html-entry/-/import-html-entry-1.15.1.tgz",
"integrity": "sha512-5MQkbwIr8n/bXOoE05M5/Nm0lnHO46vnb3D6svSvtVwpDqwhd/X14zjLcU31QWZ6gL8rUXNzj6vKHx4yOUL6gQ==", "integrity": "sha512-flVVS3lQTaHUUEF/zByio0WHdJRMNwT/1sI48/ps9VVGWNn+oE1wuX+fBRZkXLKAeggVVmfU41MpgNnZ7I9nRg==",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.7.2" "@babel/runtime": "^7.7.2"
} }
...@@ -15004,12 +15004,12 @@ ...@@ -15004,12 +15004,12 @@
} }
}, },
"node_modules/qiankun": { "node_modules/qiankun": {
"version": "2.10.5", "version": "2.10.13",
"resolved": "https://registry.npmjs.org/qiankun/-/qiankun-2.10.5.tgz", "resolved": "https://registry.npmjs.org/qiankun/-/qiankun-2.10.13.tgz",
"integrity": "sha512-mNbneqQzdKXpgB1K/mCO3MIXsdXwzcvxU07cUQCSljeyga3LWlI9L+clirmoaj7+UK6tylhhVQ55RyFJngh3ZQ==", "integrity": "sha512-US861R2do2DMCU/BT1TEa3ccFHfCJtcu9Qs7Ytxax8sLNtPQLZpzBW3Itt9XjhBwL8q4F6nMg8WzYl/qczGT4Q==",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.10.5", "@babel/runtime": "^7.10.5",
"import-html-entry": "^1.14.5", "import-html-entry": "^1.14.6",
"lodash": "^4.17.11", "lodash": "^4.17.11",
"single-spa": "^5.9.2" "single-spa": "^5.9.2"
} }
...@@ -16318,9 +16318,9 @@ ...@@ -16318,9 +16318,9 @@
"dev": true "dev": true
}, },
"node_modules/single-spa": { "node_modules/single-spa": {
"version": "5.9.4", "version": "5.9.5",
"resolved": "https://registry.npmjs.org/single-spa/-/single-spa-5.9.4.tgz", "resolved": "https://registry.npmjs.org/single-spa/-/single-spa-5.9.5.tgz",
"integrity": "sha512-QkEoh0AzGuU82qnbUUk0ydF78QbU5wMKqKKJn7uUQfBiOYlRQEfIOpLM4m23Sab+kTOLI1kbYhYeiQ7fX5KVVw==" "integrity": "sha512-9SQdmsyz4HSP+3gs6PJzhkaMEg+6zTlu9oxIghnwUX3eq+ajq4ft5egl0iyR55LAmO/UwvU8NgIWs/ZyQMa6dw=="
}, },
"node_modules/sirv": { "node_modules/sirv": {
"version": "1.0.19", "version": "1.0.19",
...@@ -26919,9 +26919,9 @@ ...@@ -26919,9 +26919,9 @@
} }
}, },
"import-html-entry": { "import-html-entry": {
"version": "1.14.6", "version": "1.15.1",
"resolved": "https://registry.npmjs.org/import-html-entry/-/import-html-entry-1.14.6.tgz", "resolved": "https://registry.npmjs.org/import-html-entry/-/import-html-entry-1.15.1.tgz",
"integrity": "sha512-5MQkbwIr8n/bXOoE05M5/Nm0lnHO46vnb3D6svSvtVwpDqwhd/X14zjLcU31QWZ6gL8rUXNzj6vKHx4yOUL6gQ==", "integrity": "sha512-flVVS3lQTaHUUEF/zByio0WHdJRMNwT/1sI48/ps9VVGWNn+oE1wuX+fBRZkXLKAeggVVmfU41MpgNnZ7I9nRg==",
"requires": { "requires": {
"@babel/runtime": "^7.7.2" "@babel/runtime": "^7.7.2"
} }
...@@ -31562,12 +31562,12 @@ ...@@ -31562,12 +31562,12 @@
"dev": true "dev": true
}, },
"qiankun": { "qiankun": {
"version": "2.10.5", "version": "2.10.13",
"resolved": "https://registry.npmjs.org/qiankun/-/qiankun-2.10.5.tgz", "resolved": "https://registry.npmjs.org/qiankun/-/qiankun-2.10.13.tgz",
"integrity": "sha512-mNbneqQzdKXpgB1K/mCO3MIXsdXwzcvxU07cUQCSljeyga3LWlI9L+clirmoaj7+UK6tylhhVQ55RyFJngh3ZQ==", "integrity": "sha512-US861R2do2DMCU/BT1TEa3ccFHfCJtcu9Qs7Ytxax8sLNtPQLZpzBW3Itt9XjhBwL8q4F6nMg8WzYl/qczGT4Q==",
"requires": { "requires": {
"@babel/runtime": "^7.10.5", "@babel/runtime": "^7.10.5",
"import-html-entry": "^1.14.5", "import-html-entry": "^1.14.6",
"lodash": "^4.17.11", "lodash": "^4.17.11",
"single-spa": "^5.9.2" "single-spa": "^5.9.2"
} }
...@@ -32619,9 +32619,9 @@ ...@@ -32619,9 +32619,9 @@
} }
}, },
"single-spa": { "single-spa": {
"version": "5.9.4", "version": "5.9.5",
"resolved": "https://registry.npmjs.org/single-spa/-/single-spa-5.9.4.tgz", "resolved": "https://registry.npmjs.org/single-spa/-/single-spa-5.9.5.tgz",
"integrity": "sha512-QkEoh0AzGuU82qnbUUk0ydF78QbU5wMKqKKJn7uUQfBiOYlRQEfIOpLM4m23Sab+kTOLI1kbYhYeiQ7fX5KVVw==" "integrity": "sha512-9SQdmsyz4HSP+3gs6PJzhkaMEg+6zTlu9oxIghnwUX3eq+ajq4ft5egl0iyR55LAmO/UwvU8NgIWs/ZyQMa6dw=="
}, },
"sirv": { "sirv": {
"version": "1.0.19", "version": "1.0.19",
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
"gltracker": "^0.1.3", "gltracker": "^0.1.3",
"md5": "^2.3.0", "md5": "^2.3.0",
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
"qiankun": "^2.10.5", "qiankun": "^2.10.13",
"vue": "2.6.11", "vue": "2.6.11",
"vue-router": "^3.5.3", "vue-router": "^3.5.3",
"vuex": "^3.4.0" "vuex": "^3.4.0"
......
...@@ -36,7 +36,7 @@ export default { ...@@ -36,7 +36,7 @@ export default {
// 统一边距 begin // 统一边距 begin
#app { #app {
background-color: transparent !important; background-color: transparent !important;
padding: 16px $left !important; padding: 8px $left !important;
margin: 0 !important; margin: 0 !important;
position: relative !important; position: relative !important;
} }
......
...@@ -17,9 +17,9 @@ export default { ...@@ -17,9 +17,9 @@ export default {
name: 'GLBreadcrumb2', name: 'GLBreadcrumb2',
computed: { computed: {
page() { page() {
const { id, hidden, title: pageTitle = '', name } = this.app.currentPage || {} const { id, hidden, title: pageTitle = '' } = this.app.currentPage || {}
const isShowBack = id?.split('-').length > 2 && hidden const isShowBack = id?.split('-').length > 2 && hidden
const title = name === 'HomeHomeIndex' ? '首页' : decodeURI(pageTitle) const title = decodeURI(pageTitle)
return { isShowBack, title } return { isShowBack, title }
}, },
...mapGetters(['app', 'auth']) ...mapGetters(['app', 'auth'])
......
<template> <template>
<div class="com-left-side-menu-lv2"> <div class="com-left-side-menu-lv2">
<GLScroll class="com-left-side-menu-lv2-scroll-y"> <GLScroll class="com-left-side-menu-lv2-scroll-y">
<!-- <div class="menu-wrap"> -->
<el-menu class="flex-1 none-border" background-color="#fff" active-text-color="#409EFF" text-color="#999" :default-openeds="cur.openeds" :default-active="cur.active" :collapse-transition="false"> <el-menu class="flex-1 none-border" background-color="#fff" active-text-color="#409EFF" text-color="#999" :default-openeds="cur.openeds" :default-active="cur.active" :collapse-transition="false">
<LeftSideMenuLv2Item></LeftSideMenuLv2Item> <LeftSideMenuLv2Item></LeftSideMenuLv2Item>
</el-menu> </el-menu>
<!-- </div> -->
</GLScroll> </GLScroll>
</div> </div>
</template> </template>
<script> <script>
import { mapActions, mapGetters } from 'vuex'
import { currentId } from './mixins/index' import { currentId } from './mixins/index'
export default { export default {
name: 'LeftSideMenuLv2', name: 'LeftSideMenuLv2',
...@@ -19,17 +16,14 @@ export default { ...@@ -19,17 +16,14 @@ export default {
inject: ['bus'], inject: ['bus'],
created() { created() {
this.bus.$on('current', this.handleCurrentChange) this.bus.$on('current', this.handleCurrentChange)
this.bus.$on('menuChanged', this.handleMenuChanged) this.bus.$on('menuOpenedsChanged', this.handleMenuOpenedsChanged)
},
computed: {
...mapGetters(['app', 'menu'])
}, },
mounted() { mounted() {
this.handleCurrentChange(this.current) this.handleCurrentChange(this.current)
}, },
beforeDestroy() { beforeDestroy() {
this.bus.$off('current', this.handleCurrentChange) this.bus.$off('current', this.handleCurrentChange)
this.bus.$off('menuChanged', this.handleMenuChanged) this.bus.$off('menuOpenedsChanged', this.handleMenuOpenedsChanged)
}, },
data() { data() {
return { return {
...@@ -40,20 +34,17 @@ export default { ...@@ -40,20 +34,17 @@ export default {
} }
}, },
methods: { methods: {
...mapActions('menu', ['setOpenId', 'setHoverId']),
open(index) {
this.setOpenId(index)
},
close() {
this.setOpenId('')
// this.setHoverId('')
},
handleCurrentChange({ lv1, lv2, lv3 }) { handleCurrentChange({ lv1, lv2, lv3 }) {
this.cur.active = `${lv1}-${lv2}-${lv3}` this.cur.active = `${lv1}-${lv2}-${lv3}`
}, },
handleMenuChanged({ menus, isReload }) { handleMenuOpenedsChanged({ menus }) {
if (isReload) return const _ids = menus.map(({ id, children = [] }) => {
this.cur.openeds = menus.map(({ id }) => id) if (children.noHidden().length) {
return id
}
})
if (this.cur.openeds.toString() == _ids.toString()) return
this.cur.openeds = _ids
} }
} }
} }
...@@ -70,6 +61,7 @@ export default { ...@@ -70,6 +61,7 @@ export default {
// height: 100%; // height: 100%;
/deep/.el-menu { /deep/.el-menu {
height: 100%; height: 100%;
width: calc(#{$menu_width} - #{$menu_width_collapse} -1px);
} }
// } // }
&-scroll-y { &-scroll-y {
...@@ -77,7 +69,6 @@ export default { ...@@ -77,7 +69,6 @@ export default {
margin-bottom: 0 !important ; margin-bottom: 0 !important ;
.el-scrollbar__view { .el-scrollbar__view {
min-height: 52px; min-height: 52px;
width: calc(#{$menu_width} - #{$menu_width_collapse} -1px);
max-height: calc(100vh - #{$logo-height}); max-height: calc(100vh - #{$logo-height});
} }
} }
......
...@@ -53,17 +53,19 @@ export default { ...@@ -53,17 +53,19 @@ export default {
isMenuNoChildren({ children = [] }) { isMenuNoChildren({ children = [] }) {
return children.noHidden().length == 0 return children.noHidden().length == 0
}, },
handleMenuChanged({ menus, isReload = false }) { handleMenuChanged({ menus = [], isReload = false }) {
if (this.menus[0]?.pid == menus[0]?.pid) return
if (isReload) { if (isReload) {
this.reload() this.reload()
return return
} }
this.menus = menus this.menus = menus
this.bus.$emit('menuOpenedsChanged', { menus })
}, },
reload() { reload() {
const { lv1 } = this.current const { lv1 } = this.current
const menus = this.app.menuList.find(({ id }) => id == lv1).children.noHidden() const menus = this.app.menuList.find(({ id }) => id == lv1).children.noHidden()
this.bus.$emit('menuChanged', { menus }) this.handleMenuChanged({ menus })
} }
} }
} }
...@@ -100,15 +102,6 @@ $active-background-color: rgba(88, 80, 255, 0.2) !important; ...@@ -100,15 +102,6 @@ $active-background-color: rgba(88, 80, 255, 0.2) !important;
right: 0; right: 0;
} }
} }
// &.is-opened {
// .el-submenu__title {
// background-color: transparent !important;
// span,
// i {
// color: $main-color !important;
// }
// }
// }
&.is-active { &.is-active {
.el-submenu__title { .el-submenu__title {
background-color: transparent !important; background-color: transparent !important;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<script> <script>
export default { export default {
name: 'LeftSideMenuLv3', name: 'LeftSideMenuLv3',
inject: ['bus'],
props: { props: {
menuItems: { menuItems: {
type: Array, type: Array,
...@@ -16,9 +17,10 @@ export default { ...@@ -16,9 +17,10 @@ export default {
} }
}, },
methods: { methods: {
handleSelect({ path }) { handleSelect({ path, children = [] }) {
if (path) { if (path) {
this.$router.push(path) this.$router.push(path)
this.bus.$emit('menu3Changed', children.noHidden())
} }
} }
} }
......
<template>
<li class="com-left-side-menu-lv3-item">{{ menu3 }}</li>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
name: 'LeftSideMenuLv3Item',
props: {
menu3: {
type: Object,
default: () => {}
}
},
computed: {
...mapGetters(['app', 'menu'])
},
methods: {}
}
</script>
<style lang="scss" scoped>
@import '~@/assets/style/collapse.scss';
.com-left-side-menu-lv3-item {
width: 100%;
min-height: 36px;
background-color: blue;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 16px;
color: #333;
}
</style>
<template>
<div class="com-left-side-right">
<LeftSideMenuNav></LeftSideMenuNav>
</div>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
name: 'LeftSideRight',
computed: {
...mapGetters(['app', 'menu'])
},
methods: {}
}
</script>
<style lang="scss" scoped>
@import '~@/assets/style/collapse.scss';
.com-left-side-right {
flex: 1;
}
</style>
<template>
<div class="scrm-base-mebu-lv4" v-show="nav4 && nav4.length">
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane :name="item.path" v-for="item in nav4" :key="item.id">
<span slot="label" style="padding: 0 10px">{{ item.title }}</span>
</el-tab-pane>
</el-tabs>
</div>
</template>
<script>
import { currentId } from './mixins/index'
export default {
name: 'MenuLv4',
mixins: [currentId],
data() {
return {
activeName: '',
nav4: []
}
},
mounted() {
this.bus.$on('menu3Changed', this.onMenu4Changed)
this.onLoad()
},
beforeDestroy() {
this.bus.$off('menu3Changed', this.onMenu4Changed)
},
methods: {
handleClick(item) {
this.$router.push(item.name)
},
setActive(activeId = '', nav4 = []) {
const sub = this.find(activeId)
if (sub) {
this.nav4 = nav4
this.$nextTick(() => (this.activeName = sub.path))
}
},
find(id) {
return this.app.flatten.find(item => item.id == id)
},
onMenu4Changed(menus = []) {
this.setActive(menus[0]?.id, menus)
},
onLoad() {
const [lv1, lv2, lv3, lv4] = this.current
const lv3id = `${lv1}-${lv2}-${lv3}`
const lv4id = `${lv3id}-${lv4}`
const sub = this.find(lv3id).children
if (sub?.length) {
const nav4 = sub.noHidden()
this.setActive(lv4id, nav4)
}
}
}
}
</script>
<style lang="scss" scoped>
@import '~@/assets/style/mixins.scss';
.scrm-base-mebu-lv4 {
// transform: translateY(-5px);
@include leftpadding;
/deep/.el-tabs {
&__nav-wrap {
&::after {
height: 1px;
// width: calc(100% - #{$left});
}
}
&__header {
margin: 4px 0 1px;
}
&__item {
height: 42px !important;
// line-height: 10px !important;
&.is-active,
&:hover {
color: $main-color;
font-weight: 600;
}
font-weight: 400;
font-size: 16px;
color: #717171;
height: 36px;
line-height: 36px;
}
&__active-bar {
background-color: $main-color;
}
}
}
</style>
...@@ -7,6 +7,7 @@ export const currentId = { ...@@ -7,6 +7,7 @@ export const currentId = {
if (this.app.currentPage) { if (this.app.currentPage) {
const [lv1, lv2, lv3, lv4] = this.app.currentPage.id.split('-') const [lv1, lv2, lv3, lv4] = this.app.currentPage.id.split('-')
Object.assign(_current, { lv1, lv2, lv3, lv4 }) Object.assign(_current, { lv1, lv2, lv3, lv4 })
this.bus?.$emit('current', _current)
} }
return _current return _current
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<el-header> <el-header>
<div class="header-wrap"> <div class="header-wrap">
<NavMenu></NavMenu> <NavMenu></NavMenu>
<SubNav></SubNav> <MenuLv4></MenuLv4>
</div> </div>
</el-header> </el-header>
<el-main> <el-main>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!