Commit 68cde27e by xinla

新版菜单布局调整

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