This commit is contained in:
2025-09-25 13:36:38 +08:00
parent d042520b14
commit d18a3d5279
6 changed files with 931 additions and 39 deletions

View File

@@ -9,6 +9,7 @@ import { EventCommunicationService } from './EventCommunicationService'
import { ApplicationSandboxEngine } from './ApplicationSandboxEngine'
import { ApplicationLifecycleManager } from './ApplicationLifecycleManager'
import { externalAppDiscovery } from './ExternalAppDiscovery'
import type { IWindowFormDataUpdateParams } from '@/events/WindowFormEventManager'
/**
* 系统服务配置接口
@@ -404,6 +405,64 @@ export class SystemServiceIntegration {
}
})
// 监听窗体数据更新事件
this.eventBus.addEventListener(
'onWindowFormDataUpdate',
(data: IWindowFormDataUpdateParams) => {
console.log(`[SystemIntegration] 接收到窗体数据更新事件:`, data)
// 只有在有订阅者时才发送消息
if (this.eventService.getChannelSubscriberCount('window-form-data-update') > 0) {
this.eventService.sendMessage('system', 'window-form-data-update', data)
console.log(`[SystemIntegration] 已发送 window-form-data-update 消息到事件通信服务`)
} else {
console.log(`[SystemIntegration] 无订阅者,跳过发送 window-form-data-update 消息`)
}
},
)
// 监听窗体调整尺寸开始事件
this.eventBus.addEventListener('onResizeStart', (windowId: string) => {
console.log(`[SystemIntegration] 接收到窗体调整尺寸开始事件: ${windowId}`)
// 只有在有订阅者时才发送消息
if (this.eventService.getChannelSubscriberCount('window-form-resize-start') > 0) {
this.eventService.sendMessage('system', 'window-form-resize-start', { windowId })
} else {
console.log(`[SystemIntegration] 无订阅者,跳过发送 window-form-resize-start 消息`)
}
})
// 监听窗体调整尺寸过程中事件
this.eventBus.addEventListener(
'onResizing',
(windowId: string, width: number, height: number) => {
console.log(`[SystemIntegration] 接收到窗体调整尺寸过程中事件: ${windowId}`, {
width,
height,
})
// 只有在有订阅者时才发送消息
if (this.eventService.getChannelSubscriberCount('window-form-resizing') > 0) {
this.eventService.sendMessage('system', 'window-form-resizing', {
windowId,
width,
height,
})
} else {
console.log(`[SystemIntegration] 无订阅者,跳过发送 window-form-resizing 消息`)
}
},
)
// 监听窗体调整尺寸结束事件
this.eventBus.addEventListener('onResizeEnd', (windowId: string) => {
console.log(`[SystemIntegration] 接收到窗体调整尺寸结束事件: ${windowId}`)
// 只有在有订阅者时才发送消息
if (this.eventService.getChannelSubscriberCount('window-form-resize-end') > 0) {
this.eventService.sendMessage('system', 'window-form-resize-end', { windowId })
} else {
console.log(`[SystemIntegration] 无订阅者,跳过发送 window-form-resize-end 消息`)
}
})
// 监听资源配额超出
this.eventBus.addEventListener(
'onResourceQuotaExceeded',
@@ -567,8 +626,18 @@ export class SystemServiceIntegration {
return this.windowService.setWindowSize(windowId, data.width, data.height)
case 'move':
// 需要实现窗体移动功能
return true
// 实现窗体移动功能
const window = this.windowService.getWindow(windowId);
if (window && window.element) {
// 更新窗体位置
window.config.x = data.x;
window.config.y = data.y;
window.element.style.left = `${data.x}px`;
window.element.style.top = `${data.y}px`;
window.element.style.transform = 'none'; // 确保移除transform
return true;
}
return false;
case 'minimize':
return this.windowService.minimizeWindow(windowId)
@@ -583,14 +652,14 @@ export class SystemServiceIntegration {
return this.lifecycleManager.stopApp(appId)
case 'getState':
const window = this.windowService.getWindow(windowId)
return window?.state
const windowInfo = this.windowService.getWindow(windowId)
return windowInfo?.state
case 'getSize':
const windowInfo = this.windowService.getWindow(windowId)
const windowData = this.windowService.getWindow(windowId)
return {
width: windowInfo?.config.width,
height: windowInfo?.config.height,
width: windowData?.config.width,
height: windowData?.config.height,
}
default:
@@ -870,4 +939,4 @@ export class SystemServiceIntegration {
console.log(`[SystemService] ${message}`, data)
}
}
}
}