From 83d251608828d17dbb9a8d480c13a1a7c0a20eb5 Mon Sep 17 00:00:00 2001
From: 祖安之光 <11848914+light-of-zuan@user.noreply.gitee.com>
Date: Wed, 29 Apr 2026 16:20:18 +0800
Subject: [PATCH] 修改主页跳转
---
src/permission.js | 35 ++++++++++++++++++++++++++++++++++-
1 files changed, 34 insertions(+), 1 deletions(-)
diff --git a/src/permission.js b/src/permission.js
index 0628d25..9eac69c 100644
--- a/src/permission.js
+++ b/src/permission.js
@@ -1,5 +1,5 @@
import router from './router'
-import { ElMessage } from 'element-plus'
+import { ElMessage, ElLoading } from 'element-plus'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import { getToken } from '@/utils/auth'
@@ -13,6 +13,27 @@
const whiteList = ['/homePage'];
+// 全局 Loading 实例
+let loadingInstance = null
+
+// 显示 Loading
+const showLoading = () => {
+ loadingInstance = ElLoading.service({
+ fullscreen: false,
+ text: '正在加载系统菜单...',
+ customClass: 'route-loading'
+ })
+}
+
+// 隐藏 Loading
+const hideLoading = () => {
+ if (loadingInstance) {
+ loadingInstance.close()
+ loadingInstance = null
+ }
+}
+
+
router.beforeEach((to, from, next) => {
NProgress.start()
if (getToken()) {
@@ -22,9 +43,18 @@
next({ path: '/' })
NProgress.done()
} else if (whiteList.indexOf(to.path) !== -1) {
+
next()
} else {
+ if(to.path ==='/menuPage'){
+ next()
+ return
+ }
if (useUserStore().roles.length === 0) {
+ if(to.path ==='/menuIndex'){
+ showLoading()
+ }
+
isRelogin.show = true
// 判断当前用户是否已拉取完user_info信息
useUserStore().getInfo().then(() => {
@@ -36,6 +66,8 @@
router.addRoute(route) // 动态添加可访问路由表
}
})
+
+ hideLoading()
if (to.fullPath == '/index') {
@@ -77,5 +109,6 @@
})
router.afterEach(() => {
+ hideLoading()
NProgress.done()
})
--
Gitblit v1.9.2