|
@@ -3,15 +3,15 @@
|
|
|
<el-sub-menu v-if="subItem.children?.length" :index="subItem.path">
|
|
|
<template #title>
|
|
|
<el-icon v-if="subItem.meta.icon">
|
|
|
- <component :is="subItem.meta.icon"></component>
|
|
|
+ <img class="img-icons" :src="getCustomIcon(isActive(subItem) ? subItem.meta.iconActive : subItem.meta.icon)" />
|
|
|
</el-icon>
|
|
|
- <span class="sle">{{ subItem.meta.title }}</span>
|
|
|
+ <span class="sle" :class="isActive(subItem) ? 'menu-title-active' : 'menu-title'">{{ subItem.meta.title }}</span>
|
|
|
</template>
|
|
|
<SubMenu :menu-list="subItem.children" />
|
|
|
</el-sub-menu>
|
|
|
<el-menu-item v-else :index="subItem.path" @click="handleClickMenu(subItem)">
|
|
|
<el-icon v-if="subItem.meta.icon">
|
|
|
- <component :is="subItem.meta.icon"></component>
|
|
|
+ <img class="img-icons" :src="getCustomIcon(isActive(subItem) ? subItem.meta.iconActive : subItem.meta.icon)" />
|
|
|
</el-icon>
|
|
|
<template #title>
|
|
|
<span class="sle">{{ subItem.meta.title }}</span>
|
|
@@ -22,6 +22,16 @@
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
import { useRouter } from "vue-router";
|
|
|
+import alarm from "@/assets/images/alarm.png";
|
|
|
+import alarmActive from "@/assets/images/alarm-active.png";
|
|
|
+import analysis from "@/assets/images/analysis.png";
|
|
|
+import analysisActive from "@/assets/images/analysis-active.png";
|
|
|
+import query from "@/assets/images/query.png";
|
|
|
+import queryActive from "@/assets/images/query-active.png";
|
|
|
+import system from "@/assets/images/system.png";
|
|
|
+import systemActive from "@/assets/images/system-active.png";
|
|
|
+import maintenance from "@/assets/images/maintenance.png";
|
|
|
+import maintenanceActive from "@/assets/images/maintenance-active.png";
|
|
|
|
|
|
defineProps<{ menuList: Menu.MenuOptions[] }>();
|
|
|
|
|
@@ -30,6 +40,27 @@ const handleClickMenu = (subItem: Menu.MenuOptions) => {
|
|
|
if (subItem.meta.isLink) return window.open(subItem.meta.isLink, "_blank");
|
|
|
router.push(subItem.path);
|
|
|
};
|
|
|
+
|
|
|
+const isActive = (subItem: Menu.MenuOptions) => {
|
|
|
+ const currentPath = router.currentRoute.value.fullPath;
|
|
|
+ return subItem.path === currentPath || subItem.children?.some(child => child.path === currentPath);
|
|
|
+};
|
|
|
+
|
|
|
+const getCustomIcon = (iconName: string) => {
|
|
|
+ const icons = {
|
|
|
+ alarm: alarm,
|
|
|
+ alarmActive: alarmActive,
|
|
|
+ analysis: analysis,
|
|
|
+ analysisActive: analysisActive,
|
|
|
+ query: query,
|
|
|
+ queryActive: queryActive,
|
|
|
+ system: system,
|
|
|
+ systemActive: systemActive,
|
|
|
+ maintenance: maintenance,
|
|
|
+ maintenanceActive: maintenanceActive
|
|
|
+ };
|
|
|
+ return icons[iconName] || null;
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|
|
@@ -37,6 +68,20 @@ const handleClickMenu = (subItem: Menu.MenuOptions) => {
|
|
|
color: var(--el-menu-hover-text-color) !important;
|
|
|
background-color: transparent !important;
|
|
|
}
|
|
|
+.menu-title-active {
|
|
|
+ color: var(--el-menu-active-color) !important;
|
|
|
+}
|
|
|
+
|
|
|
+.menu-title {
|
|
|
+ color: var(--el-menu-hover-text-color) !important;
|
|
|
+}
|
|
|
+
|
|
|
+.img-icons {
|
|
|
+ width: 24px;
|
|
|
+ height: 24px;
|
|
|
+ margin-right: 5px;
|
|
|
+}
|
|
|
+
|
|
|
.el-menu--collapse {
|
|
|
.is-active {
|
|
|
.el-sub-menu__title {
|