wip fix
This commit is contained in:
parent
5da491fda6
commit
bd36ea0156
File diff suppressed because one or more lines are too long
|
|
@ -18,6 +18,7 @@ export const ViGlobal = {
|
|||
mode: "old" as "old" | "vsc",
|
||||
},
|
||||
},
|
||||
site_url: null as unknown as URL,
|
||||
script: {
|
||||
init_local_effect: undefined as undefined | Record<string, boolean>,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -46,6 +46,24 @@ export const Vi: FC<{
|
|||
vi.entry = entry;
|
||||
vi.on_preload = on_preload;
|
||||
|
||||
w.siteurl = (pathname: string) => {
|
||||
if (vi.site.api_url) {
|
||||
if (!vi.site_url) {
|
||||
vi.site_url = new URL(vi.site.api_url);
|
||||
}
|
||||
}
|
||||
|
||||
if (vi.site_url) {
|
||||
const u = vi.site_url;
|
||||
let path = pathname;
|
||||
if (!path.startsWith("/")) {
|
||||
path = "/" + path;
|
||||
}
|
||||
return `${u.protocol}//${u.hostname}${path}`;
|
||||
}
|
||||
|
||||
return pathname;
|
||||
};
|
||||
w.isMobile = mode === "mobile";
|
||||
w.isDesktop = mode === "desktop";
|
||||
w.preload = (_urls: string | string[]) => {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ export const baseTypings = `
|
|||
const isLayout: boolean;
|
||||
const isMobile: boolean;
|
||||
const isDesktop: boolean;
|
||||
const siteurl: (path:string) => string;
|
||||
const preload: (urls: string | string[]) => ReactNode;
|
||||
const apiHeaders: Record<string, any>;
|
||||
const navigate: (url: string) => void;
|
||||
|
|
|
|||
Loading…
Reference in New Issue