@@ -716,6 +716,65 @@ export default function App() {
716716 withBusy
717717 } ) ;
718718
719+ // 稳定化内联箭头函数:避免每次渲染创建新函数引用导致 memo 子组件失效
720+ const onOpenDocumentStable = useCallback ( ( ) => {
721+ void handleOpenDocument ( ) ;
722+ } , [ handleOpenDocument ] ) ;
723+ const onExportStable = useCallback ( ( ) => {
724+ void handleExport ( ) ;
725+ } , [ handleExport ] ) ;
726+ const onStartWindowDragStable = useCallback ( ( ) => {
727+ void handleStartWindowDrag ( ) ;
728+ } , [ handleStartWindowDrag ] ) ;
729+ const onMinimizeWindowStable = useCallback ( ( ) => {
730+ void handleMinimizeWindow ( ) ;
731+ } , [ handleMinimizeWindow ] ) ;
732+ const onToggleMaximizeWindowStable = useCallback ( ( ) => {
733+ void handleToggleMaximizeWindow ( ) ;
734+ } , [ handleToggleMaximizeWindow ] ) ;
735+ const onCloseWindowStable = useCallback ( ( ) => {
736+ void handleCloseWindow ( ) ;
737+ } , [ handleCloseWindow ] ) ;
738+ const onStartRewriteStable = useCallback (
739+ ( mode : AppSettings [ "rewriteMode" ] ) => {
740+ void handleStartRewrite ( mode ) ;
741+ } ,
742+ [ handleStartRewrite ]
743+ ) ;
744+ const onPauseStable = useCallback ( ( ) => {
745+ void handlePause ( ) ;
746+ } , [ handlePause ] ) ;
747+ const onResumeStable = useCallback ( ( ) => {
748+ void handleResume ( ) ;
749+ } , [ handleResume ] ) ;
750+ const onCancelRewriteStable = useCallback ( ( ) => {
751+ void handleCancelRewrite ( ) ;
752+ } , [ handleCancelRewrite ] ) ;
753+ const onFinalizeDocumentStable = useCallback ( ( ) => {
754+ void handleFinalizeDocument ( ) ;
755+ } , [ handleFinalizeDocument ] ) ;
756+ const onResetSessionStable = useCallback ( ( ) => {
757+ void handleResetSession ( ) ;
758+ } , [ handleResetSession ] ) ;
759+ const onSaveEditorStable = useCallback ( ( ) => {
760+ void handleSaveEditor ( ) ;
761+ } , [ handleSaveEditor ] ) ;
762+ const onSaveEditorAndExitStable = useCallback ( ( ) => {
763+ void handleSaveEditor ( { returnToWorkbench : true } ) ;
764+ } , [ handleSaveEditor ] ) ;
765+ const onRewriteSelectionStable = useCallback ( ( ) => {
766+ void handleRewriteSelection ( ) ;
767+ } , [ handleRewriteSelection ] ) ;
768+ const onCheckUpdateStable = useCallback ( ( ) => {
769+ void handleCheckUpdate ( ) ;
770+ } , [ handleCheckUpdate ] ) ;
771+ const onRefreshReleaseVersionsStable = useCallback ( ( ) => {
772+ void handleRefreshReleaseVersions ( ) ;
773+ } , [ handleRefreshReleaseVersions ] ) ;
774+ const onSwitchSelectedReleaseStable = useCallback ( ( ) => {
775+ void handleSwitchSelectedRelease ( ) ;
776+ } , [ handleSwitchSelectedRelease ] ) ;
777+
719778 if ( booting ) {
720779 return < BootScreen /> ;
721780 }
@@ -739,13 +798,13 @@ export default function App() {
739798 windowMaximized = { windowMaximized }
740799 showWindowControls = { desktopRuntime }
741800 enableWindowDrag = { desktopRuntime }
742- onOpenDocument = { ( ) => void handleOpenDocument ( ) }
801+ onOpenDocument = { onOpenDocumentStable }
743802 onOpenSettings = { openSettings }
744- onExport = { ( ) => void handleExport ( ) }
745- onStartWindowDrag = { ( ) => void handleStartWindowDrag ( ) }
746- onMinimizeWindow = { ( ) => void handleMinimizeWindow ( ) }
747- onToggleMaximizeWindow = { ( ) => void handleToggleMaximizeWindow ( ) }
748- onCloseWindow = { ( ) => void handleCloseWindow ( ) }
803+ onExport = { onExportStable }
804+ onStartWindowDrag = { onStartWindowDragStable }
805+ onMinimizeWindow = { onMinimizeWindowStable }
806+ onToggleMaximizeWindow = { onToggleMaximizeWindowStable }
807+ onCloseWindow = { onCloseWindowStable }
749808 />
750809
751810 < div className = "workspace-stage" >
@@ -770,12 +829,12 @@ export default function App() {
770829 onOpenDocument = { handleOpenDocument }
771830 onSelectRewriteUnit = { handleSelectRewriteUnit }
772831 onSelectSuggestion = { handleSelectSuggestion }
773- onStartRewrite = { ( mode ) => void handleStartRewrite ( mode ) }
774- onPause = { ( ) => void handlePause ( ) }
775- onResume = { ( ) => void handleResume ( ) }
776- onCancel = { ( ) => void handleCancelRewrite ( ) }
777- onFinalizeDocument = { ( ) => void handleFinalizeDocument ( ) }
778- onResetSession = { ( ) => void handleResetSession ( ) }
832+ onStartRewrite = { onStartRewriteStable }
833+ onPause = { onPauseStable }
834+ onResume = { onResumeStable }
835+ onCancel = { onCancelRewriteStable }
836+ onFinalizeDocument = { onFinalizeDocumentStable }
837+ onResetSession = { onResetSessionStable }
779838 onApplySuggestion = { handleApplySuggestion }
780839 onDismissSuggestion = { handleDismissSuggestion }
781840 onDeleteSuggestion = { handleDeleteSuggestion }
@@ -785,13 +844,11 @@ export default function App() {
785844 onChangeEditorText = { handleChangeEditorText }
786845 onChangeEditorSlotText = { handleChangeEditorSlotText }
787846 onChangeEditorHasSelection = { setEditorHasSelection }
788- onSaveEditor = { ( ) => void handleSaveEditor ( ) }
789- onSaveEditorAndExit = { ( ) =>
790- void handleSaveEditor ( { returnToWorkbench : true } )
791- }
847+ onSaveEditor = { onSaveEditorStable }
848+ onSaveEditorAndExit = { onSaveEditorAndExitStable }
792849 onDiscardEditorChanges = { handleDiscardEditorChanges }
793850 onExitEditor = { handleExitEditor }
794- onRewriteSelection = { ( ) => void handleRewriteSelection ( ) }
851+ onRewriteSelection = { onRewriteSelectionStable }
795852 />
796853 </ div >
797854
@@ -823,10 +880,10 @@ export default function App() {
823880 onConfirm = { requestConfirm }
824881 onTestProvider = { handleTestProvider }
825882 onSaveSettings = { handleSaveSettings }
826- onCheckUpdate = { ( ) => void handleCheckUpdate ( ) }
827- onRefreshReleaseVersions = { ( ) => void handleRefreshReleaseVersions ( ) }
883+ onCheckUpdate = { onCheckUpdateStable }
884+ onRefreshReleaseVersions = { onRefreshReleaseVersionsStable }
828885 onSelectReleaseTag = { handleSelectReleaseTag }
829- onSwitchSelectedRelease = { ( ) => void handleSwitchSelectedRelease ( ) }
886+ onSwitchSelectedRelease = { onSwitchSelectedReleaseStable }
830887 />
831888 </ main >
832889 </ div >
0 commit comments