perf(settings): fix navigate-in-setState, memo sections, defer crypto resolution

This commit is contained in:
plebeius
2026-03-04 15:41:21 +08:00
parent 2f697c6a36
commit df1bc2071d
8 changed files with 36 additions and 32 deletions
@@ -65,24 +65,23 @@ const SettingsModal = () => {
}, [hash]); // eslint-disable-line react-hooks/exhaustive-deps
const handleCategoryClick = (categoryId: string) => {
setExpandedSections((prev) => {
const next = new Set(prev);
const isOpening = !next.has(categoryId);
if (isOpening) {
next.add(categoryId);
} else {
next.delete(categoryId);
}
if (isOpening) {
navigate(`${basePath}#${categoryId}`, { replace: true });
} else if (next.size === 1) {
const remaining = next.values().next().value;
navigate(`${basePath}#${remaining}`, { replace: true });
} else {
navigate(basePath, { replace: true });
}
return next;
});
const isOpening = !expandedSections.has(categoryId);
const next = new Set(expandedSections);
if (isOpening) {
next.add(categoryId);
} else {
next.delete(categoryId);
}
setExpandedSections(next);
if (isOpening) {
navigate(`${basePath}#${categoryId}`, { replace: true });
} else if (next.size === 1) {
const remaining = next.values().next().value;
navigate(`${basePath}#${remaining}`, { replace: true });
} else {
navigate(basePath, { replace: true });
}
};
const handleExpandAll = () => {