Commit 4e61f073 authored by 纪泽龙's avatar 纪泽龙

解决更多菜单的全局样式污染冲突问题

parent 66f00fdd
#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;
} }
.sidebar-container { .sidebar-container {
-webkit-transition: width .28s; -webkit-transition: width 0.28s;
transition: width 0.28s; transition: width 0.28s;
width: $sideBarWidth !important; width: $sideBarWidth !important;
background-color: #053B6A; background-color: #053b6a;
height: 100%; height: 100%;
position: fixed; position: fixed;
font-size: 0px; font-size: 0px;
...@@ -20,28 +19,44 @@ ...@@ -20,28 +19,44 @@
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);
.el-menu-item{ .el-menu-item {
padding: 0px !important; padding: 0px !important;
margin-top: 5px; margin-top: 5px;
height: 84px; height: 84px;
line-height: 30px !important; line-height: 30px !important;
text-align: center; text-align: center;
.svg-icon{ .svg-icon {
margin-top: 10px; margin-top: 10px;
font-size: 30px; font-size: 30px;
// width: 30px !important; // width: 30px !important;
} }
} }
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,
transition: 0s width ease-in-out, 0s padding-left ease-in-out, 0s padding-right ease-in-out; 0s padding-right ease-in-out;
} }
.scrollbar-wrapper { .scrollbar-wrapper {
overflow-x: hidden !important; overflow-x: hidden !important;
.el-menu-item:focus,
.is-active {
outline: none;
// background-image: url(/static/img/item-background.0ec28f27.png);
background-repeat: no-repeat;
background-size: 100% 100%;
/* background: rgba(0, 0, 0, 0); */
color: #31eaea !important;
}
.el-menu-item:hover {
outline: none;
// background-image: url(/static/img/item-background.0ec28f27.png);
background-repeat: no-repeat;
background-size: 100% 100%;
/* background: rgba(0, 0, 0, 0); */
color: #31eaea !important;
}
} }
.el-scrollbar__bar.is-vertical { .el-scrollbar__bar.is-vertical {
...@@ -73,13 +88,14 @@ ...@@ -73,13 +88,14 @@
} }
.el-menu { .el-menu {
background-color: #053B6A; background-color: #053b6a;
border: none; border: none;
height: 100%; height: 100%;
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;
...@@ -97,7 +113,7 @@ ...@@ -97,7 +113,7 @@
color: #fff !important; color: #fff !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: $sideBarWidth !important; min-width: $sideBarWidth !important;
...@@ -106,9 +122,9 @@ ...@@ -106,9 +122,9 @@
} }
} }
& .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: #053B6A !important; background-color: #053b6a !important;
&:hover { &:hover {
background-color: rgba(0, 0, 0, 0.06) !important; background-color: rgba(0, 0, 0, 0.06) !important;
...@@ -141,20 +157,19 @@ ...@@ -141,20 +157,19 @@
.el-submenu { .el-submenu {
overflow: hidden; overflow: hidden;
&>.el-submenu__title { & > .el-submenu__title {
padding: 0 0 !important; padding: 0 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;
...@@ -177,7 +192,7 @@ ...@@ -177,7 +192,7 @@
} }
.sidebar-container { .sidebar-container {
transition: transform .28s; transition: transform 0.28s;
width: $sideBarWidth !important; width: $sideBarWidth !important;
} }
...@@ -191,7 +206,6 @@ ...@@ -191,7 +206,6 @@
} }
.withoutAnimation { .withoutAnimation {
.main-container, .main-container,
.sidebar-container { .sidebar-container {
transition: none; transition: none;
...@@ -201,13 +215,13 @@ ...@@ -201,13 +215,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
...@@ -216,7 +230,7 @@ ...@@ -216,7 +230,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;
......
...@@ -4,9 +4,13 @@ ...@@ -4,9 +4,13 @@
<svg-icon class-name="size-icon" icon-class="size" /> <svg-icon class-name="size-icon" icon-class="size" />
</div> </div>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item v-for="item of sizeOptions" :key="item.value" :disabled="size===item.value" :command="item.value"> <el-dropdown-item
{{ v-for="item of sizeOptions"
item.label }} :key="item.value"
:disabled="size === item.value"
:command="item.value"
>
{{ item.label }}
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
...@@ -17,41 +21,40 @@ export default { ...@@ -17,41 +21,40 @@ export default {
data() { data() {
return { return {
sizeOptions: [ sizeOptions: [
{ label: 'Default', value: 'default' }, { label: "Default", value: "default" },
{ label: 'Medium', value: 'medium' }, { label: "Medium", value: "medium" },
{ label: 'Small', value: 'small' }, { label: "Small", value: "small" },
{ label: 'Mini', value: 'mini' } { label: "Mini", value: "mini" },
] ],
} };
}, },
computed: { computed: {
size() { size() {
return this.$store.getters.size return this.$store.getters.size;
} },
}, },
methods: { methods: {
handleSetSize(size) { handleSetSize(size) {
this.$ELEMENT.size = size this.$ELEMENT.size = size;
this.$store.dispatch('app/setSize', size) this.$store.dispatch("app/setSize", size);
this.refreshView() this.refreshView();
this.$message({ this.$message({
message: 'Switch Size Success', message: "Switch Size Success",
type: 'success' type: "success",
}) });
}, },
refreshView() { refreshView() {
// In order to make the cached page re-rendered // In order to make the cached page re-rendered
this.$store.dispatch('tagsView/delAllCachedViews', this.$route) this.$store.dispatch("tagsView/delAllCachedViews", this.$route);
const { fullPath } = this.$route const { fullPath } = this.$route;
this.$nextTick(() => { this.$nextTick(() => {
this.$router.replace({ this.$router.replace({
path: '/redirect' + fullPath path: "/redirect" + fullPath,
}) });
}) });
} },
} },
};
}
</script> </script>
...@@ -20,10 +20,16 @@ ...@@ -20,10 +20,16 @@
</template> </template>
<!-- 顶部菜单超出数量折叠 --> <!-- 顶部菜单超出数量折叠 -->
<el-submenu index="more" v-if="topMenus.length > visibleNumber"> <!-- <div> -->
<el-submenu
class="onlyNavTio"
index="more"
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
class="navTopBar"
:index="item.path" :index="item.path"
:key="index" :key="index"
v-if="index >= visibleNumber" v-if="index >= visibleNumber"
...@@ -32,6 +38,7 @@ ...@@ -32,6 +38,7 @@
> >
</template> </template>
</el-submenu> </el-submenu>
<!-- </div> -->
</el-menu> </el-menu>
</template> </template>
...@@ -225,6 +232,45 @@ export default { ...@@ -225,6 +232,45 @@ export default {
} }
} }
// 》〉》〉》导航的样式调整
.navTopBar {
// background-color: red !important;
width: 110px !important;
background-color: #053b6a !important;
text-align: center !important;
color: #fff !important;
&:hover {
color: #fff !important;
outline: none;
background-image: url("../../assets/logo/item-background.png");
background-repeat: no-repeat;
background-size: 100% 100%;
/* background: rgba(0, 0, 0, 0); */
color: #31eaea !important;
}
}
.navTopBar:focus,
.navTopBar.is-active {
outline: none;
background-image: url("../../assets/logo/item-background.png");
background-repeat: no-repeat;
background-size: 100% 100%;
/* background: rgba(0, 0, 0, 0); */
color: #31eaea !important;
}
.el-menu--popup {
z-index: 100;
min-width: 120px;
border: none;
padding: 5px;
border-radius: 2px;
-webkit-box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
background-color: #053b6a;
}
// 》〉》〉》导航的样式
.el-menu--horizontal > .el-menu-item.is-active { .el-menu--horizontal > .el-menu-item.is-active {
border-bottom: 3px solid #{"var(--theme)"}; border-bottom: 3px solid #{"var(--theme)"};
/* box-shadow: inset 2px 2px 20px #5CD9D4; */ /* box-shadow: inset 2px 2px 20px #5CD9D4; */
...@@ -235,8 +281,8 @@ export default { ...@@ -235,8 +281,8 @@ export default {
.el-menu--horizontal > .el-submenu .el-submenu__title { .el-menu--horizontal > .el-submenu .el-submenu__title {
height: 50px !important; height: 50px !important;
line-height: 50px !important; line-height: 50px !important;
border:none !important; border: none !important;
margin-left:15px; margin-left: 15px;
} }
.el-menu--horizontal > .el-menu-item:not(.is-disabled):hover, .el-menu--horizontal > .el-menu-item:not(.is-disabled):hover,
.el-menu--horizontal > .el-menu-item:not(.is-disabled):focus { .el-menu--horizontal > .el-menu-item:not(.is-disabled):focus {
...@@ -258,7 +304,7 @@ export default { ...@@ -258,7 +304,7 @@ export default {
rgba(0, 0, 0, 0) 100% rgba(0, 0, 0, 0) 100%
); );
} }
.submenu-title-noDropdown{ .submenu-title-noDropdown {
color: rgb(5 59 106) !important; color: rgb(5 59 106) !important;
font-weight: 900 !important; font-weight: 900 !important;
} }
......
<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
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 :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}"> <el-menu-item
<item :icon="onlyOneChild.meta.icon||(item.meta&&item.meta.icon)"/><br> :index="resolvePath(onlyOneChild.path)"
:class="{ 'submenu-title-noDropdown': !isNest }"
>
<item
:icon="onlyOneChild.meta.icon || (item.meta && item.meta.icon)"
/><br />
<!-- <item :title="onlyOneChild.meta.title" /> --> <!-- <item :title="onlyOneChild.meta.title" /> -->
{{onlyOneChild.meta.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"
...@@ -27,135 +47,142 @@ ...@@ -27,135 +47,142 @@
</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: "",
} },
}, },
data() { data() {
this.onlyOneChild = null this.onlyOneChild = null;
return {} return {};
}, },
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;
} 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;
}
return path.resolve(this.basePath, routePath)
} }
} return path.resolve(this.basePath, routePath);
} },
},
};
</script> </script>
<style lang="scss"> <style lang="scss">
#app .sidebar-container .submenu-title-noDropdown:hover, #app .sidebar-container .el-submenu__title:hover { #app .sidebar-container .submenu-title-noDropdown:hover,
#app .sidebar-container .el-submenu__title:hover {
/* box-shadow: inset 2px 2px 20px #5CD9D4; */ /* box-shadow: inset 2px 2px 20px #5CD9D4; */
background: rgba(0, 0, 0, 0); background: rgba(0, 0, 0, 0);
} }
#app .sidebar-container .el-menu-item, #app .sidebar-container .el-submenu__title { #app .sidebar-container .el-menu-item,
#app .sidebar-container .el-submenu__title {
overflow: hidden !important; overflow: hidden !important;
text-overflow: ellipsis !important; text-overflow: ellipsis !important;
background: rgba(0, 0, 0, 0); background: rgba(0, 0, 0, 0);
} }
.el-menu-item:hover { // 顶部导航的样式
.navbar {
.el-menu-item:hover {
outline: none; outline: none;
background-image: url("../../../assets/logo/item-background.png"); background-image: url("../../../assets/logo/item-background.png");
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: 100% 100%; background-size: 100% 100%;
/* background: rgba(0, 0, 0, 0); */ /* background: rgba(0, 0, 0, 0); */
color: #31EAEA !important; color: #31eaea !important;
} }
.el-menu-item:focus,.is-active { .el-menu-item:focus,
.is-active {
outline: none; outline: none;
background-image: url("../../../assets/logo/item-background.png"); background-image: url("../../../assets/logo/item-background.png");
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: 100% 100%; background-size: 100% 100%;
/* background: rgba(0, 0, 0, 0); */ /* background: rgba(0, 0, 0, 0); */
color: #31EAEA !important; color: #31eaea !important;
} }
.el-menu--horizontal > .el-submenu .el-submenu__title:hover { .el-menu--horizontal > .el-submenu .el-submenu__title:hover {
background-color: rgba(0, 0, 0, 0); background-color: rgba(0, 0, 0, 0);
color: #fff; color: #fff;
background-image: url("../../../assets/logo/item-background.png"); background-image: url("../../../assets/logo/item-background.png");
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: 100% 100%; background-size: 100% 100%;
} }
.el-menu--horizontal > .el-submenu .el-submenu__title { .el-menu--horizontal > .el-submenu .el-submenu__title {
height: 50px !important; height: 50px !important;
line-height: 50px !important; line-height: 50px !important;
margin-top: 15px; margin-top: 15px;
font-size: 22px; font-size: 22px;
font-weight: 600; font-weight: 600;
color: #fff; color: #fff;
} }
.el-menu--horizontal > .el-submenu:focus .el-submenu__title, .el-menu--horizontal > .el-submenu:hover .el-submenu__title { .el-menu--horizontal > .el-submenu:focus .el-submenu__title,
.el-menu--horizontal > .el-submenu:hover .el-submenu__title {
color: #fff; color: #fff;
} }
.el-menu--horizontal > .el-submenu.is-active .el-submenu__title { .el-menu--horizontal > .el-submenu.is-active .el-submenu__title {
border-bottom: 0px solid; border-bottom: 0px solid;
color: #fff; color: #fff;
} }
.el-submenu__title i { .el-submenu__title i {
color: #fff; color: #fff;
} }
.el-menu--horizontal .el-menu .el-menu-item, .el-menu--horizontal .el-menu .el-submenu__title { .el-menu--horizontal .el-menu .el-menu-item,
background-color: #053B6A; .el-menu--horizontal .el-menu .el-submenu__title {
background-color: #053b6a;
float: none; float: none;
height: 36px; height: 36px;
line-height: 36px; line-height: 36px;
padding: 0; padding: 0;
color: #fff; color: #fff;
} }
.el-menu--popup { .el-menu--popup {
z-index: 100; z-index: 100;
min-width: 120px; min-width: 120px;
border: none; border: none;
...@@ -163,6 +190,9 @@ export default { ...@@ -163,6 +190,9 @@ export default {
border-radius: 2px; border-radius: 2px;
-webkit-box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%); -webkit-box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%); box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
background-color: #053B6A; background-color: #053b6a;
}
} }
// 》〉》〉》〉顶部导航的样式
</style> </style>
\ No newline at end of file
...@@ -117,6 +117,7 @@ class gaodeMap { ...@@ -117,6 +117,7 @@ class gaodeMap {
if (this.handleInfoWindowOpenFunc) { if (this.handleInfoWindowOpenFunc) {
this.handleInfoWindowOpenFunc(); this.handleInfoWindowOpenFunc();
this.handleInfoWindowOpenFunc = null; this.handleInfoWindowOpenFunc = null;
this.leftListClick=false;
} }
// 刚进入页面的时候只调用一次,让左侧的抽屉在地图移动完之后显示 // 刚进入页面的时候只调用一次,让左侧的抽屉在地图移动完之后显示
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment