Remove app dev mode frontend routes

This commit is contained in:
2026-06-09 00:29:12 +08:00
parent a89b24f97a
commit 0303ba977e
6 changed files with 24 additions and 126 deletions
+11 -25
View File
@@ -26,17 +26,10 @@ function setupCommonGuard(router: Router) {
const tabHistoryByApp = new Map<string, any>();
router.beforeEach((to) => {
// 检测应用切换(支持 /app/ 和 /app-dev/ 两种模式)
const devMatch = to.path.match(/^\/app-dev\/([^/]+)/);
// 检测应用切换
const appMatch = to.path.match(/^\/app\/([^/]+)/);
const newAppCode =
(devMatch && devMatch[1]) || (appMatch && appMatch[1]) || null;
const isDevMode = !!(devMatch && devMatch[1]);
const appKey = newAppCode
? (isDevMode
? `${newAppCode}-dev`
: newAppCode)
: 'main';
const newAppCode = (appMatch && appMatch[1]) || null;
const appKey = newAppCode || 'main';
// 如果应用切换了,保存当前应用的 tab 历史,加载新应用的 tab 历史
if (newAppCode !== currentAppCode) {
@@ -85,13 +78,10 @@ function setupCommonGuard(router: Router) {
// 记录页面是否加载,如果已经加载,后续的页面切换动画等效果不在重复执行
loadedPaths.add(to.path);
// 保存当前应用的 tab 历史到 sessionStorage(支持 /app/ 和 /app-dev/ 两种模式)
const devMatch = to.path.match(/^\/app-dev\/([^/]+)/);
// 保存当前应用的 tab 历史到 sessionStorage
const appMatch = to.path.match(/^\/app\/([^/]+)/);
const appCode =
(devMatch && devMatch[1]) || (appMatch && appMatch[1]) || null;
const isDevMode = !!(devMatch && devMatch[1]);
const appKey = appCode ? (isDevMode ? `${appCode}-dev` : appCode) : 'main';
const appCode = (appMatch && appMatch[1]) || null;
const appKey = appCode || 'main';
const storageKey = `vben-admin-tabs-${appKey}`;
const tabbarStore = useTabbarStore();
@@ -166,16 +156,13 @@ function setupAccessGuard(router: Router) {
? decodeURIComponent(redirectParam)
: to.path;
// 支持 /app-dev/ 和 /app/ 两种模式
const devMatch = targetPath.match(/^\/app-dev\/([^/]+)/);
// 支持 /app/ 子应用路径
const appMatch = targetPath.match(/^\/app\/([^/]+)/);
const detectedAppCode =
(devMatch && devMatch[1]) || (appMatch && appMatch[1]) || null;
const detectedDevMode = !!(devMatch && devMatch[1]);
const detectedAppCode = (appMatch && appMatch[1]) || null;
if (detectedAppCode && !appContextStore.appCode) {
// 从重定向路径中检测到子应用,初始化 appContextStore
await appContextStore.setAppCode(detectedAppCode, detectedDevMode);
await appContextStore.setAppCode(detectedAppCode);
}
// 生成路由表
@@ -196,10 +183,9 @@ function setupAccessGuard(router: Router) {
accessStore.setAccessRoutes(accessibleRoutes);
accessStore.setIsAccessChecked(true);
// 子应用根路径重定向(/app/hr -> /app/hr/xxx 或 /app-dev/hr -> /app-dev/hr/xxx
// 子应用根路径重定向(/app/hr -> /app/hr/xxx
if (appContextStore.isSubApp) {
const pathPrefix = appContextStore.isDevMode ? '/app-dev' : '/app';
const subAppRootPath = `${pathPrefix}/${appContextStore.appCode}`;
const subAppRootPath = `/app/${appContextStore.appCode}`;
if (to.path === subAppRootPath) {
const defaultHome =