Remove app dev mode frontend routes
This commit is contained in:
@@ -58,14 +58,9 @@ async function generateAccess(options: GenerateMenuAndRoutesOptions) {
|
||||
// 获取应用上下文
|
||||
const appContextStore = useAppContextStore();
|
||||
|
||||
// 如果是子应用模式,传递 appCode 和 devMode 参数
|
||||
// - 开发模式 (isDevMode=true): 只返回系统菜单
|
||||
// - 正常模式 (isDevMode=false): 只返回应用专属菜单
|
||||
// 如果是子应用模式,传递 appCode 过滤应用专属菜单
|
||||
if (appContextStore.appCode) {
|
||||
return await getAllMenusApi(
|
||||
appContextStore.appCode,
|
||||
appContextStore.isDevMode,
|
||||
);
|
||||
return await getAllMenusApi(appContextStore.appCode);
|
||||
}
|
||||
|
||||
// 主应用模式,不传参数
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -19,15 +19,6 @@ const routes: RouteRecordRaw[] = [
|
||||
path: '/app/:appCode/ai-platform/workflow-runs',
|
||||
component: () => import('#/views/ai-platform/workflow-runs/index.vue'),
|
||||
},
|
||||
{
|
||||
meta: {
|
||||
hideInMenu: true,
|
||||
title: '执行历史',
|
||||
},
|
||||
name: 'SubAppDevAIWorkflowRuns',
|
||||
path: '/app-dev/:appCode/ai-platform/workflow-runs',
|
||||
component: () => import('#/views/ai-platform/workflow-runs/index.vue'),
|
||||
},
|
||||
// 工作流编辑器 - 主应用
|
||||
{
|
||||
meta: {
|
||||
@@ -50,17 +41,6 @@ const routes: RouteRecordRaw[] = [
|
||||
path: '/app/:appCode/ai-platform/workflow/editor/:id',
|
||||
component: () => import('#/views/ai-platform/workflow/editor/index.vue'),
|
||||
},
|
||||
// 工作流编辑器 - 子应用开发模式
|
||||
{
|
||||
meta: {
|
||||
hideInMenu: true,
|
||||
title: '工作流编辑器',
|
||||
noBasicLayout: true,
|
||||
},
|
||||
name: 'SubAppDevAIWorkflowEditor',
|
||||
path: '/app-dev/:appCode/ai-platform/workflow/editor/:id',
|
||||
component: () => import('#/views/ai-platform/workflow/editor/index.vue'),
|
||||
},
|
||||
// 智能体编辑器 - 主应用
|
||||
{
|
||||
meta: {
|
||||
@@ -83,17 +63,6 @@ const routes: RouteRecordRaw[] = [
|
||||
path: '/app/:appCode/ai-platform/agent/editor/:id',
|
||||
component: () => import('#/views/ai-platform/agent/editor/index.vue'),
|
||||
},
|
||||
// 智能体编辑器 - 子应用开发模式
|
||||
{
|
||||
meta: {
|
||||
hideInMenu: true,
|
||||
title: '智能体编辑器',
|
||||
noBasicLayout: true,
|
||||
},
|
||||
name: 'SubAppDevAIAgentEditor',
|
||||
path: '/app-dev/:appCode/ai-platform/agent/editor/:id',
|
||||
component: () => import('#/views/ai-platform/agent/editor/index.vue'),
|
||||
},
|
||||
// 知识库详情 - 主应用
|
||||
{
|
||||
meta: {
|
||||
@@ -114,16 +83,6 @@ const routes: RouteRecordRaw[] = [
|
||||
path: '/app/:appCode/ai-platform/knowledge/detail/:id',
|
||||
component: () => import('#/views/ai-platform/knowledge/detail/index.vue'),
|
||||
},
|
||||
// 知识库详情 - 子应用开发模式
|
||||
{
|
||||
meta: {
|
||||
hideInMenu: true,
|
||||
title: '知识库详情',
|
||||
},
|
||||
name: 'SubAppDevAIKnowledgeDetail',
|
||||
path: '/app-dev/:appCode/ai-platform/knowledge/detail/:id',
|
||||
component: () => import('#/views/ai-platform/knowledge/detail/index.vue'),
|
||||
},
|
||||
];
|
||||
|
||||
export default routes;
|
||||
|
||||
Reference in New Issue
Block a user