From 5c5cddb1c2ee0d19adddebaf3a3a10a6d93fd2ad Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期日, 26 十月 2025 10:52:18 +0800
Subject: [PATCH] feat:优化微信小程序可以运行
---
ruoyi-ui/src/permission.js | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/ruoyi-ui/src/permission.js b/ruoyi-ui/src/permission.js
index b66190b..ca6c9cf 100644
--- a/ruoyi-ui/src/permission.js
+++ b/ruoyi-ui/src/permission.js
@@ -9,7 +9,7 @@
NProgress.configure({ showSpinner: false })
-const whiteList = ['/login', '/register']
+const whiteList = ['/login', '/register','/anonymous/*', '/h5/*']
const isWhiteList = (path) => {
return whiteList.some(pattern => isPathMatch(pattern, path))
@@ -17,6 +17,14 @@
router.beforeEach((to, from, next) => {
NProgress.start()
+
+ // 璋冭瘯鏃ュ織
+ console.log('=== 璺敱瀹堝崼璋冭瘯 ===')
+ console.log('鐩爣璺緞:', to.path)
+ console.log('瀹屾暣璺緞:', to.fullPath)
+ console.log('Token鐘舵��:', !!getToken())
+ console.log('鐧藉悕鍗曟鏌�:', isWhiteList(to.path))
+
if (getToken()) {
to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
/* has token*/
@@ -24,6 +32,7 @@
next({ path: '/' })
NProgress.done()
} else if (isWhiteList(to.path)) {
+ console.log('鉁� 鏈塗oken涓斿湪鐧藉悕鍗曪紝鐩存帴閫氳繃')
next()
} else {
if (store.getters.roles.length === 0) {
@@ -47,9 +56,11 @@
}
}
} else {
+
// 娌℃湁token
- if (isWhiteList(to.path)) {
+ if (isWhiteList(to.path) || to.meta.anonymous) {
// 鍦ㄥ厤鐧诲綍鐧藉悕鍗曪紝鐩存帴杩涘叆
+
next()
} else {
next(`/login?redirect=${encodeURIComponent(to.fullPath)}`) // 鍚﹀垯鍏ㄩ儴閲嶅畾鍚戝埌鐧诲綍椤�
--
Gitblit v1.9.1