using type for page name

This commit is contained in:
Miodec 2022-02-19 21:29:38 +01:00
parent 695300289e
commit 2e398ba2a2
4 changed files with 10 additions and 7 deletions

View file

@ -1,5 +1,5 @@
export default class Page {
public name: string;
public name: MonkeyTypes.Page;
public element: JQuery;
public pathname: string;
public beforeHide: () => void;
@ -7,7 +7,7 @@ export default class Page {
public beforeShow: () => void;
public afterShow: () => void;
constructor(
name: string,
name: MonkeyTypes.Page,
element: JQuery,
pathname: string,
beforeHide: () => void,

View file

@ -58,7 +58,10 @@ $(document).ready(() => {
});
history.replaceState("/", "", "/");
}
const page = window.location.pathname.replace("/", "");
const page = window.location.pathname.replace(
"/",
""
) as MonkeyTypes.Page;
PageController.change(page);
} else if (window.location.pathname === "/account") {
// history.replaceState("/", null, "/");

View file

@ -1,9 +1,9 @@
let activePage = "loading";
let activePage: MonkeyTypes.Page | undefined = "loading";
export function get(): string {
export function get(): MonkeyTypes.Page | undefined {
return activePage;
}
export function set(active: string): void {
export function set(active: MonkeyTypes.Page | undefined): void {
activePage = active;
}

View file

@ -545,7 +545,7 @@ declare namespace MonkeyTypes {
colorfulErrorExtra: string;
}
// type Page = "Loading" | "Account" | "Settings" | "About" | "Test";
type Page = "loading" | "test" | "about" | "settings" | "account" | "login";
// type ActivePage = `page${Page}` | undefined;