chauncey 1 рік тому
батько
коміт
8c3755f137
2 змінених файлів з 5 додано та 37 видалено
  1. 0 32
      src/components/Nav.vue
  2. 5 5
      src/layout/MenuLayout.vue

+ 0 - 32
src/components/Nav.vue

@@ -43,14 +43,11 @@
   import Login from '@/components/Login.vue';
   import UserInfo from '@/components/UserInfo.vue';
   import { useGlobSetting } from '@/hooks/setting';
-
-  // import { storeToRefs } from 'pinia';
   import { useUserStore } from '@/store/modules/user';
 
   const userStore = useUserStore();
   const activeNav = ref(NAV_LIST[0].name);
   const router = useRouter();
-  // const showLogin = ref(false);
   const searchValue = ref('');
   const loginType = ref<'login' | 'switchAccount' | 'modifyPassword'>('login');
 
@@ -66,44 +63,15 @@
   const currentRoute = useRoute();
   const { title } = useGlobSetting();
 
-<<<<<<< HEAD
-  const handleNavClick = (item: any) => {
-=======
   const handleNavClick = (item: { name: string; path: string }) => {
-    // 如果不是首页,先检查用户是否登录
-    // if (item.name !== '首页' && !userInfo.value) {
-    //   handleLogin('login');
-    //   return;
-    // }
->>>>>>> 9bcd636 (fix: 完成了未登录情况下顶级路由高亮显示问题)
     if (!item.path) return;
     activeNav.value = item.name;
     router.push(item.path);
   };
 
-<<<<<<< HEAD
-=======
-  console.log('currentRoute', currentRoute);
-
->>>>>>> 9bcd636 (fix: 完成了未登录情况下顶级路由高亮显示问题)
   const selectedKey = computed(() => {
     return currentRoute.matched[0]?.name;
   });
-<<<<<<< HEAD
-=======
-
-  // 跟随页面路由变化,切换菜单选中状态
-  // watch(
-  //   () => currentRoute.fullPath,
-  //   () => {
-  //     updateMenu();
-  //     const matched = currentRoute.matched;
-  //     openKeys.value = matched.map((item) => item.name);
-  //     const activeMenu: string = (currentRoute.meta?.activeMenu as string) || '';
-  //     selectedKeys.value = activeMenu ? activeMenu : (currentRoute.name as string);
-  //   },
-  // );
->>>>>>> 9bcd636 (fix: 完成了未登录情况下顶级路由高亮显示问题)
 </script>
 
 <style lang="scss" scoped>

+ 5 - 5
src/layout/MenuLayout.vue

@@ -6,18 +6,18 @@
         <template v-for="item in subMenus" :key="item.path">
           <el-sub-menu v-if="item.children" :index="item.path">
             <template #title>
-              <component v-if="item.meta.icon" :is="item.meta.icon" />
-              <span class="menu-title">{{ item.meta.title }}</span>
+              <component v-if="item.meta?.icon" :is="item.meta.icon" />
+              <span class="menu-title">{{ item.meta?.title }}</span>
             </template>
             <el-menu-item v-for="child in item.children" :key="child.path" :index="child.path">
-              {{ child.meta.title }}
+              {{ child.meta?.title }}
             </el-menu-item>
           </el-sub-menu>
           <el-menu-item v-else :index="item.path">
             <!-- <SvgIcon icon-name="overview" /> -->
-            <component v-if="item.meta.icon" :is="item.meta.icon" />
+            <component v-if="item.meta?.icon" :is="item.meta?.icon" />
             <span class="menu-title">
-              {{ item.meta.title }}
+              {{ item.meta?.title }}
             </span>
           </el-menu-item>
         </template>