Commit fcfa7c21 by xinla

4.x绿色主题开始

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