import type { AuthShellModel } from "../models/AuthModels";
export class PageContext {
static read<TPayload = unknown>(): AuthShellModel<TPayload> {
const element = document.querySelector<HTMLScriptElement>("#auth-page-model");
if (!element?.textContent) {
return { entryName: "public", pageName: "home" } as AuthShellModel<TPayload>;
}
return JSON.parse(element.textContent) as AuthShellModel<TPayload>;
}
static antiforgeryToken(): string {
return (
document
.querySelector<HTMLMetaElement>('meta[name="request-verification-token"]')
?.getAttribute("content") ?? ""
);
}
}
AI 正在分析代码…
评论加载中...