mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-23 00:12:29 +00:00
Fix base route navigation
This commit is contained in:
parent
5ac93645e4
commit
18c143e12f
@ -1,5 +1,7 @@
|
||||
import { EventEmitter } from "events";
|
||||
|
||||
import type { Page } from "@backend/types";
|
||||
import { isPage } from "@backend/types";
|
||||
|
||||
const emitter = new EventEmitter();
|
||||
const navigation = new EventEmitter();
|
||||
@ -18,14 +20,14 @@ export function setup(): void {
|
||||
setTimeout(() => {
|
||||
// Check if the window's href is a page.
|
||||
const page = window.location.href.split("/").pop();
|
||||
if (page == undefined) return;
|
||||
if (page == undefined || page == "") return;
|
||||
|
||||
// Convert the page to a Page type.
|
||||
const pageName = page.charAt(0).toUpperCase() + page.slice(1);
|
||||
const pageType = pageName as Page;
|
||||
|
||||
// Navigate to the page.
|
||||
navigate(pageType, false);
|
||||
isPage(page) && navigate(pageType, false);
|
||||
}, 3e2);
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ export enum ItemCategory {
|
||||
* @param page The string to check.
|
||||
*/
|
||||
export function isPage(page: string): page is Page {
|
||||
return ["Home", "Commands"].includes(page);
|
||||
return ["Home", "Commands", "Avatars", "Items", "Entities", "Scenes"].includes(page);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,7 +23,9 @@ class App extends React.Component<{}, IState> {
|
||||
// Check if the window's href is a page.
|
||||
let targetPage = null;
|
||||
const page = window.location.href.split("/").pop();
|
||||
if (page != undefined) {
|
||||
console.log(page)
|
||||
|
||||
if (page != undefined && page != "") {
|
||||
// Convert the page to a Page type.
|
||||
const pageName = page.charAt(0).toUpperCase() + page.slice(1);
|
||||
// Check if the page is a valid page.
|
||||
|
Loading…
Reference in New Issue
Block a user