From 183416a1b3a85f1bfdbcdbadec38792a794a2207 Mon Sep 17 00:00:00 2001 From: qsh <> Date: Wed, 20 Aug 2025 11:46:34 +0800 Subject: [PATCH] sc --- .env.base | 1 - src/permission.js | 19 ++++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.env.base b/.env.base index 978fb4c..30af98f 100644 --- a/.env.base +++ b/.env.base @@ -7,7 +7,6 @@ VITE_DEV=true # VITE_BASE_URL='http://localhost:48080' VITE_BASE_URL='http://47.98.161.246:48080' -# VITE_BASE_URL='http://114.55.169.15:48080' # VITE_BASE_URL='http://114.215.207.150:48080' # 上传路径 diff --git a/src/permission.js b/src/permission.js index c008a26..dec09ee 100644 --- a/src/permission.js +++ b/src/permission.js @@ -62,10 +62,23 @@ router.beforeEach(async (to, from, next) => { if (whiteList.indexOf(to.path) !== -1) { next() } else { - const tenantId = getTenantId() - const appId = getAppId() + const tenantId = getTenantId() || to.query?.tenantId + const appId = getAppId() || to.query?.appId if (tenantId && appId) { - next(`/login?tenantId=${tenantId}&appId=${appId}&redirect=${to.fullPath}`) // 否则全部重定向到登录页 + let redirectPath = to.fullPath + const p = to.fullPath.split('?') + if (p.length > 1) { + // 过滤掉query参数中的tenantId和appId + redirectPath = + p[0] + + '?' + + p[1] + .split('&') + .filter((item) => !item.startsWith('tenantId=') && !item.startsWith('appId=')) + .join('&') + } + + next(`/login?tenantId=${tenantId}&appId=${appId}&redirect=${redirectPath}`) // 否则全部重定向到登录页 } else { // next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到平台登陆页