mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-28 01:39:29 +08:00
using type for page name
This commit is contained in:
parent
695300289e
commit
2e398ba2a2
4 changed files with 10 additions and 7 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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, "/");
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
2
frontend/src/scripts/types/types.d.ts
vendored
2
frontend/src/scripts/types/types.d.ts
vendored
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue