This commit is contained in:
2025-09-28 12:34:28 +08:00
parent b77a20f9b0
commit 7b1dff9ea1
4 changed files with 206 additions and 28 deletions

View File

@@ -1,6 +1,8 @@
import { reactive } from 'vue'
import type { IEventBuilder } from '@/events/IEventBuilder'
import type { IEventBuilder, IEventMap } from '@/events/IEventBuilder'
import { v4 as uuidv4 } from 'uuid'
import type { WindowState } from './WindowService'
import type { ResourceType } from './ResourceService'
/**
* 消息类型枚举
@@ -90,6 +92,51 @@ export interface EventStatistics {
channelUsage: Map<string, number>
}
/**
* 窗体数据更新参数
*/
export interface WindowFormDataUpdateParams {
/** 窗口id */
id: string
/** 窗口状态 */
state: WindowState
/** 窗口宽度 */
width: number
/** 窗口高度 */
height: number
/** 窗口x坐标(左上角) */
x: number
/** 窗口y坐标(左上角) */
y: number
}
/**
* 事件通信服务事件接口
*/
export interface EventCommunicationEvents extends IEventMap {
// 系统就绪事件
onSystemReady: (data: { timestamp: Date; services: string[] }) => void
// 窗体相关事件
onWindowStateChanged: (windowId: string, newState: string, oldState: string) => void
onWindowFormDataUpdate: (data: WindowFormDataUpdateParams) => void
onWindowFormResizeStart: (windowId: string) => void
onWindowFormResizing: (windowId: string, width: number, height: number) => void
onWindowFormResizeEnd: (windowId: string) => void
onWindowClose: (windowId: string) => void
// 应用生命周期事件
onAppLifecycle: (data: { appId: string; event: string; timestamp: Date }) => void
// 资源相关事件
onResourceQuotaExceeded: (appId: string, resourceType: ResourceType) => void
onPerformanceAlert: (data: { type: 'memory' | 'cpu'; usage: number; limit: number }) => void
// 消息处理事件
onMessageProcessed: (message: EventMessage) => void
onMessageFailed: (message: EventMessage, error: any) => void
}
/**
* 事件通信服务类
*/
@@ -108,9 +155,9 @@ export class EventCommunicationService {
})
private processingInterval: number | null = null
private eventBus: IEventBuilder<any>
private eventBus: IEventBuilder<EventCommunicationEvents>
constructor(eventBus: IEventBuilder<any>) {
constructor(eventBus: IEventBuilder<EventCommunicationEvents>) {
this.eventBus = eventBus
this.initializeDefaultChannels()
this.startMessageProcessing()