保存一下
This commit is contained in:
@@ -4,6 +4,9 @@ import type { IProcess } from '@/core/process/IProcess.ts'
|
||||
import type { IProcessInfo } from '@/core/process/IProcessInfo.ts'
|
||||
import type { IWindowForm } from '@/core/window/IWindowForm.ts'
|
||||
import { processManager } from '@/core/process/ProcessManager.ts'
|
||||
import { EventBuilderImpl } from '@/core/events/impl/EventBuilderImpl.ts'
|
||||
import type { IEventBuilder } from '@/core/events/IEventBuilder.ts'
|
||||
import type { IProcessEvent } from '@/core/process/types/ProcessEvent.ts'
|
||||
|
||||
/**
|
||||
* 进程
|
||||
@@ -13,6 +16,7 @@ export default class ProcessImpl implements IProcess {
|
||||
private readonly _processInfo: IProcessInfo;
|
||||
// 当前进程的窗体集合
|
||||
private _windowForms: Map<string, IWindowForm> = new Map();
|
||||
private _event: IEventBuilder<IProcessEvent> = new EventBuilderImpl<IProcessEvent>()
|
||||
|
||||
public get id() {
|
||||
return this._id;
|
||||
@@ -23,6 +27,9 @@ export default class ProcessImpl implements IProcess {
|
||||
public get windowForms() {
|
||||
return this._windowForms;
|
||||
}
|
||||
public get event() {
|
||||
return this._event;
|
||||
}
|
||||
|
||||
constructor(info: IProcessInfo) {
|
||||
console.log(`AppProcess: ${info.name}`)
|
||||
@@ -30,6 +37,8 @@ export default class ProcessImpl implements IProcess {
|
||||
|
||||
const startName = info.startName;
|
||||
|
||||
this.initEvent();
|
||||
|
||||
processManager.registerProcess(this);
|
||||
// 通过设置 isJustProcess 为 true,则不会创建窗体
|
||||
if (!info.isJustProcess) {
|
||||
@@ -37,6 +46,15 @@ export default class ProcessImpl implements IProcess {
|
||||
}
|
||||
}
|
||||
|
||||
private initEvent() {
|
||||
this.event.addEventListener('onProcessWindowFormExit', (id: string) => {
|
||||
this.windowForms.delete(id)
|
||||
if(this.windowForms.size === 0) {
|
||||
processManager.removeProcess(this)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
public openWindowForm(startName: string) {
|
||||
const info = this._processInfo.windowFormConfigs.find(item => item.name === startName);
|
||||
if (!info) throw new Error(`未找到窗体:${startName}`);
|
||||
|
||||
Reference in New Issue
Block a user