Files
OpenList-Frontend/src/utils/config.ts
2022-08-20 14:34:57 +08:00

31 lines
734 B
TypeScript

// api and base_path both don't endsWith /
export let base_path = "";
export const setBasePath = (path: string) => {
base_path = path;
if (!base_path.startsWith("/")) {
base_path = "/" + base_path;
}
if (base_path.endsWith("/")) {
base_path = base_path.slice(0, -1);
}
};
if (window.ALIST.base_path) {
setBasePath(window.ALIST.base_path);
}
export let api = import.meta.env.VITE_API_URL as string;
if (window.ALIST.api) {
api = window.ALIST.api;
}
if (api === "/") {
api = location.origin + base_path;
}
if (api.endsWith("/")) {
api = api.slice(0, -1);
}
export const monaco_cdn =
window.ALIST.monaco_cdn ||
"https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/monaco-editor/0.33.0-dev.20220228/min/vs";