diff --git a/framework/framework/server.ts b/framework/framework/server.ts
index fc46f2c6c..38cfc8418 100644
--- a/framework/framework/server.ts
+++ b/framework/framework/server.ts
@@ -724,6 +724,7 @@ ${c.response.status} ${endTime - startTime}ms ${c.response.length}`);
}
this.registry[name] = HandlerClass;
this.registrationCount[name]++;
+ this.routeMap[routeName] = path as string;
const Checker = (args) => {
let perm: bigint;
@@ -776,6 +777,7 @@ ${c.response.status} ${endTime - startTime}ms ${c.response.length}`);
this.ctx.effect(() => () => {
this.registrationCount[name]--;
if (!this.registrationCount[name]) delete this.registry[name];
+ delete this.routeMap[routeName];
dispose();
});
}
diff --git a/packages/ui-next/index.ts b/packages/ui-next/index.ts
index c2bd8226d..66568679f 100644
--- a/packages/ui-next/index.ts
+++ b/packages/ui-next/index.ts
@@ -6,6 +6,7 @@ import c2k from 'koa2-connect/ts';
import { createServer, type Plugin } from 'vite';
import { serializer } from '@hydrooj/framework';
import { Context } from 'hydrooj';
+import type { PageData } from './src/context/pageData';
const INJECT_MARKER = '';
const buildInject = (str: string) => ``;
@@ -81,11 +82,12 @@ export async function apply(ctx: Context) {
asFallback: true,
priority: 100,
async render(name, args, context) {
- const data = {
+ const data: PageData = {
HYDRO_INJECTED: true,
name,
args,
url: context.handler.context.req.url,
+ routeMap: ctx.server.routeMap,
};
const serialized = JSON.stringify(data, serializer(false, context.handler));
const htmlToRender = html.replace(INJECT_MARKER, buildInject(serialized));
diff --git a/packages/ui-next/src/context/pageData.tsx b/packages/ui-next/src/context/pageData.tsx
index a6727fa31..4c775f91f 100644
--- a/packages/ui-next/src/context/pageData.tsx
+++ b/packages/ui-next/src/context/pageData.tsx
@@ -4,6 +4,7 @@ export interface PageData {
name: string;
args: Record;
url: string;
+ routeMap: Record;
[key: string]: any;
}