|
|
@@ -577,9 +577,21 @@ async function handleLogout() {
|
|
|
router.push('/login')
|
|
|
}
|
|
|
|
|
|
+// 根据当前路由自动展开菜单
|
|
|
+function initExpandedMenus() {
|
|
|
+ menuItems.forEach((item) => {
|
|
|
+ if (item.children && item.children.some((child) => route.path.startsWith(child.path))) {
|
|
|
+ if (!expandedMenus.value.includes(item.path)) {
|
|
|
+ expandedMenus.value.push(item.path)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
userStore.getUserInfo()
|
|
|
checkMobile()
|
|
|
+ initExpandedMenus()
|
|
|
window.addEventListener('resize', checkMobile)
|
|
|
document.addEventListener('click', closeUserMenu)
|
|
|
})
|