功能修改
This commit is contained in:
@@ -39,6 +39,15 @@ export const firstPartyRoutes: PageRoute[] = [
|
||||
requiredCapability: "servers.read",
|
||||
showInNav: false
|
||||
},
|
||||
{
|
||||
id: "pluginPage",
|
||||
label: "插件页面",
|
||||
path: "/plugin-pages/:pluginId/:routeKey",
|
||||
hash: "#/plugin-pages/:pluginId/:routeKey",
|
||||
description: "平台托管的插件运维页面",
|
||||
requiredCapability: "servers.read",
|
||||
showInNav: false
|
||||
},
|
||||
{
|
||||
id: "plugins",
|
||||
label: "插件市场",
|
||||
@@ -93,6 +102,14 @@ export function hashForPage(pageId: PageId, params: PageParams = {}): string {
|
||||
if (pageId === "serverDetail" && params.serverId) {
|
||||
return `#/servers/${encodeURIComponent(params.serverId)}`;
|
||||
}
|
||||
if (pageId === "pluginPage" && params.pluginId && params.routeKey) {
|
||||
const query = new URLSearchParams();
|
||||
if (params.serverId) {
|
||||
query.set("serverInstanceId", params.serverId);
|
||||
}
|
||||
const suffix = query.toString();
|
||||
return `#/plugin-pages/${encodeURIComponent(params.pluginId)}/${encodeURIComponent(params.routeKey)}${suffix ? `?${suffix}` : ""}`;
|
||||
}
|
||||
return route.hash;
|
||||
}
|
||||
|
||||
@@ -121,13 +138,25 @@ export function resolveRouteHash(hash: string, user?: CurrentUserView): Resolved
|
||||
if (!normalized || normalized === "/") {
|
||||
return fallback;
|
||||
}
|
||||
const segments = normalized.replace(/^\//, "").split("/").filter(Boolean);
|
||||
const [normalizedPath, rawQuery = ""] = normalized.split("?", 2);
|
||||
const segments = normalizedPath.replace(/^\//, "").split("/").filter(Boolean);
|
||||
if (segments.length === 0) {
|
||||
return fallback;
|
||||
}
|
||||
if (segments[0] === "servers" && segments.length > 1) {
|
||||
return { route: routeForPage("serverDetail"), params: { serverId: decodeURIComponent(segments[1]) } };
|
||||
}
|
||||
if (segments[0] === "plugin-pages" && segments.length > 2) {
|
||||
const serverId = new URLSearchParams(rawQuery).get("serverInstanceId") ?? undefined;
|
||||
return {
|
||||
route: routeForPage("pluginPage"),
|
||||
params: {
|
||||
pluginId: decodeURIComponent(segments[1]),
|
||||
routeKey: decodeURIComponent(segments[2]),
|
||||
serverId
|
||||
}
|
||||
};
|
||||
}
|
||||
const key = segments[0];
|
||||
const byId = routesById.get(key as PageId);
|
||||
if (byId) {
|
||||
|
||||
Reference in New Issue
Block a user