Browse Source

feat: 父菜单过滤

ystl_myq 8 months ago
parent
commit
8346787b22

+ 5 - 2
src/components/echarts/radar.vue

@@ -16,9 +16,12 @@ const { setOptions } = useECharts(chartRef, { theme });
 setOptions({
   tooltip: {},
   legend: {
+    // icon: "arrow",
+    itemWidth: 25,
+    itemHeight: 4,
+    data: ["得分率"],
     top: 10,
-    left: "left",
-    data: ["得分率"]
+    left: "left"
   },
   radar: {
     radius: "70%", // 调整半径以使雷达图更大

+ 11 - 1
src/layout/components/sidebar/mixNav.vue

@@ -14,6 +14,15 @@ import LogoutCircleRLine from "@iconify-icons/ri/logout-circle-r-line";
 import Setting from "@iconify-icons/ri/settings-3-line";
 const router = useRouter();
 const menuRef = ref();
+// 过滤父级菜单
+const menuActiveRef = ref([]);
+usePermissionStoreHook().wholeMenus.forEach(item => {
+  if (item.meta.filterMenu) {
+  } else {
+    menuActiveRef.value.push(item);
+  }
+});
+// -
 const defaultActive = ref(null);
 
 const {
@@ -39,6 +48,7 @@ function getDefaultActive(routePath) {
 
 onMounted(() => {
   getDefaultActive(route.path);
+  console.log("route.path", usePermissionStoreHook().wholeMenus);
 });
 
 nextTick(() => {
@@ -72,7 +82,7 @@ const changePassword = () => {
       :default-active="defaultActive"
     >
       <el-menu-item
-        v-for="route in usePermissionStoreHook().wholeMenus"
+        v-for="route in menuActiveRef"
         :key="route.path"
         :index="resolvePath(route) || route.redirect"
       >

+ 3 - 1
src/router/modules/password.ts

@@ -3,7 +3,9 @@ export default {
   path: "/password",
   meta: {
     title: "账号与密码",
-    showLink: false
+    // 是否在主菜单显示父级路由 仅支持mixNav
+    filterMenu: true
+    // showLink: false
   },
   children: [
     {

+ 2 - 0
types/router.d.ts

@@ -92,6 +92,8 @@ declare global {
       icon?: string | FunctionalComponent | IconifyIcon;
       /** 是否在菜单中显示(默认`true`)`可选` */
       showLink?: boolean;
+      // 是否过滤父级菜单
+      filterMenu?: boolean;
       /** 菜单升序排序,值越高排的越后(只针对顶级路由)`可选` */
       rank?: number;
     };