Commit fcfa7c21 by xinla

4.x绿色主题开始

1 parent a22ff4fc
<template> <template>
<div class="logo-container" :class="{ collapse: collapse }">
<transition name="sidebarLogoFade"> <transition name="sidebarLogoFade">
<router-link v-if="collapse" key="collapse" class="sidebar-logo-link" to="/"> <div class="logo-container" :class="{ collapse: collapse }">
<img v-if="logo" :src="logo" class="sidebar-logo" /> <router-link key="collapse" class="sidebar-logo-link" to="/">
<!-- <h1 v-else class="sidebar-title">{{ title }}</h1> -->
</router-link>
<router-link v-else key="expand" class="sidebar-logo-link" to="/">
<img v-if="logo" :src="logo" class="sidebar-logo" /> <img v-if="logo" :src="logo" class="sidebar-logo" />
<!-- <h1 class="sidebar-title">{{ title }}</h1> -->
</router-link> </router-link>
</transition> <i class="el-icon-s-operation"></i>
</div> </div>
</transition>
</template> </template>
<script> <script>
...@@ -25,7 +21,7 @@ export default { ...@@ -25,7 +21,7 @@ export default {
data() { data() {
return { return {
title: process.env.VUE_APP_TITLE, title: process.env.VUE_APP_TITLE,
logo: this.lwConfig.LOGO_TEXT_LIGHT, logo: this.lwConfig.LOGO_TEXT_DARK,
} }
}, },
} }
...@@ -43,14 +39,11 @@ export default { ...@@ -43,14 +39,11 @@ export default {
.logo-container { .logo-container {
position: relative; position: relative;
width: 210px; width: 330px;
text-align: center;
overflow: hidden; overflow: hidden;
display: flex;
align-items: center;
& .sidebar-logo-link { & .sidebar-logo-link {
height: 100%;
width: 100%;
& .sidebar-logo { & .sidebar-logo {
max-height: 44px; max-height: 44px;
max-width: 170px; max-width: 170px;
...@@ -75,5 +68,10 @@ export default { ...@@ -75,5 +68,10 @@ export default {
margin-right: 0px; margin-right: 0px;
} }
} }
.el-icon-s-operation {
color: #333;
font-size: 20px;
}
} }
</style> </style>
...@@ -11,8 +11,8 @@ export default { ...@@ -11,8 +11,8 @@ export default {
props: { props: {
to: { to: {
type: String, type: String,
required: true required: true,
} },
}, },
computed: { computed: {
isExternal() { isExternal() {
...@@ -23,7 +23,7 @@ export default { ...@@ -23,7 +23,7 @@ export default {
return 'a' return 'a'
} }
return 'router-link' return 'router-link'
} },
}, },
methods: { methods: {
linkProps(to) { linkProps(to) {
...@@ -31,13 +31,13 @@ export default { ...@@ -31,13 +31,13 @@ export default {
return { return {
href: to, href: to,
target: '_blank', target: '_blank',
rel: 'noopener' rel: 'noopener',
} }
} }
return { return {
to: to to: to,
}
}
} }
},
},
} }
</script> </script>
<template> <template>
<div v-if="!item.hidden"> <div v-if="!item.hidden">
<template <app-link v-if="isLeafMeu(item)" :to="resolvePath(onlyOneChild.path, onlyOneChild.query)">
v-if=" <el-menu-item v-if="onlyOneChild.meta" :index="resolvePath(onlyOneChild.path)">
hasOneShowingChild(item.children, item) && {{ onlyOneChild.meta.title }}
(!onlyOneChild.children || onlyOneChild.noShowingChildren) &&
(!item.alwaysShow || onlyOneChild.noShowingChildren)
"
>
<app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path, onlyOneChild.query)">
<el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{ 'submenu-title-noDropdown': !isNest }">
<span solt="title">{{ onlyOneChild.meta.title }}</span>
</el-menu-item> </el-menu-item>
</app-link> </app-link>
</template>
<el-submenu v-else ref="subMenu" :index="resolvePath(item.path)" popper-append-to-body> <el-submenu v-else :index="resolvePath(item.path)" popper-append-to-body>
<template slot="title"> <span slot="title" v-if="item.meta">{{ item.meta.title }}</span>
<span solt="title" style="color: #aaa; font-size: 14px;" v-if="item.meta">{{ item.meta.title }}</span>
</template>
<sidebar-item <sidebar-item
v-for="child in item.children" v-for="child in item.children"
:key="child.path" :key="child.path"
:is-nest="true" :is-nest="true"
:item="child" :item="child"
:base-path="resolvePath(child.path)" :base-path="resolvePath(child.path)"
class="nest-menu" class="nest-menu" />
/>
</el-submenu> </el-submenu>
</div> </div>
</template> </template>
<script> <script>
import path from 'path' import path from 'path'
import { isExternal } from '@/utils/validate' import { isExternal } from '@/utils/validate'
import Item from './Item' import Item from './Item'
import AppLink from './Link' import AppLink from './Link'
import FixiOSBug from './FixiOSBug' import FixiOSBug from './FixiOSBug'
export default { export default {
name: 'SidebarItem', name: 'SidebarItem',
components: { Item, AppLink }, components: { Item, AppLink },
mixins: [FixiOSBug], mixins: [FixiOSBug],
...@@ -45,21 +34,22 @@ ...@@ -45,21 +34,22 @@
// route object // route object
item: { item: {
type: Object, type: Object,
required: true required: true,
}, },
isNest: { isNest: {
type: Boolean, type: Boolean,
default: false default: false,
}, },
basePath: { basePath: {
type: String, type: String,
default: '' default: '',
} },
}, },
data() { data() {
this.onlyOneChild = null this.onlyOneChild = null
return {} return {}
}, },
computed() {},
methods: { methods: {
hasOneShowingChild(children, parent) { hasOneShowingChild(children, parent) {
// 菜单叶子,无子路由的 // 菜单叶子,无子路由的
...@@ -79,9 +69,10 @@ ...@@ -79,9 +69,10 @@
}) })
// When there is only one child router, the child router is displayed by default // When there is only one child router, the child router is displayed by default
if (showingChildren.length === 1) { // if (showingChildren.length === 1) {
return true // return true
} // }
// 菜单目录,无子路由的 ;或者有子路由的,且子路由全部不显示的,显示父级 // 菜单目录,无子路由的 ;或者有子路由的,且子路由全部不显示的,显示父级
if (showingChildren.length === 0) { if (showingChildren.length === 0) {
this.onlyOneChild = { ...parent, path: '', noShowingChildren: true } this.onlyOneChild = { ...parent, path: '', noShowingChildren: true }
...@@ -90,6 +81,9 @@ ...@@ -90,6 +81,9 @@
return false return false
}, },
isLeafMeu(item) {
return this.hasOneShowingChild(item.children, item) && (!item.alwaysShow || this.onlyOneChild.noShowingChildren)
},
resolvePath(routePath, routeQuery) { resolvePath(routePath, routeQuery) {
if (isExternal(routePath)) { if (isExternal(routePath)) {
return routePath return routePath
...@@ -105,7 +99,7 @@ ...@@ -105,7 +99,7 @@
return { path: path.resolve(this.basePath, routePath), query: query } return { path: path.resolve(this.basePath, routePath), query: query }
} }
return path.resolve(this.basePath, routePath) return path.resolve(this.basePath, routePath)
} },
} },
} }
</script> </script>
...@@ -4,32 +4,24 @@ ...@@ -4,32 +4,24 @@
<el-menu <el-menu
:default-active="activeMenu" :default-active="activeMenu"
:collapse="isCollapse" :collapse="isCollapse"
:background-color="
settings.sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground
"
:text-color="settings.sideTheme === 'theme-dark' ? variables.menuColor : variables.menuLightColor"
:unique-opened="true" :unique-opened="true"
:active-text-color="settings.theme"
:collapse-transition="false" :collapse-transition="false"
mode="vertical" mode="vertical">
>
<sidebar-item <sidebar-item
v-for="(route, index) in sidebarRouters" v-for="(route, index) in sidebarRouters"
:key="route.path + index" :key="route.path + index"
:item="route" :item="route"
:base-path="route.path" :base-path="route.path" />
/>
</el-menu> </el-menu>
</el-scrollbar> </el-scrollbar>
</div> </div>
</template> </template>
<script> <script>
import { mapGetters, mapState } from 'vuex' import { mapGetters, mapState } from 'vuex'
import SidebarItem from './SidebarItem' import SidebarItem from './SidebarItem'
import variables from '@/styles/variables.scss'
export default { export default {
components: { SidebarItem }, components: { SidebarItem },
computed: { computed: {
...mapState(['settings']), ...mapState(['settings']),
...@@ -45,13 +37,10 @@ ...@@ -45,13 +37,10 @@
} }
return path return path
}, },
variables() {
return variables
},
isCollapse() { isCollapse() {
// return !this.sidebar.opened // return !this.sidebar.opened
return false return false
} },
} },
} }
</script> </script>
<template> <template>
<el-menu :default-active="activeMenu" background-color="transparent" mode="horizontal" @select="handleSelect"> <el-menu :default-active="activeMenu" mode="horizontal" @select="handleSelect">
<template v-for="(item, index) in topMenus"> <el-menu-item v-for="(item, index) in topMenus" :index="item.path" :key="index">{{ item.meta.title }}</el-menu-item>
<el-menu-item :index="item.path" :key="index">{{ item.meta.title }}</el-menu-item>
</template>
<!-- 顶部菜单超出数量折叠 -->
<!-- <el-submenu :style="{'--theme': theme}" :index="currentIndex">
<template slot="title">{{name}}</template>
<template v-for="(item, index) in topMenus">
<el-menu-item :index="item.path" :key="index">
<svg-icon :icon-class="item.meta.icon" /> {{ item.meta.title }}</el-menu-item>
</template>
</el-submenu> -->
</el-menu> </el-menu>
</template> </template>
...@@ -134,20 +123,44 @@ export default { ...@@ -134,20 +123,44 @@ export default {
} }
.el-menu--horizontal > .el-menu-item { .el-menu--horizontal > .el-menu-item {
float: left; float: left;
height: 50px !important; height: 38px !important;
line-height: 50px !important; line-height: 38px !important;
color: #fff !important; color: #1d2129;
// padding: 0 5px !important; border-radius: 8px;
margin: 0 10px !important; font-weight: bold;
} margin: 0 4px !important;
.el-menu-item:hover { border: 0;
background-color: transparent !important; &::after {
content: '';
display: block;
opacity: 0;
position: absolute;
top: 0;
left: 0;
z-index: -1;
width: 100%;
height: 100%;
border-radius: 8px;
transition: opacity 0.3s;
@extend .bglg;
}
&:not(.is-disabled) {
&:hover,
&:focus {
&::after {
opacity: 1;
}
background-color: transparent;
color: #fff;
}
}
} }
.el-menu--horizontal > .el-menu-item.is-active, .el-menu--horizontal > .el-menu-item.is-active,
.el-menu--horizontal > .el-submenu.is-active .el-submenu__title { .el-menu--horizontal > .el-submenu.is-active .el-submenu__title {
border-bottom: 2px solid #fff !important; @extend .bglg;
// color: #303133; color: #fff;
border: 0;
} }
/* submenu item */ /* submenu item */
......
...@@ -22,16 +22,16 @@ ...@@ -22,16 +22,16 @@
</template> </template>
<script> <script>
import RightPanel from '@/components/RightPanel' import RightPanel from '@/components/RightPanel'
import { AppMain, Navbar, Settings, Sidebar, TagsView } from './components' import { AppMain, Navbar, Settings, Sidebar, TagsView } from './components'
import Breadcrumb from './components/Breadcrumb' import Breadcrumb from './components/Breadcrumb'
import Hamburger from './components/Hamburger' import Hamburger from './components/Hamburger'
import CustomerService from './components/CustomerService' import CustomerService from './components/CustomerService'
import ResizeMixin from './mixin/ResizeHandler' import ResizeMixin from './mixin/ResizeHandler'
import { mapState } from 'vuex' import { mapState } from 'vuex'
export default { export default {
name: 'Layout', name: 'Layout',
components: { components: {
Breadcrumb, Breadcrumb,
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
Settings, Settings,
Sidebar, Sidebar,
TagsView, TagsView,
CustomerService CustomerService,
}, },
mixins: [ResizeMixin], mixins: [ResizeMixin],
computed: { computed: {
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
...mapState({ ...mapState({
sidebar: (state) => state.app.sidebar, sidebar: (state) => state.app.sidebar,
device: (state) => state.app.device, device: (state) => state.app.device,
showSettings: (state) => state.settings.showSettings showSettings: (state) => state.settings.showSettings,
// needTagsView: (state) => state.settings.tagsView, // needTagsView: (state) => state.settings.tagsView,
// fixedHeader: (state) => state.settings.fixedHeader, // fixedHeader: (state) => state.settings.fixedHeader,
}), }),
...@@ -66,22 +66,22 @@ ...@@ -66,22 +66,22 @@
openSidebar: this.isSidebar, openSidebar: this.isSidebar,
hideSidebar: !this.isSidebar, hideSidebar: !this.isSidebar,
withoutAnimation: this.sidebar.withoutAnimation, withoutAnimation: this.sidebar.withoutAnimation,
mobile: this.device === 'mobile' mobile: this.device === 'mobile',
}
} }
}, },
},
methods: { methods: {
handleClickOutside() { handleClickOutside() {
this.$store.dispatch('app/closeSideBar', { withoutAnimation: false }) this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
} },
} },
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import '~@/styles/mixin.scss'; @import '~@/styles/mixin.scss';
.app-wrapper { .app-wrapper {
@include clearfix; @include clearfix;
position: relative; position: relative;
height: 100%; height: 100%;
...@@ -98,23 +98,22 @@ ...@@ -98,23 +98,22 @@
// z-index: 99999; // z-index: 99999;
// } // }
.top-wrap { .top-wrap {
height: 58px; height: 64px;
background: $blue;
} }
.main-wrap { .main-wrap {
height: calc(100vh - 58px); height: calc(100vh - 64px);
background: #eee; background: #edf2f9;
.main { .main {
height: 100%; height: 100%;
padding: 10px; // padding: 10px;
display: flex; display: flex;
align-items: stretch; align-items: stretch;
} }
} }
} }
.drawer-bg { .drawer-bg {
background: #000; background: #000;
opacity: 0.3; opacity: 0.3;
width: 100%; width: 100%;
...@@ -122,26 +121,26 @@ ...@@ -122,26 +121,26 @@
height: 100%; height: 100%;
position: absolute; position: absolute;
z-index: 999; z-index: 999;
} }
.fixed-header { .fixed-header {
position: fixed; position: fixed;
top: 0; top: 0;
right: 0; right: 0;
z-index: 9; z-index: 9;
width: calc(100% - #{$sideBarWidth}); width: calc(100% - #{$sideBarWidth});
transition: width 0.28s; transition: width 0.28s;
} }
.hideSidebar .fixed-header { .hideSidebar .fixed-header {
width: calc(100% - 54px); width: calc(100% - 54px);
} }
.mobile .fixed-header { .mobile .fixed-header {
width: 100%; width: 100%;
} }
.hamburger-container { .hamburger-container {
cursor: pointer; cursor: pointer;
transition: background 0.3s; transition: background 0.3s;
-webkit-tap-highlight-color: transparent; -webkit-tap-highlight-color: transparent;
...@@ -149,10 +148,10 @@ ...@@ -149,10 +148,10 @@
&:hover { &:hover {
background: rgba(0, 0, 0, 0.025); background: rgba(0, 0, 0, 0.025);
} }
} }
.slogan { .slogan {
font-size: 22px; font-size: 22px;
color: #999; color: #999;
vertical-align: middle; vertical-align: middle;
} }
</style> </style>
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
**/ **/
/* theme color */ /* theme color */
$--color-primary: #0079de; $--color-primary: #07c160;
$--color-success: #06c160; $--color-success: #07c160;
$--color-warning: #ffcf0e; $--color-warning: #faad14;
$--color-danger: #e74e59; $--color-danger: #eb5e12;
// $--color-info: #fa7216; // $--color-info: #fa7216;
// $--color-info: #1E1E1E; // $--color-info: #1E1E1E;
......
...@@ -105,8 +105,8 @@ aside { ...@@ -105,8 +105,8 @@ aside {
display: block; display: block;
line-height: 32px; line-height: 32px;
font-size: 16px; font-size: 16px;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans',
'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; 'Droid Sans', 'Helvetica Neue', sans-serif;
color: #2c3e50; color: #2c3e50;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
...@@ -464,3 +464,10 @@ aside { ...@@ -464,3 +464,10 @@ aside {
border-right: 1px solid #f1f1f1; border-right: 1px solid #f1f1f1;
} }
} }
.br8 {
border-radius: 8px;
}
.br16 {
border-radius: 16px;
}
...@@ -13,19 +13,13 @@ ...@@ -13,19 +13,13 @@
.sidebar-container { .sidebar-container {
transition: width 0.28s; transition: width 0.28s;
width: $sideBarWidth !important; width: $sideBarWidth !important;
background-color: $menuBg; background-color: #fff;
font-size: 0px; font-size: 0px;
bottom: 0; bottom: 0;
z-index: 1001; z-index: 1001;
overflow: hidden; overflow: hidden;
flex: none; flex: none;
box-shadow: 0px 2px 2px 0px rgba(228, 228, 228, 0.35); box-shadow: 0px 2px 2px 0px rgba(228, 228, 228, 0.35);
border-radius: 10px;
.el-menu-item.is-active {
background-color: $menuActiveBg !important;
border-right: 2px solid #0079de;
}
// reset element-ui css // reset element-ui css
.horizontal-collapse-transition { .horizontal-collapse-transition {
...@@ -54,12 +48,6 @@ ...@@ -54,12 +48,6 @@
display: none; display: none;
} }
a {
display: inline-block;
width: 100%;
overflow: hidden;
}
.svg-icon { .svg-icon {
margin-right: 16px; margin-right: 16px;
} }
...@@ -70,26 +58,44 @@ ...@@ -70,26 +58,44 @@
width: 100% !important; width: 100% !important;
} }
// menu hover // 菜单,目录
.submenu-title-noDropdown, .el-menu-item,
.el-submenu__title { .el-submenu > .el-submenu__title {
margin: 4px auto;
font-weight: 500;
height: 40px;
line-height: 40px;
i {
color: inherit;
}
// background-color: $subMenuBg !important;
&:hover { &:hover {
background-color: $menuHover !important; color: $blue;
background-color: transparent !important;
} }
} }
// 叶子菜单项
.is-active > .el-submenu__title { .el-menu-item {
color: $subMenuActiveText !important; margin: 4px 16px;
min-width: auto;
// a {
// &:hover {
// color: inherit !important;
// }
// }
}
// 当前激活菜单
.el-menu-item.is-active {
background: linear-gradient(to right, $blue 0%, $light-blue 100%);
box-shadow: 0px 13px 16px 0px rgba(7, 168, 85, 0.2);
border-radius: 8px;
color: #fff !important;
z-index: 1;
} }
& .nest-menu .el-submenu > .el-submenu__title, // 当前激活菜单所属上级菜单标题目录
& .el-menu-item { .is-active > .el-submenu__title {
min-width: $sideBarWidth !important; color: $blue !important;
background-color: $subMenuBg !important;
&:hover {
background-color: $subMenuHover !important;
}
} }
} }
...@@ -179,37 +185,37 @@ ...@@ -179,37 +185,37 @@
} }
// when menu collapsed // when menu collapsed
.el-menu--vertical { // .el-menu--vertical {
& > .el-menu { // & > .el-menu {
.svg-icon { // .svg-icon {
margin-right: 16px; // margin-right: 16px;
} // }
} // }
.nest-menu .el-submenu > .el-submenu__title, // .nest-menu .el-submenu > .el-submenu__title,
.el-menu-item { // .el-menu-item {
&:hover { // &:hover {
// you can use $subMenuHover // // you can use $subMenuHover
background-color: $menuHover !important; // background-color: $menuHover !important;
} // }
} // }
// the scroll bar appears when the subMenu is too long // // the scroll bar appears when the subMenu is too long
> .el-menu--popup { // > .el-menu--popup {
max-height: 100vh; // max-height: 100vh;
overflow-y: auto; // overflow-y: auto;
&::-webkit-scrollbar-track-piece { // &::-webkit-scrollbar-track-piece {
background: #d3dce6; // background: #d3dce6;
} // }
&::-webkit-scrollbar { // &::-webkit-scrollbar {
width: 6px; // width: 6px;
} // }
&::-webkit-scrollbar-thumb { // &::-webkit-scrollbar-thumb {
background: #99a9bf; // background: #99a9bf;
border-radius: 20px; // border-radius: 20px;
} // }
} // }
} // }
// base color // base color
$blue: #0079de; $blue: #07c160;
$light-blue: #4ca1e8; $light-blue: #90de45;
$red: #e74e59; $red: #eb5e12;
$pink: #e65d6e; $pink: #eb5e12;
$green: #06c160; $green: #07c160;
$tiffany: #4ab7bd; $tiffany: #4ab7bd;
$yellow: #ffcf0e; $yellow: #faad14;
$panGreen: #30b08f; $panGreen: #30b08f;
$grayBg: #efeff4; $grayBg: #efeff4;
...@@ -14,17 +14,17 @@ $sub-text-color: #999; ...@@ -14,17 +14,17 @@ $sub-text-color: #999;
color: $sub-text-color; color: $sub-text-color;
} }
// sidebar // sidebar
$menuText: #333; // $menuText: #333;
$menuActiveText: #333; // $menuActiveText: $blue;
$subMenuActiveText: #333; // https://github.com/ElemeFE/element/issues/12951 // $subMenuActiveText: #333; // https://github.com/ElemeFE/element/issues/12951
$menuBg: #fff; // $menuBg: #fff;
$menuActiveBg: #fafafa; // $menuActiveBg: #fafafa;
$menuHover: #fafafa; // $menuHover: #fafafa;
$subMenuBg: #fff; // $subMenuBg: #fff;
$subMenuActiveBg: #fafafa; // $subMenuActiveBg: #fafafa;
$subMenuHover: #fafafa; // $subMenuHover: #fafafa;
$sideBarWidth: 200px; $sideBarWidth: 200px;
...@@ -34,12 +34,17 @@ $border-radius: 4px; ...@@ -34,12 +34,17 @@ $border-radius: 4px;
// the :export directive is the magic sauce for webpack // the :export directive is the magic sauce for webpack
// https://www.bluematador.com/blog/how-to-share-variables-between-js-and-sass // https://www.bluematador.com/blog/how-to-share-variables-between-js-and-sass
:export { :export {
menuText: $menuText; // menuText: $menuText;
menuActiveText: $menuActiveText; // menuActiveText: $menuActiveText;
subMenuActiveText: $subMenuActiveText; // subMenuActiveText: $subMenuActiveText;
menuBg: $menuBg; // menuBg: $menuBg;
menuHover: $menuHover; // menuHover: $menuHover;
subMenuBg: $subMenuBg; // subMenuBg: $subMenuBg;
subMenuHover: $subMenuHover; // subMenuHover: $subMenuHover;
sideBarWidth: $sideBarWidth; sideBarWidth: $sideBarWidth;
} }
.bglg {
background: linear-gradient(to left, $blue 0%, $light-blue 100%);
box-shadow: 0px 13px 16px 0px rgba(7, 168, 85, 0.2);
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!