feat: support runtime base path configuration via BASE_PATH env var

This commit is contained in:
ZacharyZcR committed 2026-05-13 16:13:20 +08:00
1 parent ec87f8a4d1
commit 1727601fbe
3 files changed
+12

No files matched your search

+5
View File
@@ -1,4 +1,9 @@
export function getBasePath(): string {
const runtime = (window as unknown as Record<string, unknown>)
.__TERMIX_BASE_PATH__ as string | undefined;
if (runtime) {
return runtime.endsWith("/") ? runtime.slice(0, -1) : runtime;
}
const base = import.meta.env.BASE_URL || "/";
if (base === "./" || base === "/") return "";
return base.endsWith("/") ? base.slice(0, -1) : base;