保存一下
This commit is contained in:
51
src/core/window/impl/WindowFormImpl.ts
Normal file
51
src/core/window/impl/WindowFormImpl.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { v4 as uuidV4 } from 'uuid';
|
||||
import XSystem from '../../XSystem.ts'
|
||||
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 { WindowFormPos } from '@/core/window/types/WindowFormTypes.ts'
|
||||
|
||||
export default class WindowFormImpl implements IWindowForm {
|
||||
private readonly _id: string = uuidV4();
|
||||
private readonly _procId: string;
|
||||
private pos: WindowFormPos = { x: 0, y: 0 };
|
||||
private width: number = 0;
|
||||
private height: number = 0;
|
||||
|
||||
public get id() {
|
||||
return this._id;
|
||||
}
|
||||
public get proc() {
|
||||
return XSystem.instance.processManage.findProcessById(this._procId)
|
||||
}
|
||||
private get desktopRootDom() {
|
||||
return XSystem.instance.desktopRootDom;
|
||||
}
|
||||
|
||||
constructor(proc: IProcess, config: IWindowFormConfig) {
|
||||
this._procId = proc.id;
|
||||
console.log('WindowForm')
|
||||
this.pos = {
|
||||
x: config.left ?? 0,
|
||||
y: config.top ?? 0
|
||||
}
|
||||
this.width = config.width ?? 0;
|
||||
this.height = config.height ?? 0;
|
||||
|
||||
this.createWindowFrom();
|
||||
}
|
||||
|
||||
public createWindowFrom() {
|
||||
const dom = document.createElement('div');
|
||||
dom.style.position = 'absolute';
|
||||
dom.style.left = `${this.pos.x}px`;
|
||||
dom.style.top = `${this.pos.y}px`;
|
||||
dom.style.width = `${this.width}px`;
|
||||
dom.style.height = `${this.height}px`;
|
||||
dom.style.zIndex = '100';
|
||||
dom.style.backgroundColor = 'white';
|
||||
|
||||
this.desktopRootDom.appendChild(dom);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user