之前的
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { reactive, ref } from 'vue'
|
||||
import { EventBuilderImpl } from '@/events/impl/EventBuilderImpl'
|
||||
import type { IEventBuilder, IEventMap, WindowFormDataUpdateParams } from '@/events/IEventBuilder'
|
||||
import { ResourceService, ResourceType } from './ResourceService'
|
||||
import { ServiceProvider, Inject } from './di/ServiceProvider'
|
||||
import type { IServiceContainer } from './di/IServiceContainer'
|
||||
import { ServiceIds } from './di/ServiceRegistry'
|
||||
import { WindowFormService } from './WindowFormService'
|
||||
import type { ResourceType } from './ResourceService'
|
||||
|
||||
// 导入所有服务
|
||||
import { WindowFormService } from './WindowFormService.ts'
|
||||
import { ResourceService } from './ResourceService'
|
||||
import { ApplicationSandboxEngine } from './ApplicationSandboxEngine'
|
||||
import { ApplicationLifecycleManager } from './ApplicationLifecycleManager'
|
||||
import { externalAppDiscovery } from './ExternalAppDiscovery'
|
||||
@@ -54,24 +55,12 @@ export class SystemServiceIntegration {
|
||||
private config: SystemServiceConfig
|
||||
private startTime: Date
|
||||
|
||||
// 核心服务实例 - 使用依赖注入
|
||||
@Inject(ServiceIds.EVENT_BUILDER)
|
||||
private eventBus!: IEventBuilder<any>
|
||||
|
||||
@Inject(ServiceIds.WINDOW_FORM_SERVICE)
|
||||
private windowFormService!: any
|
||||
|
||||
@Inject(ServiceIds.RESOURCE_SERVICE)
|
||||
private resourceService!: any
|
||||
|
||||
@Inject(ServiceIds.SANDBOX_ENGINE)
|
||||
private sandboxEngine!: any
|
||||
|
||||
@Inject(ServiceIds.LIFECYCLE_MANAGER)
|
||||
private lifecycleManager!: any
|
||||
|
||||
@Inject(ServiceIds.EXTERNAL_APP_DISCOVERY)
|
||||
private externalAppDiscovery!: any
|
||||
// 核心服务实例
|
||||
private eventBus: IEventBuilder<any>
|
||||
private windowFormService!: WindowFormService
|
||||
private resourceService!: ResourceService
|
||||
private sandboxEngine!: ApplicationSandboxEngine
|
||||
private lifecycleManager!: ApplicationLifecycleManager
|
||||
|
||||
// 系统状态
|
||||
private systemStatus = reactive<SystemStatus>({
|
||||
@@ -89,9 +78,8 @@ export class SystemServiceIntegration {
|
||||
// 性能监控
|
||||
private cleanupInterval: number | null = null
|
||||
private performanceInterval: number | null = null
|
||||
private serviceContainer: IServiceContainer
|
||||
|
||||
constructor(serviceContainer: IServiceContainer, config: SystemServiceConfig = {}) {
|
||||
constructor(config: SystemServiceConfig = {}) {
|
||||
this.config = {
|
||||
debug: false,
|
||||
autoCleanup: true,
|
||||
@@ -100,7 +88,7 @@ export class SystemServiceIntegration {
|
||||
}
|
||||
|
||||
this.startTime = new Date()
|
||||
this.serviceContainer = serviceContainer
|
||||
this.eventBus = new EventBuilderImpl<any>()
|
||||
|
||||
this.setupGlobalErrorHandling()
|
||||
}
|
||||
@@ -110,31 +98,36 @@ export class SystemServiceIntegration {
|
||||
*/
|
||||
public async initialize(): Promise<void> {
|
||||
if (this.initialized.value) {
|
||||
console.warn('系统服务已经初始化')
|
||||
return
|
||||
throw new Error('系统服务已初始化')
|
||||
}
|
||||
|
||||
try {
|
||||
console.log('开始初始化系统服务...')
|
||||
|
||||
// 启动自动清理(如果启用)
|
||||
// 按依赖顺序初始化服务
|
||||
await this.initializeServices()
|
||||
|
||||
// 设置服务间通信
|
||||
this.setupServiceCommunication()
|
||||
|
||||
// 设置SDK消息处理
|
||||
this.setupSDKMessageHandling()
|
||||
|
||||
// 启动自动清理
|
||||
if (this.config.autoCleanup) {
|
||||
this.startAutoCleanup()
|
||||
}
|
||||
|
||||
// 更新系统状态
|
||||
this.systemStatus.initialized = true
|
||||
this.systemStatus.running = true
|
||||
// 启动外置应用发现服务
|
||||
// 注意:外置应用发现服务统一由 SystemServiceIntegration 管理,
|
||||
// ApplicationLifecycleManager 只负责使用已发现的应用,避免重复启动
|
||||
console.log('启动外置应用发现服务...')
|
||||
await externalAppDiscovery.startDiscovery()
|
||||
|
||||
this.initialized.value = true
|
||||
this.running.value = true
|
||||
|
||||
// 标记所有服务状态为已启动
|
||||
this.systemStatus.servicesStatus = {
|
||||
windowFormService: true,
|
||||
resourceService: true,
|
||||
sandboxEngine: true,
|
||||
lifecycleManager: true
|
||||
}
|
||||
this.systemStatus.initialized = true
|
||||
this.systemStatus.running = true
|
||||
|
||||
console.log('系统服务初始化完成')
|
||||
} catch (error) {
|
||||
@@ -144,8 +137,6 @@ export class SystemServiceIntegration {
|
||||
}
|
||||
}
|
||||
|
||||
// ... 保留其他现有方法
|
||||
|
||||
/**
|
||||
* 获取系统状态
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user