@@ -8,11 +8,6 @@ import {
88import { BasicModule } from '@ali/ide-core-common' ;
99import { WSChannelHandler } from '@ali/ide-connection' ;
1010
11- import { IEditorDocumentModelService } from '@ali/ide-editor/lib/browser' ;
12- import { EditorDocumentModelServiceImpl } from '@ali/ide-editor/lib/browser/doc-model/editor-document-model-service' ;
13- import { EditorDocumentModel } from '@ali/ide-editor/lib/browser/doc-model/editor-document-model' ;
14- import { isMonacoLoaded } from '@ali/ide-monaco/lib/browser/monaco-loader' ;
15-
1611import { FCServiceCenter , ClientPort , initFCService } from '../connection' ;
1712import { KaitianExtFsProvider , KtExtFsProviderContribution } from './extension' ;
1813import { TextmateLanguageGrammarContribution } from './textmate-language-grammar/index.contribution' ;
@@ -36,11 +31,6 @@ export { TextmateLanguageGrammarContribution, LanguageGrammarRegistrationService
3631
3732export type ModuleConstructor = ConstructorOf < BrowserModule > ;
3833
39- let codeEditorService : any = null ;
40- isMonacoLoaded ( ) ?. then ( ( ) => {
41- codeEditorService = ( monaco as any ) . services . StaticServices . codeEditorService ;
42- } ) ;
43-
4434@Injectable ( )
4535export class ClientModule extends BrowserModule {
4636 providers = [
@@ -65,6 +55,8 @@ export interface IAppOpts extends IClientAppOpts, IServerAppOpts {}
6555export { IClientAppOpts } ;
6656
6757export class ClientApp extends BasicClientApp {
58+ private disposed = false ;
59+
6860 constructor ( opts : IAppOpts ) {
6961 super ( opts ) ;
7062 this . initServer ( opts ) ;
@@ -99,23 +91,25 @@ export class ClientApp extends BasicClientApp {
9991 return super . start ( container , type ) ;
10092 }
10193
102- public dispose ( ) {
103- // from acr
104- // TODO: dispose 会存在报错,需要解决
105- if ( this . injector . hasInstance ( IEditorDocumentModelService ) ) {
106- const editorDocModelService = this . injector . get (
107- IEditorDocumentModelService
108- ) as EditorDocumentModelServiceImpl ;
109- for ( const instance of Array . from (
110- editorDocModelService [ '_modelReferenceManager' ] . instances . values ( )
111- ) as EditorDocumentModel [ ] ) {
112- instance [ 'monacoModel' ] . dispose ( ) ;
113- }
94+ stopContributions ( ) {
95+ if ( ! this . disposed ) {
96+ super . stopContributions ( ) ;
11497 }
115- if ( codeEditorService ) {
116- codeEditorService . _value = null ;
98+ }
99+
100+ preventStop ( ) {
101+ if ( ! this . disposed ) {
102+ return super . preventStop ( ) ;
117103 }
118- this . injector . disposeAll ( ) ;
104+ return false ;
105+ }
106+
107+ /**
108+ * kaitian 中没有注销注册在 window 上上的事件,在把 IDE 销毁后,此时刷新页面依然会执行事件
109+ * 此时 injector.get 都会报错,因此这里加个状态判断
110+ */
111+ dispose ( ) {
112+ this . disposed = true ;
119113 }
120114}
121115
0 commit comments