Jelajahi Sumber

修正节目审核页面侧边栏为空的bug

Shinohara Haruna 6 bulan lalu
induk
melakukan
7e42532937
1 mengubah file dengan 10 tambahan dan 4 penghapusan
  1. 10 4
      smsb-plus-ui/src/layout/components/Sidebar/index.vue

+ 10 - 4
smsb-plus-ui/src/layout/components/Sidebar/index.vue

@@ -26,15 +26,21 @@ const appStore = useAppStore();
 const settingsStore = useSettingsStore();
 const permissionStore = usePermissionStore();
 // 只显示当前一级菜单下的二级菜单
-const topMenus = computed(() => permissionStore.getTopbarRoutes().filter(menu => menu.hidden !== true));
+const topMenus = computed(() => permissionStore.getTopbarRoutes().filter((menu) => menu.hidden !== true));
 const currentTopMenuPath = computed(() => {
+  // 特例:如果当前路由是 approval,则返回 /source 作为一级菜单
+  if (route.path === '/source/push/approval') {
+    return '/source';
+  }
   // 取当前路由的一级菜单 path
   const matched = route.matched?.[0];
-  return matched && matched.path !== '/' ? matched.path : (topMenus.value[0]?.path || '/');
+  // console.log("[Sidebar] matched", matched);
+  // console.log("[Sidebar] ret", matched && matched.path !== '/' ? matched.path : (topMenus.value[0]?.path || '/'));
+  return matched && matched.path !== '/' ? matched.path : topMenus.value[0]?.path || '/';
 });
 const sidebarRouters = computed<RouteRecordRaw[]>(() => {
-  const topMenu = topMenus.value.find(menu => menu.path === currentTopMenuPath.value);
-  return topMenu && topMenu.children ? topMenu.children.filter(item => item.hidden !== true) : [];
+  const topMenu = topMenus.value.find((menu) => menu.path === currentTopMenuPath.value);
+  return topMenu && topMenu.children ? topMenu.children.filter((item) => item.hidden !== true) : [];
 });
 const showLogo = computed(() => settingsStore.sidebarLogo);
 const sideTheme = computed(() => settingsStore.sideTheme);