diff --git a/src/App.vue b/src/App.vue
index c48f2f5..e5ddb5d 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -1,13 +1,15 @@
-
-
-
-
+
+
+
+
+
@@ -25,7 +27,7 @@ onMounted(() => {
// 将 TopLoading 实例挂载到 window 上,供 api 模块调用
// @ts-ignore
window.__topLoading__ = topLoadingRef.value
-
+
// 检查并恢复标签页状态
tabsStore.validateAndRecoverTabs()
})
diff --git a/src/components/layout/Layout.vue b/src/components/layout/Layout.vue
index 22df770..3aa41ba 100644
--- a/src/components/layout/Layout.vue
+++ b/src/components/layout/Layout.vue
@@ -15,12 +15,12 @@
-
-
+
+
@@ -28,8 +28,8 @@
-
-
+
+
@@ -122,6 +122,7 @@ const handleToggleSidebar = (collapsed: boolean) => {
transition: margin-left 0.3s ease;
.main-content {
+ background-color: #fff;
flex: 1;
overflow-y: auto;
overflow-x: hidden;
diff --git a/src/components/layout/Sidebar.vue b/src/components/layout/Sidebar.vue
index 6f5aca1..2558d17 100644
--- a/src/components/layout/Sidebar.vue
+++ b/src/components/layout/Sidebar.vue
@@ -7,10 +7,11 @@
:default-active="activeMenu"
:collapse="collapsed"
router
+ @select="handleSelect"
>
-
+
@@ -18,7 +19,7 @@
-
+
@@ -28,7 +29,7 @@
{{ subMenu.label }}
@@ -49,6 +50,7 @@ import {
WarningFilled,
Tools,
} from '@element-plus/icons-vue'
+import { ElMessage } from 'element-plus'
import { useUserStore } from '@/stores/modules/user'
defineProps<{
@@ -56,6 +58,7 @@ defineProps<{
}>()
const route = useRoute()
+const router = useRouter()
const userStore = useUserStore()
// 计算当前激活的菜单 index
@@ -68,6 +71,24 @@ const menuList = computed(() => {
return userStore.sideMenu || []
})
+// 菜单点击处理:
+// el-menu 在 router 模式下会根据 :index 跳路径,但当路径在动态路由表中不存在时,
+// 会触发 :pathMatch(.*)* 兑底被重定向到 /dashboard,造成“点了菜单没反应、过一会自动刷新”。
+// 这里加一道护栏:路径为空、或者未在已注册路由表中存在时,提示用户并取消跳转。
+const handleSelect = (index: string) => {
+ if (!index || index.startsWith('__invalid_')) {
+ ElMessage.warning('该菜单暂未配置访问路径,请联系管理员')
+ return false
+ }
+ // 检查路由表中是否已存在该路径
+ const hasExact = router.getRoutes().some((r) => r.path === index)
+ if (!hasExact) {
+ ElMessage.warning('该页面路由未加载,请稍后重试')
+ return false
+ }
+ return true
+}
+
// 图标映射表
const iconMap: Record = {
HomeFilled,
@@ -84,11 +105,11 @@ const iconMap: Record = {