111
This commit is contained in:
@@ -4,7 +4,7 @@ import type { IEventBuilder, IEventMap, WindowFormDataUpdateParams } from '@/eve
|
||||
import type { ResourceType } from './ResourceService'
|
||||
|
||||
// 导入所有服务
|
||||
import { WindowService } from './WindowService'
|
||||
import { WindowFormService } from './WindowFormService.ts'
|
||||
import { ResourceService } from './ResourceService'
|
||||
import { ApplicationSandboxEngine } from './ApplicationSandboxEngine'
|
||||
import { ApplicationLifecycleManager } from './ApplicationLifecycleManager'
|
||||
@@ -26,7 +26,7 @@ export interface SystemStatus {
|
||||
initialized: boolean // 系统是否初始化完成
|
||||
running: boolean // 系统是否运行中
|
||||
servicesStatus: {
|
||||
windowService: boolean // 窗体服务是否启动
|
||||
windowFormService: boolean // 窗体服务是否启动
|
||||
resourceService: boolean // 资源服务是否启动
|
||||
sandboxEngine: boolean // 沙箱引擎是否启动
|
||||
lifecycleManager: boolean // 生命周期管理器是否启动
|
||||
@@ -57,7 +57,7 @@ export class SystemServiceIntegration {
|
||||
|
||||
// 核心服务实例
|
||||
private eventBus: IEventBuilder<any>
|
||||
private windowService!: WindowService
|
||||
private windowFormService!: WindowFormService
|
||||
private resourceService!: ResourceService
|
||||
private sandboxEngine!: ApplicationSandboxEngine
|
||||
private lifecycleManager!: ApplicationLifecycleManager
|
||||
@@ -67,7 +67,7 @@ export class SystemServiceIntegration {
|
||||
initialized: false,
|
||||
running: false,
|
||||
servicesStatus: {
|
||||
windowService: false,
|
||||
windowFormService: false,
|
||||
resourceService: false,
|
||||
sandboxEngine: false,
|
||||
lifecycleManager: false
|
||||
@@ -96,7 +96,7 @@ export class SystemServiceIntegration {
|
||||
/**
|
||||
* 初始化系统服务
|
||||
*/
|
||||
private async initialize(): Promise<void> {
|
||||
public async initialize(): Promise<void> {
|
||||
if (this.initialized.value) {
|
||||
throw new Error('系统服务已初始化')
|
||||
}
|
||||
@@ -147,9 +147,9 @@ export class SystemServiceIntegration {
|
||||
/**
|
||||
* 获取窗体服务
|
||||
*/
|
||||
getWindowService(): WindowService {
|
||||
getWindowFormService(): WindowFormService {
|
||||
this.checkInitialized()
|
||||
return this.windowService
|
||||
return this.windowFormService
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -221,7 +221,7 @@ export class SystemServiceIntegration {
|
||||
/**
|
||||
* 关闭系统服务
|
||||
*/
|
||||
private async shutdown(): Promise<void> {
|
||||
public async shutdown(): Promise<void> {
|
||||
console.log('关闭系统服务...')
|
||||
|
||||
this.running.value = false
|
||||
@@ -255,11 +255,11 @@ export class SystemServiceIntegration {
|
||||
this.sandboxEngine.destroy()
|
||||
}
|
||||
|
||||
if (this.windowService) {
|
||||
if (this.windowFormService) {
|
||||
// 关闭所有窗体
|
||||
const windows = this.windowService.getAllWindows()
|
||||
const windows = this.windowFormService.getAllWindows()
|
||||
for (const window of windows) {
|
||||
await this.windowService.destroyWindow(window.id)
|
||||
await this.windowFormService.destroyWindow(window.id)
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -283,8 +283,8 @@ export class SystemServiceIntegration {
|
||||
|
||||
// 3. 初始化窗体服务
|
||||
console.log('初始化窗体服务...')
|
||||
this.windowService = new WindowService(this.eventBus)
|
||||
this.systemStatus.servicesStatus.windowService = true
|
||||
this.windowFormService = new WindowFormService(this.eventBus)
|
||||
this.systemStatus.servicesStatus.windowFormService = true
|
||||
|
||||
// 4. 初始化沙箱引擎
|
||||
console.log('初始化沙箱引擎...')
|
||||
@@ -294,7 +294,7 @@ export class SystemServiceIntegration {
|
||||
// 5. 初始化生命周期管理器
|
||||
console.log('初始化生命周期管理器...')
|
||||
this.lifecycleManager = new ApplicationLifecycleManager(
|
||||
this.windowService,
|
||||
this.windowFormService,
|
||||
this.resourceService,
|
||||
this.sandboxEngine
|
||||
)
|
||||
@@ -305,7 +305,7 @@ export class SystemServiceIntegration {
|
||||
* 设置服务间通信
|
||||
*/
|
||||
private setupServiceCommunication(): void {
|
||||
// 监听窗体状态变化(来自 WindowService 的 onStateChange 事件)
|
||||
// 监听窗体状态变化(来自 windowFormService 的 onStateChange 事件)
|
||||
this.eventBus.addEventListener(
|
||||
'onWindowStateChanged',
|
||||
(windowId: string, newState: string, oldState: string) => {
|
||||
@@ -504,14 +504,14 @@ export class SystemServiceIntegration {
|
||||
|
||||
switch (action) {
|
||||
case 'setTitle':
|
||||
return this.windowService.setWindowTitle(windowId, data.title)
|
||||
return this.windowFormService.setWindowTitle(windowId, data.title)
|
||||
|
||||
case 'resize':
|
||||
return this.windowService.setWindowSize(windowId, data.width, data.height)
|
||||
return this.windowFormService.setWindowSize(windowId, data.width, data.height)
|
||||
|
||||
case 'move':
|
||||
// 实现窗体移动功能
|
||||
const window = this.windowService.getWindow(windowId)
|
||||
const window = this.windowFormService.getWindow(windowId)
|
||||
if (window && window.element) {
|
||||
// 更新窗体位置
|
||||
window.config.x = data.x
|
||||
@@ -524,23 +524,23 @@ export class SystemServiceIntegration {
|
||||
return false
|
||||
|
||||
case 'minimize':
|
||||
return this.windowService.minimizeWindow(windowId)
|
||||
return this.windowFormService.minimizeWindow(windowId)
|
||||
|
||||
case 'maximize':
|
||||
return this.windowService.maximizeWindow(windowId)
|
||||
return this.windowFormService.maximizeWindow(windowId)
|
||||
|
||||
case 'restore':
|
||||
return this.windowService.restoreWindow(windowId)
|
||||
return this.windowFormService.restoreWindow(windowId)
|
||||
|
||||
case 'close':
|
||||
return this.lifecycleManager.stopApp(appId)
|
||||
|
||||
case 'getState':
|
||||
const windowInfo = this.windowService.getWindow(windowId)
|
||||
const windowInfo = this.windowFormService.getWindow(windowId)
|
||||
return windowInfo?.state
|
||||
|
||||
case 'getSize':
|
||||
const windowData = this.windowService.getWindow(windowId)
|
||||
const windowData = this.windowFormService.getWindow(windowId)
|
||||
return {
|
||||
width: windowData?.config.width,
|
||||
height: windowData?.config.height
|
||||
|
||||
Reference in New Issue
Block a user