import { AService } from '@/core/service/kernel/AService.ts' interface IWindow { id: string; title: string; x: number; y: number; width: number; height: number; zIndex: number; minimized: boolean; maximized: boolean; } export class WindowFormService extends AService { private windows: Map = new Map(); private zCounter = 1; constructor() { super("WindowForm"); console.log('WindowFormService - 服务注册') } createWindow(title: string, config?: Partial): IWindow { const id = `win-${Date.now()}-${Math.random()}`; const win: IWindow = { id, title, x: config?.x ?? 100, y: config?.y ?? 100, width: config?.width ?? 400, height: config?.height ?? 300, zIndex: this.zCounter++, minimized: false, maximized: false }; this.windows.set(id, win); this.sm.broadcast("WindowFrom:created", win); return win; } closeWindow(id: string) { if (this.windows.has(id)) { this.windows.delete(id); this.sm.broadcast("WindowFrom:closed", id); } } focusWindow(id: string) { const win = this.windows.get(id); if (win) { win.zIndex = this.zCounter++; this.sm.broadcast("WindowFrom:focused", win); } } minimizeWindow(id: string) { const win = this.windows.get(id); if (win) { win.minimized = true; this.sm.broadcast("WindowFrom:minimized", win); } } maximizeWindow(id: string) { const win = this.windows.get(id); if (win) { win.maximized = !win.maximized; this.sm.broadcast("WindowFrom:maximized", win); } } getWindows(): IWindow[] { return Array.from(this.windows.values()).sort((a, b) => a.zIndex - b.zIndex); } onMessage(event: string, data?: any) { console.log(`[WindowService] 收到事件:`, event, data); } }