Commit 68cde27e by xinla

新版菜单布局调整

1 parent 738ea639
<template>
<el-breadcrumb class="app-breadcrumb" separator="/">
<transition-group name="breadcrumb">
<el-breadcrumb-item v-for="(item,index) in levelList" :key="item.path">
<span v-if="item.redirect==='noRedirect'||index==levelList.length-1" class="no-redirect">{{ item.meta.title }}</span>
<el-breadcrumb-item v-for="(item, index) in levelList" :key="item.path">
<span
v-if="item.redirect === 'noRedirect' || index == levelList.length - 1"
class="no-redirect"
>{{ item.meta.title }}</span
>
<a v-else @click.prevent="handleLink(item)">{{ item.meta.title }}</a>
</el-breadcrumb-item>
</transition-group>
......@@ -15,7 +19,7 @@ import pathToRegexp from 'path-to-regexp'
export default {
data() {
return {
levelList: null
levelList: null,
}
},
watch: {
......@@ -25,7 +29,7 @@ export default {
return
}
this.getBreadcrumb()
}
},
},
created() {
this.getBreadcrumb()
......@@ -33,14 +37,19 @@ export default {
methods: {
getBreadcrumb() {
// only show routes with meta.title
let matched = this.$route.matched.filter(item => item.meta && item.meta.title)
let matched = this.$route.matched.filter(
(item) => item.meta && item.meta.title
)
console.log(matched)
const first = matched[0]
if (!this.isDashboard(first)) {
matched = [{ path: '/index', meta: { title: '首页' }}].concat(matched)
matched = [{ path: '/index', meta: { title: '首页' } }].concat(matched)
}
this.levelList = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false)
this.levelList = matched.filter(
(item) => item.meta && item.meta.title && item.meta.breadcrumb !== false
)
},
isDashboard(route) {
const name = route && route.name
......@@ -61,14 +70,15 @@ export default {
return
}
this.$router.push(this.pathCompile(path))
}
}
},
},
}
</script>
<style lang="scss" scoped>
.app-breadcrumb.el-breadcrumb {
display: inline-block;
vertical-align: middle;
font-size: 14px;
line-height: 50px;
margin-left: 8px;
......
<template>
<div style="padding: 0 15px;" @click="toggleClick">
<div style="padding: 0 15px;display: inline-block;" @click="toggleClick">
<svg
:class="{'is-active':isActive}"
:class="{ 'is-active': $store.state.app.sidebar.opened }"
class="hamburger"
viewBox="0 0 1024 1024"
xmlns="http://www.w3.org/2000/svg"
width="64"
height="64"
>
<path d="M408 442h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zm-8 204c0 4.4 3.6 8 8 8h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56zm504-486H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 632H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM142.4 642.1L298.7 519a8.84 8.84 0 0 0 0-13.9L142.4 381.9c-5.8-4.6-14.4-.5-14.4 6.9v246.3a8.9 8.9 0 0 0 14.4 7z" />
<path
d="M408 442h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zm-8 204c0 4.4 3.6 8 8 8h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56zm504-486H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 632H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM142.4 642.1L298.7 519a8.84 8.84 0 0 0 0-13.9L142.4 381.9c-5.8-4.6-14.4-.5-14.4 6.9v246.3a8.9 8.9 0 0 0 14.4 7z"
/>
</svg>
</div>
</template>
......@@ -16,17 +18,19 @@
<script>
export default {
name: 'Hamburger',
props: {
isActive: {
type: Boolean,
default: false
}
watch: {
$route(route) {
// if you go to the redirect page, do not update the breadcrumbs
if (route.name == '首页') {
// this.$store.state.app.sidebar.opened = false
}
},
},
methods: {
toggleClick() {
this.$emit('toggleClick')
}
}
this.$store.dispatch('app/toggleSideBar')
},
},
}
</script>
......@@ -36,6 +40,7 @@ export default {
vertical-align: middle;
width: 20px;
height: 20px;
fill: currentColor;
}
.hamburger.is-active {
......
<template>
<div class="sidebar-logo-container" :class="{ collapse: collapse }">
<div class="logo-container" :class="{ collapse: collapse }">
<transition name="sidebarLogoFade">
<router-link
v-if="collapse"
......@@ -26,7 +26,7 @@ export default {
props: {
collapse: {
type: Boolean,
required: true,
// required: true,
},
},
data() {
......@@ -48,12 +48,9 @@ export default {
opacity: 0;
}
.sidebar-logo-container {
.logo-container {
position: relative;
width: 100%;
height: 50px;
line-height: 50px;
background: #2b2f3a;
width: 210px;
text-align: center;
overflow: hidden;
......
<template>
<div class="navbar">
<hamburger
id="hamburger-container"
:is-active="sidebar.opened"
class="hamburger-container"
@toggleClick="toggleSideBar"
/>
<breadcrumb id="breadcrumb-container" class="breadcrumb-container" />
<div class="navbar main-size">
<logo />
<el-scrollbar class="nav-scrollbar">
<template v-for="(route, index) in permission_routes">
<div
v-if="!route.hidden"
:class="['nav', $route.path.startsWith(route.path) && 'active']"
:key="route.path + index"
@click="goLink(route.path)"
>
{{ route.meta && route.meta.title }}
</div>
</template>
</el-scrollbar>
<div class="right-menu">
<template v-if="device !== 'mobile'">
......@@ -19,11 +25,11 @@
</div>
</el-tooltip>
<!-- <el-tooltip content="文档地址" effect="dark" placement="bottom">
<el-tooltip content="文档地址" effect="dark" placement="bottom">
<div class="right-menu-item hover-effect">
<svg-icon icon-class="question" @click="goto(1)" />
</div>
</el-tooltip>-->
</el-tooltip>
<screenfull id="screenfull" class="right-menu-item hover-effect" />
</template>
......@@ -54,21 +60,21 @@
</template>
<script>
import { isExternal } from '@/utils/validate'
import { mapGetters } from 'vuex'
import Breadcrumb from '@/components/Breadcrumb'
import Hamburger from '@/components/Hamburger'
import Logo from './Logo'
import Search from '@/components/HeaderSearch'
import screenfull from '@/components/Screenfull'
export default {
components: {
Breadcrumb,
Hamburger,
Logo,
Search,
screenfull,
},
computed: {
...mapGetters(['sidebar', 'avatar', 'device']),
...mapGetters(['avatar', 'device', 'permission_routes']),
setting: {
get() {
return this.$store.state.settings.showSettings
......@@ -81,10 +87,10 @@ export default {
},
},
},
mounted() {
// console.log(this.permission_routes)
},
methods: {
toggleSideBar() {
this.$store.dispatch('app/toggleSideBar')
},
async logout() {
this.$confirm('确定注销并退出系统吗?', '提示', {
confirmButtonText: '确定',
......@@ -99,48 +105,40 @@ export default {
goto(type) {
window.open(
type
? 'https://gitee.com/LinkWeChat/link-wechat'
? 'https://www.yuque.com/linkwechat/help/dsatfs'
: 'https://gitee.com/LinkWeChat/link-wechat'
)
},
goLink(path) {
if (!isExternal(path)) {
this.$router.push({ path })
} else {
window.open(path, '_blank')
}
},
},
}
</script>
<style lang="scss" scoped>
.navbar {
height: 50px;
display: flex;
align-items: center;
width: 100%;
height: 100%;
overflow: hidden;
position: relative;
background: #fff;
color: #fff;
box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
.hamburger-container {
line-height: 46px;
height: 100%;
float: left;
cursor: pointer;
transition: background 0.3s;
-webkit-tap-highlight-color: transparent;
&:hover {
background: rgba(0, 0, 0, 0.025);
}
}
.breadcrumb-container {
float: left;
}
.errLog-container {
display: inline-block;
vertical-align: top;
}
.right-menu {
float: right;
height: 100%;
line-height: 50px;
position: absolute;
right: 0;
&:focus {
outline: none;
......@@ -149,10 +147,9 @@ export default {
.right-menu-item {
display: inline-block;
padding: 0 8px;
height: 100%;
font-size: 18px;
color: #5a5e66;
vertical-align: text-bottom;
// color: #5a5e66;
vertical-align: middle;
&.hover-effect {
cursor: pointer;
......@@ -169,7 +166,7 @@ export default {
.avatar-wrapper {
position: relative;
color: #fff;
.user-avatar {
cursor: pointer;
width: 40px;
......@@ -181,11 +178,37 @@ export default {
cursor: pointer;
position: absolute;
right: -20px;
top: 25px;
top: 5px;
font-size: 12px;
}
}
}
}
}
.nav-scrollbar {
width: calc(100% - 450px);
/deep/.el-scrollbar__view {
white-space: nowrap;
line-height: 58px;
}
.nav {
display: inline-block;
margin: 0 20px;
flex: none;
position: relative;
&.active::after {
content: '';
display: inline-block;
position: absolute;
bottom: 2px;
width: 42px;
height: 2px;
left: 50%;
transform: translateX(-50%);
border-radius: 6px;
background: #fff;
}
}
}
</style>
<template>
<div v-if="!item.hidden">
<template
v-if="hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren)&&!item.alwaysShow"
v-if="
hasOneShowingChild(item.children, item) &&
(!onlyOneChild.children || onlyOneChild.noShowingChildren) &&
!item.alwaysShow
"
>
<app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path)">
<el-menu-item
:index="resolvePath(onlyOneChild.path)"
:class="{'submenu-title-noDropdown':!isNest}"
:class="{ 'submenu-title-noDropdown': !isNest }"
>
<item
:icon="onlyOneChild.meta.icon||(item.meta&&item.meta.icon)"
:icon="onlyOneChild.meta.icon || (item.meta && item.meta.icon)"
:title="onlyOneChild.meta.title"
/>
</el-menu-item>
</app-link>
</template>
<el-submenu v-else ref="subMenu" :index="resolvePath(item.path)" popper-append-to-body>
<el-submenu
v-else
ref="subMenu"
:index="resolvePath(item.path)"
popper-append-to-body
>
<template slot="title">
<item v-if="item.meta" :icon="item.meta && item.meta.icon" :title="item.meta.title" />
<item
v-if="item.meta"
:icon="item.meta && item.meta.icon"
:title="item.meta.title"
/>
</template>
<sidebar-item
v-for="child in item.children"
......@@ -33,14 +46,14 @@
</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",
name: 'SidebarItem',
components: { Item, AppLink },
mixins: [FixiOSBug],
props: {
......@@ -55,50 +68,50 @@ export default {
},
basePath: {
type: String,
default: "",
default: '',
},
},
data() {
this.onlyOneChild = null;
return {};
this.onlyOneChild = null
return {}
},
methods: {
hasOneShowingChild(children = [], parent) {
const showingChildren = children.filter((item) => {
if (item.hidden) {
return false;
return false
} else {
// Temp set(will be used if only has one showing child)
this.onlyOneChild = item;
return true;
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;
return true
}
// Show parent if there are no child router to display
if (showingChildren.length === 0) {
this.onlyOneChild = { ...parent, path: "", noShowingChildren: true };
return true;
this.onlyOneChild = { ...parent, path: '', noShowingChildren: true }
return true
}
return false;
return false
},
resolvePath(routePath) {
if (isExternal(routePath)) {
return routePath;
return routePath
}
if (isExternal(this.basePath)) {
return this.basePath;
return this.basePath
}
if (/^\//.test(routePath)) {
return routePath;
return routePath
}
return path.resolve(this.basePath, routePath);
return path.resolve(this.basePath, routePath)
},
},
};
}
</script>
<template>
<div :class="{'has-logo':showLogo}">
<logo v-if="showLogo" :collapse="isCollapse" />
<div>
<el-scrollbar wrap-class="scrollbar-wrapper">
<el-menu
:default-active="activeMenu"
......@@ -12,46 +11,44 @@
:collapse-transition="false"
mode="vertical"
>
<sidebar-item
v-for="(route, index) in permission_routes"
:key="route.path + index"
:item="route"
:base-path="route.path"
/>
<template v-for="(route, index) in permission_routes">
<sidebar-item
v-if="$route.path.startsWith(route.path)"
:key="route.path + index"
:item="route"
:base-path="route.path"
/>
</template>
</el-menu>
</el-scrollbar>
</div>
</template>
<script>
import { mapGetters, mapState } from "vuex";
import Logo from "./Logo";
import SidebarItem from "./SidebarItem";
import variables from "@/styles/variables.scss";
import { mapGetters, mapState } from 'vuex'
import SidebarItem from './SidebarItem'
import variables from '@/styles/variables.scss'
export default {
components: { SidebarItem, Logo },
components: { SidebarItem },
computed: {
...mapState(["settings"]),
...mapGetters(["permission_routes", "sidebar"]),
...mapState(['settings']),
...mapGetters(['permission_routes', 'sidebar']),
activeMenu() {
const route = this.$route;
const { meta, path } = route;
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;
return meta.activeMenu
}
return path;
},
showLogo() {
return this.$store.state.settings.sidebarLogo;
return path
},
variables() {
return variables;
return variables
},
isCollapse() {
return !this.sidebar.opened;
return !this.sidebar.opened
},
},
};
}
</script>
<template>
<div :class="classObj" class="app-wrapper">
<div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside" />
<sidebar class="sidebar-container" />
<div :class="{hasTagsView:needTagsView}" class="main-container">
<div :class="{'fixed-header':fixedHeader}">
<navbar />
<tags-view v-if="needTagsView" />
<!-- <div
v-if="device === 'mobile' && sidebar.opened"
class="drawer-bg"
@click="handleClickOutside"
/> -->
<div class="top-wrap">
<navbar />
</div>
<div class="main-wrap">
<div class="main main-size">
<sidebar v-if="$route.name !== '首页'" class="sidebar-container" />
<div class="main-container">
<hamburger id="hamburger-container" class="hamburger-container" />
<breadcrumb id="breadcrumb-container" class="breadcrumb-container" />
<!-- <div :class="{ 'fixed-header': fixedHeader }">
<navbar />
<tags-view v-if="needTagsView" />
</div> -->
<app-main />
<right-panel v-if="showSettings">
<settings />
</right-panel>
</div>
</div>
<app-main />
<right-panel v-if="showSettings">
<settings />
</right-panel>
</div>
</div>
</template>
......@@ -18,84 +32,110 @@
<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 ResizeMixin from './mixin/ResizeHandler'
import { mapState } from 'vuex'
export default {
name: 'Layout',
components: {
Breadcrumb,
Hamburger,
AppMain,
Navbar,
RightPanel,
Settings,
Sidebar,
TagsView
TagsView,
},
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
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,
}),
classObj() {
return {
hideSidebar: !this.sidebar.opened,
openSidebar: this.sidebar.opened,
withoutAnimation: this.sidebar.withoutAnimation,
mobile: this.device === 'mobile'
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;
}
}
.drawer-bg {
background: #000;
opacity: 0.3;
width: 100%;
&.mobile.openSidebar {
position: fixed;
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;
.top-wrap {
height: 58px;
background: $blue;
}
.hideSidebar .fixed-header {
width: calc(100% - 54px)
.main-wrap {
height: calc(100vh - 58px);
background: #eee;
}
}
.mobile .fixed-header {
width: 100%;
.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;
}
.hideSidebar .fixed-header {
width: calc(100% - 54px);
}
.mobile .fixed-header {
width: 100%;
}
.hamburger-container {
cursor: pointer;
transition: background 0.3s;
-webkit-tap-highlight-color: transparent;
&:hover {
background: rgba(0, 0, 0, 0.025);
}
}
</style>
......@@ -38,17 +38,21 @@ export const constantRoutes = [
],
},
{
path: '',
path: '/index',
component: Layout,
redirect: '/index',
name: '首页',
meta: { title: '首页' },
children: [
{
path: '/index',
component: (resolve) => require(['@/views/index'], resolve),
name: '首页',
hidden: true,
meta: {
title: '首页',
icon: 'dashboard',
breadcrumb: false,
noCache: true,
affix: true,
},
......@@ -75,7 +79,7 @@ export const constantRoutes = [
// path: 'customer',
// name: 'Customer',
// component: (resolve) => require(['@/views/customerManage/customer'], resolve),
// meta: { title: '客户', icon: '' }
// meta: { title: '企业客户', icon: '' }
// },
// {
// path: 'customerDetail',
......@@ -87,7 +91,7 @@ export const constantRoutes = [
// path: 'group',
// name: 'CustomerGroup',
// component: (resolve) => require(['@/views/customerManage/group'], resolve),
// meta: { title: '客户群', icon: '' }
// meta: { title: '企业客群', icon: '' }
// },
// {
// path: 'groupDetail',
......@@ -204,7 +208,7 @@ export const constantRoutes = [
// path: '/drainageCode',
// component: Layout,
// redirect: '/drainageCode/staff',
// meta: { title: '引流码', icon: 'qrcode' },
// meta: { title: '引流获客', icon: 'qrcode' },
// children: [
// {
// path: 'staff',
......@@ -470,60 +474,60 @@ export const constantRoutes = [
// },
// ]
// },
// {
// path: '/application',
// component: Layout,
// meta: { title: '', icon: 'wechat' },
// children: [
// {
// path: 'taskGroup',
// name: 'taskGroup',
// component: (resolve) => require(['@/views/application/taskGroup'], resolve),
// meta: { title: '任务宝', icon: '' }
// },
// {
// path: 'taskDetail',
// name: 'taskDetail',
// hidden: true,
// component: (resolve) => require(['@/views/application/taskDetail'], resolve),
// meta: { title: '任务详情', icon: '' }
// },
// {
// path: 'editTask',
// name: 'editTask',
// hidden: true,
// component: (resolve) => require(['@/views/application/taskDetail/editTask'], resolve),
// meta: { title: '编辑活动任务', icon: '' }
// },
// {
// path: 'addTask',
// name: 'addTask',
// hidden: true,
// component: (resolve) => require(['@/views/application/taskDetail/addTask'], resolve),
// meta: { title: '新增活动任务', icon: '' }
// },
// {
// path: 'groupFission',
// name: 'groupFission',
// component: (resolve) => require(['@/views/application/groupFission'], resolve),
// meta: { title: '群裂变', icon: '' }
// },
// {
// path: 'addFission',
// name: 'addFission',
// hidden: true,
// component: (resolve) => require(['@/views/application/fissionDetail/addFission'], resolve),
// meta: { title: '新增群裂变', icon: '' }
// },
// {
// path: 'fissionDetail',
// name: 'fissionDetail',
// hidden: true,
// component: (resolve) => require(['@/views/application/fissionDetail'], resolve),
// meta: { title: '任务详情', icon: '' }
// },
// ]
// },
// {
// path: '/application',
// component: Layout,
// meta: { title: '', icon: 'wechat' },
// children: [
// {
// path: 'taskGroup',
// name: 'taskGroup',
// component: (resolve) => require(['@/views/application/taskGroup'], resolve),
// meta: { title: '任务宝', icon: '' }
// },
// {
// path: 'taskDetail',
// name: 'taskDetail',
// hidden: true,
// component: (resolve) => require(['@/views/application/taskDetail'], resolve),
// meta: { title: '任务详情', icon: '' }
// },
// {
// path: 'editTask',
// name: 'editTask',
// hidden: true,
// component: (resolve) => require(['@/views/application/taskDetail/editTask'], resolve),
// meta: { title: '编辑活动任务', icon: '' }
// },
// {
// path: 'addTask',
// name: 'addTask',
// hidden: true,
// component: (resolve) => require(['@/views/application/taskDetail/addTask'], resolve),
// meta: { title: '新增活动任务', icon: '' }
// },
// {
// path: 'groupFission',
// name: 'groupFission',
// component: (resolve) => require(['@/views/application/groupFission'], resolve),
// meta: { title: '群裂变', icon: '' }
// },
// {
// path: 'addFission',
// name: 'addFission',
// hidden: true,
// component: (resolve) => require(['@/views/application/fissionDetail/addFission'], resolve),
// meta: { title: '新增群裂变', icon: '' }
// },
// {
// path: 'fissionDetail',
// name: 'fissionDetail',
// hidden: true,
// component: (resolve) => require(['@/views/application/fissionDetail'], resolve),
// meta: { title: '任务详情', icon: '' }
// },
// ]
// },
{
path: '/user',
component: Layout,
......
......@@ -5,36 +5,39 @@ import Layout from '@/layout/index'
const permission = {
state: {
routes: [],
addRoutes: []
addRoutes: [],
},
mutations: {
SET_ROUTES: (state, routes) => {
state.addRoutes = routes
state.routes = constantRoutes.concat(routes)
}
},
},
actions: {
// 生成路由
GenerateRoutes({ commit }) {
return new Promise(resolve => {
return new Promise((resolve) => {
// 向后端请求路由数据
getRouters().then(res => {
getRouters().then((res) => {
const accessedRoutes = filterAsyncRouter(res.data)
accessedRoutes.push({ path: '*', redirect: '/404', hidden: true })
commit('SET_ROUTES', accessedRoutes)
resolve(accessedRoutes)
})
})
}
}
},
},
}
// 遍历后台传来的路由字符串,转换为组件对象
function filterAsyncRouter(asyncRouterMap) {
return asyncRouterMap.filter(route => {
return asyncRouterMap.filter((route) => {
if (route.component) {
// Layout组件特殊处理
if (route.component === 'Layout') {
if (route.redirect === 'noRedirect' && route.children.length) {
route.redirect = route.path + '/' + route.children[0].path
}
route.component = Layout
} else {
route.component = loadView(route.component)
......@@ -47,7 +50,8 @@ function filterAsyncRouter(asyncRouterMap) {
})
}
export const loadView = (view) => { // 路由懒加载
export const loadView = (view) => {
// 路由懒加载
return (resolve) => require([`@/views/${view}`], resolve)
}
......
......@@ -6,6 +6,34 @@
*:after {
box-sizing: border-box;
}
body,
h1,
h2,
h3,
h4,
h5,
h6,
hr,
p,
blockquote,
dl,
dt,
dd,
ul,
ol,
li,
pre,
form,
fieldset,
legend,
button,
input,
textarea,
th,
td {
margin: 0;
padding: 0;
}
body {
height: 100%;
......@@ -14,11 +42,13 @@ body {
text-rendering: optimizeLegibility;
font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB,
Microsoft YaHei, Arial, sans-serif;
overflow: hidden;
}
html {
height: 100%;
font-size: 14px;
color: #333;
}
li {
......@@ -213,3 +243,8 @@ li {
.ml20 {
margin-left: 20px;
}
.main-size {
max-width: 1920px;
margin: 0 auto;
}
......@@ -4,10 +4,11 @@
**/
/* theme color */
$--color-primary: #1890ff;
$--color-success: #13ce66;
$--color-warning: #ffba00;
$--color-danger: #ff4949;
$--color-primary: #0079de;
$--color-success: #06c160;
$--color-warning: #ffcf0e;
$--color-danger: #e74e59;
$--color-info: #fa7216;
// $--color-info: #1E1E1E;
$--button-font-weight: 400;
......@@ -17,12 +18,12 @@ $--button-font-weight: 400;
$--border-color-light: #dfe4ed;
$--border-color-lighter: #e6ebf5;
$--table-border:1px solid#dfe6ec;
$--table-border: 1px solid#dfe6ec;
/* icon font path, required */
$--font-path: '~element-ui/lib/theme-chalk/fonts';
@import "~element-ui/packages/theme-chalk/src/index";
@import '~element-ui/packages/theme-chalk/src/index';
// the :export directive is the magic sauce for webpack
// https://www.bluematador.com/blog/how-to-share-variables-between-js-and-sass
......
#app {
.main-container {
min-height: 100%;
transition: margin-left .28s;
transition: margin-left 0.28s;
margin-left: $sideBarWidth;
position: relative;
}
......@@ -11,12 +10,10 @@
transition: width 0.28s;
width: $sideBarWidth !important;
background-color: $menuBg;
height: 100%;
height: calc(100% - 58px);
position: fixed;
font-size: 0px;
top: 0;
bottom: 0;
left: 0;
z-index: 1001;
overflow: hidden;
......@@ -27,7 +24,8 @@
// reset element-ui css
.horizontal-collapse-transition {
transition: 0s width ease-in-out, 0s padding-left ease-in-out, 0s padding-right ease-in-out;
transition: 0s width ease-in-out, 0s padding-left ease-in-out,
0s padding-right ease-in-out;
}
.scrollbar-wrapper {
......@@ -76,11 +74,11 @@
}
}
.is-active>.el-submenu__title {
.is-active > .el-submenu__title {
color: $subMenuActiveText !important;
}
& .nest-menu .el-submenu>.el-submenu__title,
& .nest-menu .el-submenu > .el-submenu__title,
& .el-menu-item {
min-width: $sideBarWidth !important;
background-color: $subMenuBg !important;
......@@ -116,7 +114,7 @@
.el-submenu {
overflow: hidden;
&>.el-submenu__title {
& > .el-submenu__title {
padding: 0 !important;
.svg-icon {
......@@ -131,8 +129,8 @@
.el-menu--collapse {
.el-submenu {
&>.el-submenu__title {
&>span {
& > .el-submenu__title {
& > span {
height: 0;
width: 0;
overflow: hidden;
......@@ -155,7 +153,7 @@
}
.sidebar-container {
transition: transform .28s;
transition: transform 0.28s;
width: $sideBarWidth !important;
}
......@@ -169,7 +167,6 @@
}
.withoutAnimation {
.main-container,
.sidebar-container {
transition: none;
......@@ -179,13 +176,13 @@
// when menu collapsed
.el-menu--vertical {
&>.el-menu {
& > .el-menu {
.svg-icon {
margin-right: 16px;
}
}
.nest-menu .el-submenu>.el-submenu__title,
.nest-menu .el-submenu > .el-submenu__title,
.el-menu-item {
&:hover {
// you can use $subMenuHover
......@@ -194,7 +191,7 @@
}
// the scroll bar appears when the subMenu is too long
>.el-menu--popup {
> .el-menu--popup {
max-height: 100vh;
overflow-y: auto;
......@@ -211,4 +208,4 @@
border-radius: 20px;
}
}
}
\ No newline at end of file
}
// base color
$blue: #324157;
$light-blue: #3a71a8;
$red: #c03639;
$blue: #0079de;
$light-blue: #4ca1e8;
$red: #e74e59;
$pink: #e65d6e;
$green: #30b08f;
$green: #06c160;
$tiffany: #4ab7bd;
$yellow: #fec171;
$yellow: #ffcf0e;
$panGreen: #30b08f;
$grayBg: #efeff4;
// sidebar
$menuText: #bfcbd9;
$menuActiveText: #fff;
$subMenuActiveText: #fff; // https://github.com/ElemeFE/element/issues/12951
$menuText: #333;
$menuActiveText: #333;
$subMenuActiveText: #333; // https://github.com/ElemeFE/element/issues/12951
$menuBg: #191a23;
$menuActiveBg: #2d8cf0;
$menuHover: #212230;
$menuBg: #fff;
$menuActiveBg: #4ca1e8;
$menuHover: #4ca1e8;
$subMenuBg: #101117;
$subMenuActiveBg: #2d8cf0;
$subMenuHover: #161a29;
$subMenuBg: #fff;
$subMenuActiveBg: #4ca1e8;
$subMenuHover: #4ca1e8;
$sideBarWidth: 256px;
$sideBarWidth: 200px;
// the :export directive is the magic sauce for webpack
// https://www.bluematador.com/blog/how-to-share-variables-between-js-and-sass
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!