diff --git a/src/core/events/WindowFormEventManager.ts b/src/core/events/WindowFormEventManager.ts index db82647..d4b144d 100644 --- a/src/core/events/WindowFormEventManager.ts +++ b/src/core/events/WindowFormEventManager.ts @@ -36,6 +36,10 @@ export interface WindowFormEvent extends IEventMap { * @param data 窗口数据 */ windowFormDataUpdate: (data: IWindowFormDataUpdateParams) => void; + /** + * 窗口创建完成 + */ + windowFormCreated: () => void; } interface IWindowFormDataUpdateParams { diff --git a/src/core/window/impl/WindowFormImpl.ts b/src/core/window/impl/WindowFormImpl.ts index 1a67d16..92b6590 100644 --- a/src/core/window/impl/WindowFormImpl.ts +++ b/src/core/window/impl/WindowFormImpl.ts @@ -4,10 +4,8 @@ import type { IProcess } from '@/core/process/IProcess.ts' import type { IWindowForm } from '@/core/window/IWindowForm.ts' import type { IWindowFormConfig } from '@/core/window/types/IWindowFormConfig.ts' import type { TWindowFormState, WindowFormPos } from '@/core/window/types/WindowFormTypes.ts' -import { processManager } from '@/core/process/ProcessManager.ts' import { DraggableResizableWindow } from '@/core/utils/DraggableResizableWindow.ts' import '../css/window-form.scss' -import { serviceManager } from '@/core/service/kernel/ServiceManager.ts' import '../ui/WindowFormElement.ts' import { wfem } from '@/core/events/WindowFormEventManager.ts' import type { IObservable } from '@/core/state/IObservable.ts' @@ -20,6 +18,8 @@ export interface IWindowFormDataState { procId: string; /** 进程名称唯一 */ name: string; + /** 窗体标题 */ + title: string; /** 窗体位置x (左上角) */ x: number; /** 窗体位置y (左上角) */ @@ -65,6 +65,7 @@ export default class WindowFormImpl implements IWindowForm { id: this.id, procId: proc.id, name: proc.processInfo.name, + title: config.title ?? '未命名', x: config.left ?? 0, y: config.top ?? 0, width: config.width ?? 200, @@ -83,106 +84,30 @@ export default class WindowFormImpl implements IWindowForm { this.closeWindowForm() this._proc.closeWindowForm(this.id) }) - - // this._data.subscribeKey(['x', 'y'], (state) => { - // console.log('x,y', state) - // }) } private createWindowFrom() { - // this.dom = this.createWindowFormEle(); - // this.dom.style.position = 'absolute'; - // this.dom.style.width = `${this.width}px`; - // this.dom.style.height = `${this.height}px`; - // this.dom.style.zIndex = '10'; - // - // const header = this.dom.querySelector('.title-bar') as HTMLElement; - // const content = this.dom.querySelector('.window-content') as HTMLElement; - // this.drw = new DraggableResizableWindow({ - // target: this.dom, - // handle: header, - // snapAnimation: true, - // snapThreshold: 20, - // boundaryElement: document.body, - // taskbarElementId: '#taskbar', - // onWindowStateChange: (state) => { - // if (state === 'maximized') { - // this.dom.style.borderRadius = '0px'; - // } else { - // this.dom.style.borderRadius = '5px'; - // } - // }, - // }) - - // this.desktopRootDom.appendChild(this.dom); const wf = document.createElement('window-form-element') wf.wid = this.id wf.wfData = this._data + wf.title = this._data.state.title wf.dragContainer = document.body wf.snapDistance = 20 wf.taskbarElementId = '#taskbar' - wf.addManagedEventListener('windowForm:stateChange:minimize', (e) => { - console.log('windowForm:stateChange:minimize', e) - }) - wf.addManagedEventListener('windowForm:stateChange:maximize', (e) => { - console.log('windowForm:stateChange:maximize', e) - }) - wf.addManagedEventListener('windowForm:stateChange:restore', (e) => { - console.log('windowForm:stateChange:restore', e) - }) - wf.addManagedEventListener('windowForm:close', () => { - // this.closeWindowForm() - }) this.dom = wf this.desktopRootDom.appendChild(this.dom) - wfem.notifyEvent('windowFormFocus', this.id) + Promise.resolve().then(() => { + wfem.notifyEvent('windowFormCreated') + wfem.notifyEvent('windowFormFocus', this.id) + }) } private closeWindowForm() { - // this.drw.destroy(); this.desktopRootDom.removeChild(this.dom) this._data.dispose() - // wfem.notifyEvent('windowFormClose', this.id) } public minimize() {} public maximize() {} public restore() {} - - private createWindowFormEle() { - const template = document.createElement('template') - template.innerHTML = ` -