Browse Source

菜单样式调整

newMaster
1747191978@qq.com 4 months ago
parent
commit
55784ad5fb
  1. BIN
      acupuncture-前台/src/assets/images/dangan_n@1x.png
  2. BIN
      acupuncture-前台/src/assets/images/dangan_s@1x.png
  3. BIN
      acupuncture-前台/src/assets/images/home_N@1x.png
  4. BIN
      acupuncture-前台/src/assets/images/home_S@1x.png
  5. BIN
      acupuncture-前台/src/assets/images/logo@1x.png
  6. BIN
      acupuncture-前台/src/assets/images/me_n@1x.png
  7. BIN
      acupuncture-前台/src/assets/images/me_s@1x.png
  8. BIN
      acupuncture-前台/src/assets/images/suifang_n@1x.png
  9. BIN
      acupuncture-前台/src/assets/images/suifang_s@1x.png
  10. BIN
      acupuncture-前台/src/assets/images/zhenliao_n@1x.png
  11. BIN
      acupuncture-前台/src/assets/images/zhenliao_s@1x.png
  12. 53
      acupuncture-前台/src/assets/styles/sidebar.scss
  13. 34
      acupuncture-前台/src/assets/styles/variables.scss
  14. 77
      acupuncture-前台/src/components/TopNav/index.vue
  15. 4
      acupuncture-前台/src/layout/components/Navbar.vue
  16. 37
      acupuncture-前台/src/layout/components/Sidebar/Item.vue
  17. 67
      acupuncture-前台/src/layout/components/Sidebar/Logo.vue
  18. 113
      acupuncture-前台/src/layout/components/Sidebar/SidebarItem.vue
  19. 111
      acupuncture-前台/src/layout/components/Sidebar/index.vue
  20. 2
      acupuncture-前台/src/store/modules/settings.js

BIN
acupuncture-前台/src/assets/images/dangan_n@1x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 874 B

BIN
acupuncture-前台/src/assets/images/dangan_s@1x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 849 B

BIN
acupuncture-前台/src/assets/images/home_N@1x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 767 B

BIN
acupuncture-前台/src/assets/images/home_S@1x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 734 B

BIN
acupuncture-前台/src/assets/images/logo@1x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1018 B

BIN
acupuncture-前台/src/assets/images/me_n@1x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 716 B

BIN
acupuncture-前台/src/assets/images/me_s@1x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 699 B

BIN
acupuncture-前台/src/assets/images/suifang_n@1x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 860 B

BIN
acupuncture-前台/src/assets/images/suifang_s@1x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 833 B

BIN
acupuncture-前台/src/assets/images/zhenliao_n@1x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 787 B

BIN
acupuncture-前台/src/assets/images/zhenliao_s@1x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 759 B

53
acupuncture-前台/src/assets/styles/sidebar.scss

