feat: 前端支持平台子路径,托管时从平台登录进入
This commit is contained in:
@@ -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)}`;
|
||||
}
|
||||
Reference in New Issue
Block a user