From f1336af7af2225820ac9a8dc6dfcf501e4d4cd7b Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期三, 06 十二月 2023 09:05:16 +0800
Subject: [PATCH] 系统左侧菜单,hover背景色bug处理
---
Source/UBCS-WEB/src/config/website.js | 4
Source/UBCS-WEB/src/page/index/sidebar/sidebarItem.vue | 220 ++++++++++++++++++++++++++++--------------------------
Source/UBCS-WEB/src/styles/sidebar.scss | 8 +-
Source/UBCS-WEB/src/page/index/sidebar/index.vue | 1
4 files changed, 119 insertions(+), 114 deletions(-)
diff --git a/Source/UBCS-WEB/src/config/website.js b/Source/UBCS-WEB/src/config/website.js
index b4ecaac..9c6c3db 100644
--- a/Source/UBCS-WEB/src/config/website.js
+++ b/Source/UBCS-WEB/src/config/website.js
@@ -38,7 +38,7 @@
label: 'name',
path: 'path',
icon: 'source',
- children: 'children'
+ children: 'children',
}
},
// 绗笁鏂圭郴缁熸巿鏉冨湴鍧�
@@ -49,4 +49,4 @@
ssoUrl:'http://localhost:37000/ubcs-auth/oauth/authorize?client_id=sword&response_type=111&redirect_uri=',
// 鍗曠偣鐧诲綍鍥炶皟鍦板潃(Saber鏈嶅姟鐨勫湴鍧�)
redirectUri: 'http://localhost:38000',
-}
\ No newline at end of file
+}
diff --git a/Source/UBCS-WEB/src/page/index/sidebar/index.vue b/Source/UBCS-WEB/src/page/index/sidebar/index.vue
index 476af59..587d39a 100644
--- a/Source/UBCS-WEB/src/page/index/sidebar/index.vue
+++ b/Source/UBCS-WEB/src/page/index/sidebar/index.vue
@@ -51,6 +51,5 @@
.title{
color: red;
}
-
</style>
diff --git a/Source/UBCS-WEB/src/page/index/sidebar/sidebarItem.vue b/Source/UBCS-WEB/src/page/index/sidebar/sidebarItem.vue
index 2693e31..5914522 100644
--- a/Source/UBCS-WEB/src/page/index/sidebar/sidebarItem.vue
+++ b/Source/UBCS-WEB/src/page/index/sidebar/sidebarItem.vue
@@ -2,145 +2,151 @@
<div class="menu-wrapper">
<template v-for="item in menu">
<el-menu-item v-if="validatenull(item[childrenKey]) && vaildRoles(item)"
- :index="item[pathKey]"
- @click="open(item)"
:key="item[labelKey]"
- :class="{'is-active':vaildActive(item)}">
+ :class="{'is-active':vaildActive(item)}"
+ :index="item[pathKey]"
+ @click="open(item)">
<i :class="item[iconKey]"></i>
<span slot="title"
- :alt="item[pathKey]">{{generateTitle(item)}}</span>
+ :alt="item[pathKey]">{{ generateTitle(item) }}</span>
</el-menu-item>
<el-submenu v-else-if="!validatenull(item[childrenKey])&&vaildRoles(item)"
- :index="item[pathKey]"
- :key="item[labelKey]">
+ :key="item[labelKey]"
+ :index="item[pathKey]">
<template slot="title">
<i :class="item[iconKey]"></i>
<span slot="title"
- :class="{'el-menu--display':collapse && first}">{{generateTitle(item)}}</span>
+ :class="{'el-menu--display':collapse && first}">{{ generateTitle(item) }}</span>
</template>
<template v-for="(child,cindex) in item[childrenKey]">
- <el-menu-item :index="child[pathKey],cindex"
- @click="open(child)"
+ <el-menu-item v-if="validatenull(child[childrenKey])"
+ :key="child[labelKey]"
:class="{'is-active':vaildActive(child)}"
- v-if="validatenull(child[childrenKey])"
- :key="child[labelKey]">
+ :index="child[pathKey],cindex"
+ @click="open(child)">
<i :class="child[iconKey]"></i>
- <span slot="title">{{generateTitle(child)}}</span>
+ <span slot="title">{{ generateTitle(child) }}</span>
</el-menu-item>
<sidebar-item v-else
- :menu="[child]"
:key="cindex"
+ :collapse="collapse"
+ :menu="[child]"
:props="props"
- :screen="screen"
- :collapse="collapse"></sidebar-item>
+ :screen="screen"></sidebar-item>
</template>
</el-submenu>
</template>
</div>
</template>
<script>
- import {mapGetters} from "vuex";
- import {isURL, validatenull} from "@/util/validate";
- import config from "./config.js";
+import {mapGetters} from "vuex";
+import {isURL, validatenull} from "@/util/validate";
+import config from "./config.js";
- export default {
- name: "sidebarItem",
- data() {
- return {
- config: config
- };
+export default {
+ name: "sidebarItem",
+ data() {
+ return {
+ config: config
+ };
+ },
+ props: {
+ menu: {
+ type: Array
+ },
+ screen: {
+ type: Number
+ },
+ first: {
+ type: Boolean,
+ default: false
},
props: {
- menu: {
- type: Array
- },
- screen: {
- type: Number
- },
- first: {
- type: Boolean,
- default: false
- },
- props: {
- type: Object,
- default: () => {
- return {};
- }
- },
- collapse: {
- type: Boolean
+ type: Object,
+ default: () => {
+ return {};
}
},
- created() {
+ collapse: {
+ type: Boolean
+ }
+ },
+ created() {
+ },
+ mounted() {
+ },
+ computed: {
+ ...mapGetters(["roles"]),
+ labelKey() {
+ return this.props.label || this.config.propsDefault.label;
},
- mounted() {
+ pathKey() {
+ return this.props.path || this.config.propsDefault.path;
},
- computed: {
- ...mapGetters(["roles"]),
- labelKey() {
- return this.props.label || this.config.propsDefault.label;
- },
- pathKey() {
- return this.props.path || this.config.propsDefault.path;
- },
- iconKey() {
- return this.props.icon || this.config.propsDefault.icon;
- },
- childrenKey() {
- return this.props.children || this.config.propsDefault.children;
- },
- isOpenKey() {
- return this.props.isOpen || this.config.propsDefault.isOpen;
- },
- nowTagValue() {
- return this.$router.$avueRouter.getValue(this.$route);
+ iconKey() {
+ return this.props.icon || this.config.propsDefault.icon;
+ },
+ childrenKey() {
+ return this.props.children || this.config.propsDefault.children;
+ },
+ isOpenKey() {
+ return this.props.isOpen || this.config.propsDefault.isOpen;
+ },
+ nowTagValue() {
+ return this.$router.$avueRouter.getValue(this.$route);
+ }
+ },
+ methods: {
+ generateTitle(item) {
+ return this.$router.$avueRouter.generateTitle(
+ item[this.labelKey],
+ (item.meta || {}).i18n
+ );
+ },
+ vaildActive(item) {
+ if (this.validIsOpen(item)) {
+ return false;
+ }
+ const groupFlag = (item["group"] || []).some(ele =>
+ this.$route.path.includes(ele)
+ );
+ return this.nowTagValue === item[this.pathKey] || groupFlag;
+ },
+ vaildRoles(item) {
+ item.meta = item.meta || {};
+ return item.meta.roles ? item.meta.roles.includes(this.roles) : true;
+ },
+ validatenull(val) {
+ return validatenull(val);
+ },
+ validIsOpen(item) {
+ if (item[this.isOpenKey] === 2 && isURL(item[this.pathKey])) {
+ return true;
}
},
- methods: {
- generateTitle(item) {
- return this.$router.$avueRouter.generateTitle(
- item[this.labelKey],
- (item.meta || {}).i18n
- );
- },
- vaildActive(item) {
- if (this.validIsOpen(item)) {
- return false;
- }
- const groupFlag = (item["group"] || []).some(ele =>
- this.$route.path.includes(ele)
- );
- return this.nowTagValue === item[this.pathKey] || groupFlag;
- },
- vaildRoles(item) {
- item.meta = item.meta || {};
- return item.meta.roles ? item.meta.roles.includes(this.roles) : true;
- },
- validatenull(val) {
- return validatenull(val);
- },
- validIsOpen(item) {
- if (item[this.isOpenKey] === 2 && isURL(item[this.pathKey])) {
- return true;
- }
- },
- open(item) {
- if (this.screen <= 1) this.$store.commit("SET_COLLAPSE");
- if (this.validIsOpen(item)) {
- window.open(item[this.pathKey]);
- } else {
- this.$router.$avueRouter.group = item.group;
- this.$router.$avueRouter.meta = item.meta;
- this.$router.push({
- path: this.$router.$avueRouter.getPath({
- name: item[this.labelKey],
- src: item[this.pathKey]
- }, item.meta),
- query: item.query
- });
- }
+ open(item) {
+ if (this.screen <= 1) this.$store.commit("SET_COLLAPSE");
+ if (this.validIsOpen(item)) {
+ window.open(item[this.pathKey]);
+ } else {
+ this.$router.$avueRouter.group = item.group;
+ this.$router.$avueRouter.meta = item.meta;
+ this.$router.push({
+ path: this.$router.$avueRouter.getPath({
+ name: item[this.labelKey],
+ src: item[this.pathKey]
+ }, item.meta),
+ query: item.query
+ });
}
}
- };
+ }
+};
</script>
+<style lang="scss" scoped>
+.el-menu-item:focus, .el-menu-item:hover {
+ outline: 0;
+ background-color: #060708;
+}
+</style>
diff --git a/Source/UBCS-WEB/src/styles/sidebar.scss b/Source/UBCS-WEB/src/styles/sidebar.scss
index f4995d7..3ceec84 100644
--- a/Source/UBCS-WEB/src/styles/sidebar.scss
+++ b/Source/UBCS-WEB/src/styles/sidebar.scss
@@ -27,10 +27,10 @@
}
}
}
-
+
}
.avue-sidebar {
- user-select: none;
+ user-select: none;
position: relative;
padding-top: 60px;
height: 100%;
@@ -87,5 +87,5 @@
}
}
}
-
-}
\ No newline at end of file
+
+}
--
Gitblit v1.9.3