فهرست منبع

fix: 修复菜单路由匹配问题

cuiyalong 10 ماه پیش
والد
کامیت
2252a0d5f3
1فایلهای تغییر یافته به همراه4 افزوده شده و 3 حذف شده
  1. 4 3
      frontend/src/App.vue

+ 4 - 3
frontend/src/App.vue

@@ -8,14 +8,14 @@
         </el-icon>
       </div>
       <el-menu
-        :default-active="activeIndex"
+        :default-active="defaultActiveMenu"
         class="el-menu-vertical-demo"
         :collapse="isCollapse"
         background-color="#333"
         text-color="#fff"
         router
         active-text-color="#ffd04b">
-        <el-menu-item v-for="menu in menuList" :key="menu.path" :index="menu.path" :default-active="activeIndex">
+        <el-menu-item v-for="menu in menuList" :key="menu.path" :index="menu.path">
           <el-icon><component :is="menu.icon" style="width:20px;height:20px;" /></el-icon>
           <span slot="title">{{ menu.title }}</span>
         </el-menu-item>
@@ -55,7 +55,6 @@ const store = useStore()
 const router = useRouter()
 
 const isCollapse = ref(false);
-const activeIndex = ref('/');
 const sidebarWidth = ref('140px');
 
 function toggleSidebar() {
@@ -68,6 +67,8 @@ const menuList = computed(() => store.getters.getCurrentMenu)
 const userName = computed(() => store.state.userInfo.s_fullname)
 const userRole = computed(() => store.getters.userRole)
 const showLogoutModule = computed(() => store.state.isAuthenticated)
+const defaultActiveMenu = computed(() => menuList.value[0]?.path || '/')
+
 const doLogout = () => {
   router.replace({ name: 'logout' })
 }