mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2025-12-12 13:42:50 +00:00
优化菜单收起展开状态
This commit is contained in:
parent
0d25d29c79
commit
d0b5acad68
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cool-admin-vue",
|
"name": "cool-admin-vue",
|
||||||
"version": "3.1.5",
|
"version": "3.1.6",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"serve": "vue-cli-service serve",
|
"serve": "vue-cli-service serve",
|
||||||
"build": "vue-cli-service build",
|
"build": "vue-cli-service build",
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
@select="onSelect"
|
@select="onSelect"
|
||||||
>
|
>
|
||||||
<el-menu-item v-for="(item, index) in list" :index="`${index}`" :key="index">
|
<el-menu-item v-for="(item, index) in list" :index="`${index}`" :key="index">
|
||||||
<icon-svg v-if="item.icon" :name="item.icon"></icon-svg>
|
<icon-svg v-if="item.icon" :name="item.icon" :size="18"></icon-svg>
|
||||||
<span>{{ item.name }}</span>
|
<span>{{ item.name }}</span>
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
</el-menu>
|
</el-menu>
|
||||||
@ -76,6 +76,8 @@ export default {
|
|||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.cl-menu-topbar {
|
.cl-menu-topbar {
|
||||||
|
margin-right: 10px;
|
||||||
|
|
||||||
/deep/.el-menu {
|
/deep/.el-menu {
|
||||||
height: 50px;
|
height: 50px;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
@ -83,12 +85,12 @@ export default {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
.el-menu-item {
|
.el-menu-item {
|
||||||
height: 50px;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background: transparent;
|
height: 50px;
|
||||||
border-bottom: 0;
|
border-bottom: 0;
|
||||||
padding: 0 30px;
|
padding: 0 20px;
|
||||||
|
background: transparent;
|
||||||
|
|
||||||
span {
|
span {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
@ -97,13 +99,10 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
&.is-active {
|
&.is-active {
|
||||||
background: rgba(255, 255, 255, 0.13);
|
|
||||||
color: $color-primary;
|
color: $color-primary;
|
||||||
}
|
}
|
||||||
|
|
||||||
/deep/.icon-svg {
|
/deep/.icon-svg {
|
||||||
height: 18px;
|
|
||||||
width: 18px;
|
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -82,10 +82,8 @@ export default {
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|
||||||
/deep/.el-breadcrumb {
|
/deep/.el-breadcrumb {
|
||||||
margin: 0 10px;
|
|
||||||
|
|
||||||
&__inner {
|
&__inner {
|
||||||
font-size: 12px;
|
font-size: 13px;
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
letter-spacing: 1px;
|
letter-spacing: 1px;
|
||||||
@ -93,8 +91,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
display: none;
|
font-size: 14px;
|
||||||
font-size: 15px;
|
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,26 +1,18 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-scrollbar>
|
<el-scrollbar>
|
||||||
<div class="demo">
|
<div class="demo">
|
||||||
<div class="list">
|
<el-row :gutter="10">
|
||||||
<div
|
<el-col
|
||||||
class="item"
|
v-for="(item, index) in list"
|
||||||
:style="{
|
|
||||||
width: `calc(${100 / cols}% - 10px)`
|
|
||||||
}"
|
|
||||||
:ref="`col-${index + 1}`"
|
|
||||||
v-for="(item, index) in layout"
|
|
||||||
:key="index"
|
:key="index"
|
||||||
|
:xs="24"
|
||||||
|
:sm="12"
|
||||||
|
:md="8"
|
||||||
|
:lg="6"
|
||||||
>
|
>
|
||||||
<transition-group name="fade">
|
<component :is="item"></component>
|
||||||
<component
|
</el-col>
|
||||||
:ref="item2"
|
</el-row>
|
||||||
:is="item2"
|
|
||||||
:key="item2 + index2"
|
|
||||||
v-for="(item2, index2) in item"
|
|
||||||
></component>
|
|
||||||
</transition-group>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
</template>
|
</template>
|
||||||
@ -58,93 +50,16 @@ export default {
|
|||||||
"b-cl-context-menu",
|
"b-cl-context-menu",
|
||||||
"b-error-page",
|
"b-error-page",
|
||||||
"b-cl-editor-quill"
|
"b-cl-editor-quill"
|
||||||
],
|
]
|
||||||
cols: 4,
|
|
||||||
layout: [[], [], [], []]
|
|
||||||
};
|
};
|
||||||
},
|
|
||||||
|
|
||||||
mounted() {
|
|
||||||
const width = document.body.clientWidth;
|
|
||||||
|
|
||||||
if (width < 768) {
|
|
||||||
this.cols = 1;
|
|
||||||
} else if (width < 1000) {
|
|
||||||
this.cols = 2;
|
|
||||||
} else if (width < 1500) {
|
|
||||||
this.cols = 3;
|
|
||||||
} else {
|
|
||||||
this.cols = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.append();
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
getHeight(name) {
|
|
||||||
return this.$refs[name][0].offsetHeight;
|
|
||||||
},
|
|
||||||
|
|
||||||
selectCol() {
|
|
||||||
let arr = new Array(this.cols).fill(1);
|
|
||||||
|
|
||||||
for (let i = 0; i < this.cols; i++) {
|
|
||||||
arr[i] = this.getHeight(`col-${i + 1}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
let min = Math.min.apply(this, arr);
|
|
||||||
|
|
||||||
return arr.indexOf(min);
|
|
||||||
},
|
|
||||||
|
|
||||||
append(index = 0) {
|
|
||||||
const i = this.selectCol();
|
|
||||||
const item = this.list[index];
|
|
||||||
|
|
||||||
if (!item) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.layout[i].push(item);
|
|
||||||
|
|
||||||
this.$nextTick(() => {
|
|
||||||
setTimeout(() => {
|
|
||||||
this.append(index + 1);
|
|
||||||
}, 100);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.fade-enter-active,
|
|
||||||
.fade-leave-active {
|
|
||||||
transition: all 0.5s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.fade-enter,
|
|
||||||
.fade-leave-active {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.demo {
|
.demo {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
.list {
|
|
||||||
margin: 0 -5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.item {
|
|
||||||
width: calc(25% - 10px);
|
|
||||||
margin: 0 5px;
|
|
||||||
float: left;
|
|
||||||
|
|
||||||
&:last-child {
|
|
||||||
margin-right: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.scope {
|
.scope {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
@ -170,6 +85,8 @@ export default {
|
|||||||
|
|
||||||
.c {
|
.c {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
height: 50px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
&._svg {
|
&._svg {
|
||||||
.icon-svg {
|
.icon-svg {
|
||||||
|
|||||||
@ -1,20 +1,25 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="page-layout" :class="{ collapse: menuCollapse }">
|
<div class="page-layout" :class="{ collapse: menuCollapse }">
|
||||||
|
<!-- 遮罩层 -->
|
||||||
<div class="page-layout__mask" @click="COLLAPSE_MENU(true)"></div>
|
<div class="page-layout__mask" @click="COLLAPSE_MENU(true)"></div>
|
||||||
|
|
||||||
<div class="page-layout__left">
|
<div class="page-layout__left">
|
||||||
|
<!-- 侧栏 -->
|
||||||
<slider></slider>
|
<slider></slider>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="page-layout__right">
|
<div class="page-layout__right">
|
||||||
|
<!-- 顶栏 -->
|
||||||
<div class="page-layout__topbar">
|
<div class="page-layout__topbar">
|
||||||
<topbar></topbar>
|
<topbar></topbar>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 页面进程 -->
|
||||||
<div class="page-layout__process" v-if="app.conf.showProcess">
|
<div class="page-layout__process" v-if="app.conf.showProcess">
|
||||||
<cl-process />
|
<cl-process />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 页面视图 -->
|
||||||
<div class="page-layout__container">
|
<div class="page-layout__container">
|
||||||
<div class="page-layout__view">
|
<div class="page-layout__view">
|
||||||
<keep-alive>
|
<keep-alive>
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-topbar">
|
<div class="app-topbar">
|
||||||
<div class="app-topbar__collapse" @click="collapse">
|
<div class="app-topbar__collapse" @click="collapse">
|
||||||
<icon-svg name="icon-menu"></icon-svg>
|
<i :class="[menuCollapse ? 'el-icon-s-unfold' : 'el-icon-s-fold']"></i>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 一级菜单 -->
|
<!-- 一级菜单 -->
|
||||||
@ -97,9 +97,9 @@ export default {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
|
|
||||||
.icon-svg {
|
i {
|
||||||
height: 22px;
|
font-size: 22px;
|
||||||
width: 22px;
|
color: #666;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user