mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-22 12:26:08 +00:00
fix: plugin mgm page mistakely refreshed when open acc option menu
This commit is contained in:
@@ -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>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -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';
|
||||||
|
|||||||
Reference in New Issue
Block a user