11import React from 'react' ;
2- import { useEffect , useRef , useState } from 'react' ;
2+ import { useEffect , useState , useMemo } from 'react' ;
33import ReactDOM from 'react-dom' ;
44import { Button , Switch } from 'antd' ;
55import 'antd/dist/antd.css' ;
@@ -84,15 +84,14 @@ const App = () => {
8484
8585 // 插件
8686 const [ pluginActivated , setPluginActivated ] = useState ( false ) ;
87- const blamePlugin = useRef (
88- new CodeBlamePlugin (
87+ const blamePlugin = useMemo ( ( ) => {
88+ return new CodeBlamePlugin (
8989 ( ) => setPluginActivated ( true ) ,
9090 ( commitId : string ) =>
9191 window . open ( `/${ project . namespace . path } /${ project . path } /commit/${ commitId } ` ) ,
9292 ( projectId , commitId , path ) => repoService . getCodeBlame ( projectId , commitId , path )
93- )
94- ) ;
95-
93+ ) ;
94+ } , [ ] ) ;
9695 useEffect ( ( ) => {
9796 if ( ! pluginActivated ) {
9897 return ;
@@ -102,7 +101,7 @@ const App = () => {
102101 prevSha : diffsPack . fromVersion ?. headCommitSha ?? diffsPack . toVersion . baseCommitSha ,
103102 nextSha : diffsPack . toVersion . headCommitSha ,
104103 } ;
105- blamePlugin . current . commands ?. executeCommand ( ExtensionCommand . setProjectData , projectData ) ;
104+ blamePlugin . commands ?. executeCommand ( ExtensionCommand . setProjectData , projectData ) ;
106105 } , [ pluginActivated , diffsPack ] ) ;
107106
108107 // const extensionMetadata = useLoadLocalExtensionMetadata();
@@ -183,7 +182,7 @@ const App = () => {
183182 staticServicePath : Uri . parse ( window . location . href )
184183 . with ( { path : path . join ( '/antcode' , project . pathWithNamespace , 'raw' ) } )
185184 . toString ( ) ,
186- plugins : [ acrPlugin , CodeScaningPlugin , blamePlugin . current ] ,
185+ plugins : [ acrPlugin , CodeScaningPlugin , blamePlugin ] ,
187186 extensionMetadata : [ CodeScaning , CodeBlame ] ,
188187 // extensionMetadata,
189188 } ,
0 commit comments