mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 08:03:19 +00:00
perf(settings): batch store registrations and defer font enumeration (#4058)
Settings pages, parent action proxies and template actions registered one by one, cloning the store map and notifying subscribers per item (~1,650 action and ~172 page updates per Settings open). registerActions now disposes in one update too, and the new registerSettingsPages batches page registration and disposal; both keep later per-id overrides. Disabled font pickers no longer enumerate system fonts; enabled ones defer it to idle and load at once on interaction, and the icon-font probe waits past startup. Co-authored-by: dengliu <5108773+dengliu@users.noreply.github.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import { useMemo, useRef, useState } from "react";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { Button, Checkbox, IconButton, Input, Select, T } from "@/ui";
|
||||
import { registerSettingsPage, useSettingsForm } from "@/workbench/contributions";
|
||||
import { registerSettingsPages, useSettingsForm } from "@/workbench/contributions";
|
||||
import { pluginsBackend } from "./backend";
|
||||
import { localizeContributions, usePluginCatalogs } from "./pluginText";
|
||||
import { itemsOf } from "./projection";
|
||||
@@ -372,24 +372,20 @@ function PluginSecrets({ pluginId }: { pluginId: string }) {
|
||||
export function projectSettings(pluginId: string, decl: SettingsDecl): () => void {
|
||||
const id = pluginSettingsPageId(pluginId);
|
||||
const pages = decl.pages ?? [];
|
||||
const dispose = [
|
||||
registerSettingsPage({
|
||||
return registerSettingsPages([
|
||||
{
|
||||
id,
|
||||
title: decl.title,
|
||||
projectScope: true,
|
||||
keywords: ["plugin", pluginId, ...keywords(decl)],
|
||||
component: pages.length ? undefined : settingsPage(pluginId, decl),
|
||||
}),
|
||||
];
|
||||
for (const p of pages)
|
||||
dispose.push(
|
||||
registerSettingsPage({
|
||||
id: `${id}.settings:${p.id}`,
|
||||
title: p.title,
|
||||
projectScope: true,
|
||||
keywords: [pluginId, decl.title, ...keywords(p)],
|
||||
component: settingsPage(pluginId, p),
|
||||
}),
|
||||
);
|
||||
return () => dispose.forEach((d) => d());
|
||||
},
|
||||
...pages.map((p) => ({
|
||||
id: `${id}.settings:${p.id}`,
|
||||
title: p.title,
|
||||
projectScope: true,
|
||||
keywords: [pluginId, decl.title, ...keywords(p)],
|
||||
component: settingsPage(pluginId, p),
|
||||
})),
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user