Remove app dev mode frontend routes
This commit is contained in:
@@ -17,9 +17,6 @@ export const useAppContextStore = defineStore('app-context', () => {
|
||||
// 当前应用详情
|
||||
const currentApp = ref<Application | null>(null);
|
||||
|
||||
// 是否为开发模式(/app-dev/{code}/)
|
||||
const isDevMode = ref<boolean>(false);
|
||||
|
||||
// 是否为子应用模式
|
||||
const isSubApp = computed(() => !!appCode.value);
|
||||
|
||||
@@ -30,32 +27,19 @@ export const useAppContextStore = defineStore('app-context', () => {
|
||||
* 从 URL 路径中初始化应用上下文
|
||||
* URL 格式:
|
||||
* - /app/:appCode/... (正常模式)
|
||||
* - /app-dev/:appCode/... (开发模式)
|
||||
*/
|
||||
async function initFromUrl() {
|
||||
const path = window.location.pathname;
|
||||
|
||||
// 先尝试匹配开发模式 /app-dev/{code}/
|
||||
const devMatch = path.match(/^\/app-dev\/([^/]+)/);
|
||||
if (devMatch && devMatch[1]) {
|
||||
appCode.value = devMatch[1];
|
||||
isDevMode.value = true;
|
||||
await loadCurrentApp();
|
||||
return;
|
||||
}
|
||||
|
||||
// 再尝试匹配正常模式 /app/{code}/
|
||||
const appMatch = path.match(/^\/app\/([^/]+)/);
|
||||
if (appMatch && appMatch[1]) {
|
||||
appCode.value = appMatch[1];
|
||||
isDevMode.value = false;
|
||||
await loadCurrentApp();
|
||||
return;
|
||||
}
|
||||
|
||||
// 主应用模式
|
||||
appCode.value = null;
|
||||
isDevMode.value = false;
|
||||
currentApp.value = null;
|
||||
}
|
||||
|
||||
@@ -80,11 +64,9 @@ export const useAppContextStore = defineStore('app-context', () => {
|
||||
/**
|
||||
* 设置当前应用
|
||||
* @param code 应用编码
|
||||
* @param devMode 是否为开发模式
|
||||
*/
|
||||
async function setAppCode(code: null | string, devMode: boolean = false) {
|
||||
async function setAppCode(code: null | string) {
|
||||
appCode.value = code;
|
||||
isDevMode.value = devMode;
|
||||
if (code) {
|
||||
await loadCurrentApp();
|
||||
} else {
|
||||
@@ -97,32 +79,28 @@ export const useAppContextStore = defineStore('app-context', () => {
|
||||
*/
|
||||
function clear() {
|
||||
appCode.value = null;
|
||||
isDevMode.value = false;
|
||||
currentApp.value = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子应用 URL
|
||||
* @param code 应用编码
|
||||
* @param devMode 是否为开发模式
|
||||
*/
|
||||
function getSubAppUrl(code: string, devMode: boolean = false): string {
|
||||
function getSubAppUrl(code: string): string {
|
||||
const baseUrl = window.location.origin;
|
||||
const prefix = devMode ? 'app-dev' : 'app';
|
||||
return `${baseUrl}/${prefix}/${code}`;
|
||||
return `${baseUrl}/app/${code}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前上下文的路由路径
|
||||
* 在子应用模式下会自动添加 /app/{code} 或 /app-dev/{code} 前缀
|
||||
* 在子应用模式下会自动添加 /app/{code} 前缀
|
||||
* @param path 原始路由路径(如 /ai-platform/workflow/editor/123)
|
||||
*/
|
||||
function getContextPath(path: string): string {
|
||||
if (!appCode.value) {
|
||||
return path;
|
||||
}
|
||||
const prefix = isDevMode.value ? 'app-dev' : 'app';
|
||||
return `/${prefix}/${appCode.value}${path}`;
|
||||
return `/app/${appCode.value}${path}`;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,14 +108,12 @@ export const useAppContextStore = defineStore('app-context', () => {
|
||||
*/
|
||||
function $reset() {
|
||||
appCode.value = null;
|
||||
isDevMode.value = false;
|
||||
currentApp.value = null;
|
||||
}
|
||||
|
||||
return {
|
||||
appCode,
|
||||
currentApp,
|
||||
isDevMode,
|
||||
isSubApp,
|
||||
isMainApp,
|
||||
initFromUrl,
|
||||
|
||||
Reference in New Issue
Block a user