@ -1,18 +1,17 @@
#app { #app {
.main-container { .main-container {
height: 100%; height: 100%;
transition: margin-left .28s; transition: margin-left 0.28s;
margin-left: $base-sidebar-width; margin-left: $base-sidebar-width;
position: relative; position: relative;
} }
.sidebarHide { .sidebarHide {
margin-left: 0!important; margin-left: 0 !important;
} }
.sidebar-container { .sidebar-container {
-webkit-transition: width .28s; -webkit-transition: width 0.28s;
transition: width 0.28s; transition: width 0.28s;
width: $base-sidebar-width !important; width: $base-sidebar-width !important;
background-color: $base-menu-background; background-color: $base-menu-background;
@ -24,12 +23,17 @@
left: 0; left: 0;
z-index: 1001; z-index: 1001;
overflow: hidden; overflow: hidden;
-webkit-box-shadow: 2px 0 6px rgba(0,21,41,.35); -webkit-box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35);
box-shadow: 2px 0 6px rgba(0,21,41,.35); box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35);
// 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;
-webkit-transition: 0s width ease-in-out, 0s padding-left ease-in-out;
-moz-transition: 0s width ease-in-out, 0s padding-left ease-in-out;
-ms-transition: 0s width ease-in-out, 0s padding-left ease-in-out;
-o-transition: 0s width ease-in-out, 0s padding-left ease-in-out;
} }
.scrollbar-wrapper { .scrollbar-wrapper {
@ -70,17 +74,26 @@
width: 100% !important; width: 100% !important;
} }
.el-menu-item, .el-submenu__title { .el-menu-item,
.el-submenu__title {
overflow: hidden !important; overflow: hidden !important;
text-overflow: ellipsis !important; text-overflow: ellipsis !important;
white-space: nowrap !important; white-space: nowrap !important;
} }
.el-menu-item {
height: 90px;
line-height: 26px !important;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
// menu hover // menu hover
.submenu-title-noDropdown, .submenu-title-noDropdown,
.el-submenu__title { .el-submenu__title {
&:hover { &:hover {
background-color: rgba(0, 0, 0, 0.06) !important; background-color: rgba(0, 0, 0, 0.2) !important;
color: #fff !important;
} }
} }
@ -88,7 +101,7 @@
color: $base-menu-color-active !important; color: $base-menu-color-active !important;
} }
& .nest-menu .el-submenu>.el-submenu__title, & .nest-menu .el-submenu > .el-submenu__title,
& .el-submenu .el-menu-item { & .el-submenu .el-menu-item {
min-width: $base-sidebar-width !important; min-width: $base-sidebar-width !important;
@ -97,7 +110,7 @@
} }
} }
& .theme-dark .nest-menu .el-submenu>.el-submenu__title, & .theme-dark .nest-menu .el-submenu > .el-submenu__title,
& .theme-dark .el-submenu .el-menu-item { & .theme-dark .el-submenu .el-menu-item {
background-color: $base-sub-menu-background !important; background-color: $base-sub-menu-background !important;
@ -132,20 +145,19 @@
.el-submenu { .el-submenu {
overflow: hidden; overflow: hidden;
&>.el-submenu__title { & > .el-submenu__title {
padding: 0 !important; padding: 0 !important;
.svg-icon { .svg-icon {
margin-left: 20px; margin-left: 20px;
} }
} }
} }
.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;
@ -168,7 +180,7 @@
} }
.sidebar-container { .sidebar-container {
transition: transform .28s; transition: transform 0.28s;
width: $base-sidebar-width !important; width: $base-sidebar-width !important;
} }
@ -182,7 +194,6 @@
} }
.withoutAnimation { .withoutAnimation {
.main-container, .main-container,
.sidebar-container { .sidebar-container {
transition: none; transition: none;
@ -192,13 +203,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
@ -207,7 +218,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;

34
acupuncture-前台/src/assets/styles/variables.scss

@ -1,25 +1,25 @@
// base color // base color
$blue:#324157; $blue: #324157;
$light-blue:#3A71A8; $light-blue: #3a71a8;
$red:#C03639; $red: #c03639;
$pink: #E65D6E; $pink: #e65d6e;
$green: #30B08F; $green: #30b08f;
$tiffany: #4AB7BD; $tiffany: #4ab7bd;
$yellow:#FEC171; $yellow: #fec171;
$panGreen: #30B08F; $panGreen: #30b08f;
// 默认菜单主题风格 // 默认菜单主题风格
$base-menu-color:#bfcbd9; $base-menu-color: #c7bdb1;
$base-menu-color-active:#f4f4f5; $base-menu-color-active: #f4f4f5;
$base-menu-background:#304156; $base-menu-background: #70483e;
$base-logo-title-color: #ffffff; $base-logo-title-color: #ffffff;
$base-menu-light-color:rgba(0,0,0,.70); $base-menu-light-color: rgba(0, 0, 0, 0.7);
$base-menu-light-background:#ffffff; $base-menu-light-background: #ffffff;
$base-logo-light-title-color: #001529; $base-logo-light-title-color: #001529;
$base-sub-menu-background:#1f2d3d; $base-sub-menu-background: #1f2d3d;
$base-sub-menu-hover:#001528; $base-sub-menu-hover: #001528;
// 自定义暗色菜单风格 // 自定义暗色菜单风格
/** /**
@ -36,7 +36,7 @@ $base-sub-menu-background:#000c17;
$base-sub-menu-hover:#001528; $base-sub-menu-hover:#001528;
*/ */
$base-sidebar-width: 200px; $base-sidebar-width: 120px;
// 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
@ -50,5 +50,5 @@ $base-sidebar-width: 200px;
subMenuHover: $base-sub-menu-hover; subMenuHover: $base-sub-menu-hover;
sideBarWidth: $base-sidebar-width; sideBarWidth: $base-sidebar-width;
logoTitleColor: $base-logo-title-color; logoTitleColor: $base-logo-title-color;
logoLightTitleColor: $base-logo-light-title-color logoLightTitleColor: $base-logo-light-title-color;
} }

77
acupuncture-前台/src/components/TopNav/index.vue

@ -5,25 +5,38 @@
@select="handleSelect" @select="handleSelect"
> >
<template v-for="(item, index) in topMenus"> <template v-for="(item, index) in topMenus">
<el-menu-item :style="{'--theme': theme}" :index="item.path" :key="index" v-if="index < visibleNumber"> <el-menu-item
:style="{ '--theme': theme }"
:index="item.path"
:key="index"
v-if="index < visibleNumber"
>
<svg-icon <svg-icon
v-if="item.meta && item.meta.icon && item.meta.icon !== '#'" v-if="item.meta && item.meta.icon && item.meta.icon !== '#'"
:icon-class="item.meta.icon"/> :icon-class="item.meta.icon"
/>
{{ item.meta.title }} {{ item.meta.title }}
</el-menu-item> </el-menu-item>
</template> </template>
<!-- 顶部菜单超出数量折叠 --> <!-- 顶部菜单超出数量折叠 -->
<el-submenu :style="{'--theme': theme}" index="more" :key="visibleNumber" v-if="topMenus.length > visibleNumber"> <el-submenu
:style="{ '--theme': theme }"
index="more"
:key="visibleNumber"
v-if="topMenus.length > visibleNumber"
>
<template slot="title">更多菜单</template> <template slot="title">更多菜单</template>
<template v-for="(item, index) in topMenus"> <template v-for="(item, index) in topMenus">
<el-menu-item <el-menu-item
:index="item.path" :index="item.path"
:key="index" :key="index"
v-if="index >= visibleNumber"> v-if="index >= visibleNumber"
>
<svg-icon <svg-icon
v-if="item.meta && item.meta.icon && item.meta.icon !== '#'" v-if="item.meta && item.meta.icon && item.meta.icon !== '#'"
:icon-class="item.meta.icon"/> :icon-class="item.meta.icon"
/>
{{ item.meta.title }} {{ item.meta.title }}
</el-menu-item> </el-menu-item>
</template> </template>
@ -36,7 +49,7 @@ import { constantRoutes } from "@/router";
import { isHttp } from "@/utils/validate"; import { isHttp } from "@/utils/validate";
// //
const hideList = ['/index', '/user/profile']; const hideList = ["/index", "/user/profile"];
export default { export default {
data() { data() {
@ -44,7 +57,7 @@ export default {
// //
visibleNumber: 5, visibleNumber: 5,
// index // index
currentIndex: undefined currentIndex: undefined,
}; };
}, },
computed: { computed: {
@ -76,11 +89,12 @@ export default {
this.routers.map((router) => { this.routers.map((router) => {
for (var item in router.children) { for (var item in router.children) {
if (router.children[item].parentPath === undefined) { if (router.children[item].parentPath === undefined) {
if(router.path === "/") { if (router.path === "/") {
router.children[item].path = "/" + router.children[item].path; router.children[item].path = "/" + router.children[item].path;
} else { } else {
if(!isHttp(router.children[item].path)) { if (!isHttp(router.children[item].path)) {
router.children[item].path = router.path + "/" + router.children[item].path; router.children[item].path =
router.path + "/" + router.children[item].path;
} }
} }
router.children[item].parentPath = router.path; router.children[item].parentPath = router.path;
@ -94,25 +108,29 @@ export default {
activeMenu() { activeMenu() {
const path = this.$route.path; const path = this.$route.path;
let activePath = path; let activePath = path;
if (path !== undefined && path.lastIndexOf("/") > 0 && hideList.indexOf(path) === -1) { if (
path !== undefined &&
path.lastIndexOf("/") > 0 &&
hideList.indexOf(path) === -1
) {
const tmpPath = path.substring(1, path.length); const tmpPath = path.substring(1, path.length);
if (!this.$route.meta.link) { if (!this.$route.meta.link) {
activePath = "/" + tmpPath.substring(0, tmpPath.indexOf("/")); activePath = "/" + tmpPath.substring(0, tmpPath.indexOf("/"));
this.$store.dispatch('app/toggleSideBarHide', false); this.$store.dispatch("app/toggleSideBarHide", false);
} }
} else if(!this.$route.children) { } else if (!this.$route.children) {
activePath = path; activePath = path;
this.$store.dispatch('app/toggleSideBarHide', true); this.$store.dispatch("app/toggleSideBarHide", true);
} }
this.activeRoutes(activePath); this.activeRoutes(activePath);
return activePath; return activePath;
}, },
}, },
beforeMount() { beforeMount() {
window.addEventListener('resize', this.setVisibleNumber) window.addEventListener("resize", this.setVisibleNumber);
}, },
beforeDestroy() { beforeDestroy() {
window.removeEventListener('resize', this.setVisibleNumber) window.removeEventListener("resize", this.setVisibleNumber);
}, },
mounted() { mounted() {
this.setVisibleNumber(); this.setVisibleNumber();
@ -126,24 +144,24 @@ export default {
// //
handleSelect(key, keyPath) { handleSelect(key, keyPath) {
this.currentIndex = key; this.currentIndex = key;
const route = this.routers.find(item => item.path === key); const route = this.routers.find((item) => item.path === key);
if (isHttp(key)) { if (isHttp(key)) {
// http(s):// // http(s)://
window.open(key, "_blank"); window.open(key, "_blank");
} else if (!route || !route.children) { } else if (!route || !route.children) {
// //
const routeMenu = this.childrenMenus.find(item => item.path === key); const routeMenu = this.childrenMenus.find((item) => item.path === key);
if (routeMenu && routeMenu.query) { if (routeMenu && routeMenu.query) {
let query = JSON.parse(routeMenu.query); let query = JSON.parse(routeMenu.query);
this.$router.push({ path: key, query: query }); this.$router.push({ path: key, query: query });
} else { } else {
this.$router.push({ path: key }); this.$router.push({ path: key });
} }
this.$store.dispatch('app/toggleSideBarHide', true); this.$store.dispatch("app/toggleSideBarHide", true);
} else { } else {
// //
this.activeRoutes(key); this.activeRoutes(key);
this.$store.dispatch('app/toggleSideBarHide', false); this.$store.dispatch("app/toggleSideBarHide", false);
} }
}, },
// //
@ -156,36 +174,35 @@ export default {
} }
}); });
} }
if(routes.length > 0) { if (routes.length > 0) {
this.$store.commit("SET_SIDEBAR_ROUTERS", routes); this.$store.commit("SET_SIDEBAR_ROUTERS", routes);
} else { } else {
this.$store.dispatch('app/toggleSideBarHide', true); this.$store.dispatch("app/toggleSideBarHide", true);
} }
} },
}, },
}; };
</script> </script>
<style lang="scss"> <style lang="scss">
.topmenu-container.el-menu--horizontal > .el-menu-item { .topmenu-container.el-menu--horizontal > .el-menu-item {
line-height: 26px !important;
float: left; float: left;
height: 50px !important;
line-height: 50px !important;
color: #999093 !important; color: #999093 !important;
padding: 0 5px !important; padding: 0 5px !important;
margin: 0 10px !important; margin: 0 10px !important;
} }
.topmenu-container.el-menu--horizontal > .el-menu-item.is-active, .el-menu--horizontal > .el-submenu.is-active .el-submenu__title { .topmenu-container.el-menu--horizontal > .el-menu-item.is-active,
border-bottom: 2px solid #{'var(--theme)'} !important; .el-menu--horizontal > .el-submenu.is-active .el-submenu__title {
border-bottom: 2px solid #{"var(--theme)"} !important;
color: #303133; color: #303133;
} }
/* submenu item */ /* submenu item */
.topmenu-container.el-menu--horizontal > .el-submenu .el-submenu__title { .topmenu-container.el-menu--horizontal > .el-submenu .el-submenu__title {
float: left; float: left;
height: 50px !important; line-height: 26px !important;
line-height: 50px !important;
color: #999093 !important; color: #999093 !important;
padding: 0 5px !important; padding: 0 5px !important;
margin: 0 10px !important; margin: 0 10px !important;

4
acupuncture-前台/src/layout/components/Navbar.vue

@ -15,7 +15,7 @@
<top-nav id="topmenu-container" class="topmenu-container" v-if="topNav" /> <top-nav id="topmenu-container" class="topmenu-container" v-if="topNav" />
<div class="right-menu"> <div class="right-menu">
<template v-if="device !== 'mobile'"> <!-- <template v-if="device !== 'mobile'">
<search id="header-search" class="right-menu-item" /> <search id="header-search" class="right-menu-item" />
<el-tooltip content="源码地址" effect="dark" placement="bottom"> <el-tooltip content="源码地址" effect="dark" placement="bottom">
@ -31,7 +31,7 @@
<el-tooltip content="布局大小" effect="dark" placement="bottom"> <el-tooltip content="布局大小" effect="dark" placement="bottom">
<size-select id="size-select" class="right-menu-item hover-effect" /> <size-select id="size-select" class="right-menu-item hover-effect" />
</el-tooltip> </el-tooltip>
</template> </template> -->
<el-dropdown <el-dropdown
class="avatar-container right-menu-item hover-effect" class="avatar-container right-menu-item hover-effect"

37
acupuncture-前台/src/layout/components/Sidebar/Item.vue

@ -1,33 +1,42 @@
<script> <script>
export default { export default {
name: 'MenuItem', name: "MenuItem",
functional: true, functional: true,
props: { props: {
icon: { icon: {
type: String, type: String,
default: '' default: "",
}, },
title: { title: {
type: String, type: String,
default: '' default: "",
} },
}, },
render(h, context) { render(h, context) {
const { icon, title } = context.props const { icon, title } = context.props;
const vnodes = [] const vnodes = [];
if (icon) { // if (icon) {
vnodes.push(<svg-icon icon-class={icon}/>) // // vnodes.push(<svg-icon icon-class={icon} />);
} // vnodes.push(<img src={itmeIcon[title]} />);
// }
if (title) { if (title) {
console.log("title", title);
if (title.length > 5) { if (title.length > 5) {
vnodes.push(<span slot='title' title={(title)}>{(title)}</span>) vnodes.push(
<span slot="title" title={title}>
{title}
</span>
);
} else { } else {
vnodes.push(<span slot='title'>{(title)}</span>) vnodes.push(<span slot="title">{title}</span>);
} }
} }
return vnodes
} return vnodes;
} },
};
</script> </script>

67
acupuncture-前台/src/layout/components/Sidebar/Logo.vue

@ -1,45 +1,80 @@
<template> <template>
<div class="sidebar-logo-container" :class="{'collapse':collapse}" :style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground }"> <div
class="sidebar-logo-container"
:class="{ collapse: collapse }"
:style="{
backgroundColor:
sideTheme === 'theme-dark'
? variables.menuBackground
: variables.menuLightBackground,
}"
>
<transition name="sidebarLogoFade"> <transition name="sidebarLogoFade">
<router-link v-if="collapse" key="collapse" class="sidebar-logo-link" to="/"> <router-link
v-if="collapse"
key="collapse"
class="sidebar-logo-link"
to="/"
>
<img v-if="logo" :src="logo" class="sidebar-logo" /> <img v-if="logo" :src="logo" class="sidebar-logo" />
<h1 v-else class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.logoTitleColor : variables.logoLightTitleColor }">{{ title }} </h1> <h1
v-else
class="sidebar-title"
:style="{
color:
sideTheme === 'theme-dark'
? variables.logoTitleColor
: variables.logoLightTitleColor,
}"
>
{{ title }}
</h1>
</router-link> </router-link>
<router-link v-else key="expand" class="sidebar-logo-link" to="/"> <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" :style="{ color: sideTheme === 'theme-dark' ? variables.logoTitleColor : variables.logoLightTitleColor }">{{ title }} </h1> <h1
class="sidebar-title"
:style="{
color:
sideTheme === 'theme-dark'
? variables.logoTitleColor
: variables.logoLightTitleColor,
}"
>
{{ title }}
</h1>
</router-link> </router-link>
</transition> </transition>
</div> </div>
</template> </template>
<script> <script>
import logoImg from '@/assets/logo/logo.png' import logoImg from "@/assets/logo/logo.png";
import variables from '@/assets/styles/variables.scss' import variables from "@/assets/styles/variables.scss";
export default { export default {
name: 'SidebarLogo', name: "SidebarLogo",
props: { props: {
collapse: { collapse: {
type: Boolean, type: Boolean,
required: true required: true,
} },
}, },
computed: { computed: {
variables() { variables() {
return variables; return variables;
}, },
sideTheme() { sideTheme() {
return this.$store.state.settings.sideTheme return this.$store.state.settings.sideTheme;
} },
}, },
data() { data() {
return { return {
title: process.env.VUE_APP_TITLE, title: process.env.VUE_APP_TITLE,
logo: logoImg logo: logoImg,
} };
} },
} };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -57,7 +92,7 @@ export default {
width: 100%; width: 100%;
height: 50px; height: 50px;
line-height: 50px; line-height: 50px;
background: #2b2f3a; background: #70483e;
text-align: center; text-align: center;
overflow: hidden; overflow: hidden;

113
acupuncture-前台/src/layout/components/Sidebar/SidebarItem.vue

@ -1,16 +1,44 @@
<template> <template>
<div v-if="!item.hidden"> <div v-if="!item.hidden">
<template v-if="hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren)&&!item.alwaysShow"> <template
<app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path, onlyOneChild.query)"> v-if="
<el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}"> hasOneShowingChild(item.children, item) &&
<item :icon="onlyOneChild.meta.icon||(item.meta&&item.meta.icon)" :title="onlyOneChild.meta.title" /> (!onlyOneChild.children || onlyOneChild.noShowingChildren) &&
!item.alwaysShow
"
>
<app-link
v-if="onlyOneChild.meta"
:to="resolvePath(onlyOneChild.path, onlyOneChild.query)"
>
<el-menu-item
:index="resolvePath(onlyOneChild.path)"
:class="{ 'submenu-title-noDropdown': !isNest }"
>
{{ sideTheme }}
<div v-if="onlyOneChild.meta.icon">
<img :src="itmeIcon[onlyOneChild.meta.title]" alt="" />
</div>
<item
:icon="onlyOneChild.meta.icon || (item.meta && item.meta.icon)"
: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, index) in item.children" v-for="(child, index) in item.children"
@ -25,75 +53,90 @@
</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: {
// 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: "",
} },
sideTheme: {},
}, },
data() { data() {
this.onlyOneChild = null this.onlyOneChild = null;
return {} return {
itmeIcon: {
首页: require("@/assets/images/home_N@1x.png"),
患者档案: require("@/assets/images/dangan_n@1x.png"),
诊疗档案: require("@/assets/images/zhenliao_n@1x.png"),
随访档案: require("@/assets/images/suifang_n@1x.png"),
我的: require("@/assets/images/me_n@1x.png"),
},
itmeIcon1: {
首页: require("@/assets/images/home_S@1x.png"),
患者档案: require("@/assets/images/dangan_s@1x.png"),
诊疗档案: require("@/assets/images/zhenliao_s@1x.png"),
随访档案: require("@/assets/images/suifang_s@1x.png"),
我的: require("@/assets/images/me_s@1x.png"),
},
};
}, },
methods: { methods: {
hasOneShowingChild(children = [], parent) { hasOneShowingChild(children = [], parent) {
if (!children) { if (!children) {
children = []; children = [];
} }
const showingChildren = children.filter(item => { const showingChildren = children.filter((item) => {
if (item.hidden) { if (item.hidden) {
return false return false;
} }
// 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, routeQuery) { resolvePath(routePath, routeQuery) {
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 (routeQuery) { if (routeQuery) {
let query = JSON.parse(routeQuery); let query = JSON.parse(routeQuery);
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>

111
acupuncture-前台/src/layout/components/Sidebar/index.vue

@ -1,26 +1,42 @@
<template> <template>
<div :class="{'has-logo':showLogo}" :style="{ backgroundColor: settings.sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground }"> <div
<logo v-if="showLogo" :collapse="isCollapse" /> :class="{ 'has-logo': showLogo }"
<el-scrollbar :class="settings.sideTheme" wrap-class="scrollbar-wrapper"> :style="{
<el-menu backgroundColor:
:default-active="activeMenu" settings.sideTheme === 'theme-dark'
:collapse="isCollapse" ? variables.menuBackground
:background-color="settings.sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground" : variables.menuLightBackground,
:text-color="settings.sideTheme === 'theme-dark' ? variables.menuColor : variables.menuLightColor" }"
:unique-opened="true" >
:active-text-color="settings.theme" <logo v-if="showLogo" :collapse="isCollapse" />
:collapse-transition="false" <el-scrollbar :class="settings.sideTheme" wrap-class="scrollbar-wrapper">
mode="vertical" <el-menu
> :default-active="activeMenu"
<sidebar-item :collapse="isCollapse"
v-for="(route, index) in sidebarRouters" :background-color="
:key="route.path + index" settings.sideTheme === 'theme-dark'
:item="route" ? variables.menuBackground
:base-path="route.path" : variables.menuLightBackground
/> "
</el-menu> :text-color="
</el-scrollbar> settings.sideTheme === 'theme-dark'
</div> ? variables.menuColor
: variables.menuLightColor
"
:unique-opened="true"
:active-text-color="settings.theme"
:collapse-transition="false"
mode="vertical"
>
<sidebar-item
v-for="(route, index) in sidebarRouters"
:key="route.path + index"
:item="route"
:base-path="route.path"
/>
</el-menu>
</el-scrollbar>
</div>
</template> </template>
<script> <script>
@ -30,28 +46,33 @@ import SidebarItem from "./SidebarItem";
import variables from "@/assets/styles/variables.scss"; import variables from "@/assets/styles/variables.scss";
export default { export default {
components: { SidebarItem, Logo }, components: { SidebarItem, Logo },
computed: { computed: {
...mapState(["settings"]), ...mapState(["settings"]),
...mapGetters(["sidebarRouters", "sidebar"]), ...mapGetters(["sidebarRouters", "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() { showLogo() {
return this.$store.state.settings.sidebarLogo; return this.$store.state.settings.sidebarLogo;
}, },
variables() { variables() {
return variables; return variables;
}, },
isCollapse() { isCollapse() {
return !this.sidebar.opened; return !this.sidebar.opened;
} },
} },
}; };
</script> </script>
<style scoped>
>>> .is-active {
background-color: #fff !important;
}
</style>

2
acupuncture-前台/src/store/modules/settings.js

@ -5,7 +5,7 @@ const { sideTheme, showSettings, topNav, tagsView, fixedHeader, sidebarLogo, dyn
const storageSetting = JSON.parse(localStorage.getItem('layout-setting')) || '' const storageSetting = JSON.parse(localStorage.getItem('layout-setting')) || ''
const state = { const state = {
title: '', title: '',
theme: storageSetting.theme || '#409EFF', theme: storageSetting.theme || '#70483E',
sideTheme: storageSetting.sideTheme || sideTheme, sideTheme: storageSetting.sideTheme || sideTheme,
showSettings: showSettings, showSettings: showSettings,
topNav: storageSetting.topNav === undefined ? topNav : storageSetting.topNav, topNav: storageSetting.topNav === undefined ? topNav : storageSetting.topNav,

Loading…
Cancel
Save