update element-ui && refactor sidebar.css

This commit is contained in:
Pan 2018-03-30 16:41:35 +08:00
parent d0eebf83c4
commit 4c48c52f71
4 changed files with 41 additions and 56 deletions

View File

@ -18,7 +18,7 @@
"codemirror": "5.32.0", "codemirror": "5.32.0",
"dropzone": "5.2.0", "dropzone": "5.2.0",
"echarts": "3.8.5", "echarts": "3.8.5",
"element-ui": "2.0.8", "element-ui": "2.3.2",
"file-saver": "1.3.3", "file-saver": "1.3.3",
"font-awesome": "4.7.0", "font-awesome": "4.7.0",
"js-cookie": "2.2.0", "js-cookie": "2.2.0",

View File

@ -2,18 +2,21 @@
// 主体区域 // 主体区域
.main-container { .main-container {
min-height: 100%; min-height: 100%;
transition: margin-left 0.28s; transition: margin-left .28s;
margin-left: 180px; margin-left: 180px;
} // 侧边栏 } // 侧边栏
.sidebar-container { .sidebar-container {
transition: width 0.28s; transition: width .28s;
// background: red;
width: 180px !important; width: 180px !important;
height: 100%; height: 100%;
position: fixed; position: fixed;
font-size: 0px;
top: 0; top: 0;
bottom: 0; bottom: 0;
left: 0; left: 0;
z-index: 1001; z-index: 1001;
overflow: hidden;
a { a {
display: inline-block; display: inline-block;
width: 100%; width: 100%;
@ -23,67 +26,37 @@
} }
.el-menu { .el-menu {
border: none; border: none;
width: 100%; width: 100% !important;
} }
} }
.hideSidebar { .hideSidebar {
.sidebar-container,.sidebar-container .el-menu { .sidebar-container {
width: 36px !important; width: 36px !important;
// overflow: inherit;
} }
.main-container { .main-container {
margin-left: 36px; margin-left: 36px;
} }
}
.hideSidebar {
.submenu-title-noDropdown { .submenu-title-noDropdown {
padding-left: 10px !important; padding-left: 10px !important;
position: relative; position: relative;
span { .el-tooltip {
height: 0; padding: 0 10px !important;
width: 0;
overflow: hidden;
visibility: hidden;
transition: opacity .3s cubic-bezier(.55, 0, .1, 1);
opacity: 0;
display: inline-block;
}
&:hover {
span {
display: block;
border-radius: 3px;
z-index: 1002;
width: 140px;
height: 56px;
visibility: visible;
position: absolute;
right: -145px;
text-align: left;
text-indent: 20px;
top: 0px;
background-color: $subMenuBg!important;
opacity: 1;
}
} }
} }
.el-submenu { .el-submenu {
&>.el-submenu__title { &>.el-submenu__title {
padding-left: 10px !important; padding-left: 10px !important;
&>span { &>span {
display: none; height: 0;
width: 0;
overflow: hidden;
visibility: hidden;
display: inline-block;
} }
.el-submenu__icon-arrow { .el-submenu__icon-arrow {
display: none; display: none;
} }
} }
.nest-menu {
.el-submenu__icon-arrow {
display: block!important;
}
span {
display: inline-block!important;
}
}
} }
} }
.nest-menu .el-submenu>.el-submenu__title, .nest-menu .el-submenu>.el-submenu__title,
@ -98,3 +71,4 @@
min-width: 180px !important; min-width: 180px !important;
} }
} }

View File

@ -2,17 +2,18 @@
<div class="menu-wrapper"> <div class="menu-wrapper">
<template v-for="item in routes" v-if="!item.hidden&&item.children"> <template v-for="item in routes" v-if="!item.hidden&&item.children">
<router-link v-if="hasOneShowingChildren(item.children) && !item.children[0].children&&!item.alwaysShow" :to="item.path+'/'+item.children[0].path" :key="item.children[0].name"> <router-link v-if="hasOneShowingChildren(item.children) && !item.children[0].children&&!item.alwaysShow" :to="item.path+'/'+item.children[0].path"
:key="item.children[0].name">
<el-menu-item :index="item.path+'/'+item.children[0].path" :class="{'submenu-title-noDropdown':!isNest}"> <el-menu-item :index="item.path+'/'+item.children[0].path" :class="{'submenu-title-noDropdown':!isNest}">
<svg-icon v-if="item.children[0].meta&&item.children[0].meta.icon" :icon-class="item.children[0].meta.icon"></svg-icon> <svg-icon v-if="item.children[0].meta&&item.children[0].meta.icon" :icon-class="item.children[0].meta.icon"></svg-icon>
<span v-if="item.children[0].meta&&item.children[0].meta.title">{{generateTitle(item.children[0].meta.title)}}</span> <span v-if="item.children[0].meta&&item.children[0].meta.title" slot="title">{{generateTitle(item.children[0].meta.title)}}</span>
</el-menu-item> </el-menu-item>
</router-link> </router-link>
<el-submenu v-else :index="item.name||item.path" :key="item.name"> <el-submenu v-else :index="item.name||item.path" :key="item.name">
<template slot="title"> <template slot="title">
<svg-icon v-if="item.meta&&item.meta.icon" :icon-class="item.meta.icon"></svg-icon> <svg-icon v-if="item.meta&&item.meta.icon" :icon-class="item.meta.icon"></svg-icon>
<span v-if="item.meta&&item.meta.title">{{generateTitle(item.meta.title)}}</span> <span v-if="item.meta&&item.meta.title" slot="title">{{generateTitle(item.meta.title)}}</span>
</template> </template>
<template v-for="child in item.children" v-if="!child.hidden"> <template v-for="child in item.children" v-if="!child.hidden">
@ -21,7 +22,7 @@
<router-link v-else :to="item.path+'/'+child.path" :key="child.name"> <router-link v-else :to="item.path+'/'+child.path" :key="child.name">
<el-menu-item :index="item.path+'/'+child.path"> <el-menu-item :index="item.path+'/'+child.path">
<svg-icon v-if="child.meta&&child.meta.icon" :icon-class="child.meta.icon"></svg-icon> <svg-icon v-if="child.meta&&child.meta.icon" :icon-class="child.meta.icon"></svg-icon>
<span v-if="child.meta&&child.meta.title">{{generateTitle(child.meta.title)}}</span> <span v-if="child.meta&&child.meta.title" slot="title">{{generateTitle(child.meta.title)}}</span>
</el-menu-item> </el-menu-item>
</router-link> </router-link>
</template> </template>

View File

@ -1,11 +1,21 @@
<template> <template>
<scroll-bar> <scroll-bar>
<el-menu mode="vertical" :default-active="$route.path" :collapse="isCollapse" background-color="#304156" text-color="#bfcbd9" active-text-color="#409EFF"> <el-menu
mode="vertical"
:collapse-transition="false"
:show-timeout="200"
:default-active="$route.path"
:collapse="isCollapse"
background-color="#304156"
text-color="#bfcbd9"
active-text-color="#409EFF"
>
<sidebar-item :routes="permission_routers"></sidebar-item> <sidebar-item :routes="permission_routers"></sidebar-item>
</el-menu> </el-menu>
</scroll-bar> </scroll-bar>
</template> </template>
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import SidebarItem from './SidebarItem' import SidebarItem from './SidebarItem'