fix: plugin mgm page mistakely refreshed when open acc option menu

This commit is contained in:
Junyan Qin
2025-11-05 18:59:40 +08:00
parent 1cb9560663
commit 4a868afecd
2 changed files with 10 additions and 5 deletions
+8 -4
View File
@@ -3,7 +3,7 @@
import styles from './layout.module.css'; import styles from './layout.module.css';
import HomeSidebar from '@/app/home/components/home-sidebar/HomeSidebar'; import HomeSidebar from '@/app/home/components/home-sidebar/HomeSidebar';
import HomeTitleBar from '@/app/home/components/home-titlebar/HomeTitleBar'; import HomeTitleBar from '@/app/home/components/home-titlebar/HomeTitleBar';
import React, { useState } from 'react'; import React, { useState, useCallback, useMemo } from 'react';
import { SidebarChildVO } from '@/app/home/components/home-sidebar/HomeSidebarChild'; import { SidebarChildVO } from '@/app/home/components/home-sidebar/HomeSidebarChild';
import { I18nObject } from '@/app/infra/entities/common'; import { I18nObject } from '@/app/infra/entities/common';
@@ -18,11 +18,15 @@ export default function HomeLayout({
en_US: '', en_US: '',
zh_Hans: '', zh_Hans: '',
}); });
const onSelectedChangeAction = (child: SidebarChildVO) => {
const onSelectedChangeAction = useCallback((child: SidebarChildVO) => {
setTitle(child.name); setTitle(child.name);
setSubtitle(child.description); setSubtitle(child.description);
setHelpLink(child.helpLink); setHelpLink(child.helpLink);
}; }, []);
// Memoize the main content area to prevent re-renders when sidebar state changes
const mainContent = useMemo(() => children, [children]);
return ( return (
<div className={styles.homeLayoutContainer}> <div className={styles.homeLayoutContainer}>
@@ -33,7 +37,7 @@ export default function HomeLayout({
<div className={styles.main}> <div className={styles.main}>
<HomeTitleBar title={title} subtitle={subtitle} helpLink={helpLink} /> <HomeTitleBar title={title} subtitle={subtitle} helpLink={helpLink} />
<main className={styles.mainContent}>{children}</main> <main className={styles.mainContent}>{mainContent}</main>
</div> </div>
</div> </div>
); );
+2 -1
View File
@@ -121,7 +121,8 @@ export default function PluginConfigPage() {
}; };
fetchPluginSystemStatus(); fetchPluginSystemStatus();
}, [t]); // eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
function formatFileSize(bytes: number): string { function formatFileSize(bytes: number): string {
if (bytes === 0) return '0 Bytes'; if (bytes === 0) return '0 Bytes';