feat: 前端支持平台子路径,托管时从平台登录进入

This commit is contained in:
2026-11-03 12:30:24 +08:00
parent c38e649904
commit 5d4b86c558
17 changed files with 271 additions and 53 deletions
+17
View File
@@ -0,0 +1,17 @@
function computeBase() {
const path = new URL(document.baseURI).pathname;
return path.endsWith("/") ? path : path.slice(0, path.lastIndexOf("/") + 1);
}
/** 站点所在路径,直接访问时是 "/",托管到平台时类似 "/apps/decomeval/"。 */
export const basePath = computeBase();
export function appUrl(path: string) {
return basePath + path.replace(/^\/+/, "");
}
export const platformHome = "/";
export function platformLoginUrl(target = basePath) {
return `/login?redirect=${encodeURIComponent(target)}`;
}