diff --git a/packages/designer/src/project/project.ts b/packages/designer/src/project/project.ts index 082554846..b5a553627 100644 --- a/packages/designer/src/project/project.ts +++ b/packages/designer/src/project/project.ts @@ -369,6 +369,10 @@ export class Project implements IProject { } onSimulatorReady(fn: (args: any) => void): () => void { + if (this._simulator) { + fn(this._simulator); + return () => {}; + } this.emitter.on('lowcode_engine_simulator_ready', fn); return () => { this.emitter.removeListener('lowcode_engine_simulator_ready', fn); diff --git a/packages/shell/src/api/project.ts b/packages/shell/src/api/project.ts index 04feb81f3..a409cbcd5 100644 --- a/packages/shell/src/api/project.ts +++ b/packages/shell/src/api/project.ts @@ -192,12 +192,8 @@ export class Project implements IPublicApiProject { */ onSimulatorHostReady(fn: (host: IPublicApiSimulatorHost) => void): IPublicTypeDisposable { const offFn = this[projectSymbol].onSimulatorReady((simulator: BuiltinSimulatorHost) => { - this[simulatorHostSymbol] = simulator; fn(SimulatorHost.create(simulator)!); }); - if (this[simulatorHostSymbol]) { - fn(SimulatorHost.create(this[simulatorHostSymbol])!); - } return offFn; }