2025-08-19 14:56:38 +08:00
|
|
|
|
import { v4 as uuidV4 } from 'uuid';
|
2025-08-26 10:33:41 +08:00
|
|
|
|
import XSystem from '../../XSystem.ts'
|
2025-08-28 08:05:16 +08:00
|
|
|
|
import WindowFormImpl from '../../window/impl/WindowFormImpl.ts'
|
2025-08-26 10:33:41 +08:00
|
|
|
|
import type { IProcess } from '@/core/process/IProcess.ts'
|
|
|
|
|
|
import type { IProcessInfo } from '@/core/process/IProcessInfo.ts'
|
2025-08-28 08:05:16 +08:00
|
|
|
|
import type { IWindowForm } from '@/core/window/IWindowForm.ts'
|
2025-08-19 14:56:38 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 进程
|
|
|
|
|
|
*/
|
2025-08-26 10:33:41 +08:00
|
|
|
|
export default class ProcessImpl implements IProcess {
|
2025-08-19 14:56:38 +08:00
|
|
|
|
private readonly _id: string = uuidV4();
|
2025-08-26 10:33:41 +08:00
|
|
|
|
private readonly _processInfo: IProcessInfo;
|
2025-08-19 14:56:38 +08:00
|
|
|
|
// 当前进程的窗体集合
|
2025-08-28 08:05:16 +08:00
|
|
|
|
private _windowForms: Map<string, IWindowForm> = new Map();
|
2025-08-19 14:56:38 +08:00
|
|
|
|
|
|
|
|
|
|
public get id() {
|
|
|
|
|
|
return this._id;
|
|
|
|
|
|
}
|
|
|
|
|
|
public get processInfo() {
|
|
|
|
|
|
return this._processInfo;
|
|
|
|
|
|
}
|
|
|
|
|
|
public get windowForms() {
|
|
|
|
|
|
return this._windowForms;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-26 10:33:41 +08:00
|
|
|
|
constructor(info: IProcessInfo) {
|
2025-08-19 14:56:38 +08:00
|
|
|
|
console.log(`AppProcess: ${info.name}`)
|
|
|
|
|
|
this._processInfo = info;
|
|
|
|
|
|
|
|
|
|
|
|
const startName = info.startName;
|
|
|
|
|
|
|
2025-08-26 10:33:41 +08:00
|
|
|
|
XSystem.instance.processManage.addProcess(this);
|
2025-08-19 14:56:38 +08:00
|
|
|
|
// 通过设置 isJustProcess 为 true,则不会创建窗体
|
|
|
|
|
|
if (!info.isJustProcess) {
|
|
|
|
|
|
this.openWindowForm(startName)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public openWindowForm(startName: string) {
|
2025-08-28 08:05:16 +08:00
|
|
|
|
const info = this._processInfo.windowFormConfigs.find(item => item.name === startName);
|
|
|
|
|
|
if (!info) throw new Error(`未找到窗体:${startName}`);
|
|
|
|
|
|
const window = new WindowFormImpl(this, info);
|
2025-08-19 14:56:38 +08:00
|
|
|
|
this._windowForms.set(window.id, window);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|