111
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { IDestroyable } from '@/common/types/IDestroyable'
|
||||
import type { WindowState } from '@/services/WindowService'
|
||||
import type { WindowState } from '@/services/WindowFormService.ts'
|
||||
import type { ResourceType } from '@/services/ResourceService'
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { reactive } from 'vue'
|
||||
import type { WindowService } from './WindowService'
|
||||
import type { ResourceService } from './ResourceService'
|
||||
import type { ApplicationSandboxEngine } from './ApplicationSandboxEngine'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { externalAppDiscovery } from './ExternalAppDiscovery'
|
||||
import type { WindowFormService } from '@/services/WindowFormService.ts'
|
||||
|
||||
/**
|
||||
* 应用状态枚举
|
||||
@@ -118,16 +118,16 @@ export class ApplicationLifecycleManager {
|
||||
private runningProcesses = reactive(new Map<string, AppInstance>())
|
||||
private appFiles = new Map<string, Map<string, Blob | string>>() // 应用文件存储
|
||||
|
||||
private windowService: WindowService
|
||||
private windowFormService: WindowFormService
|
||||
private resourceService: ResourceService
|
||||
private sandboxEngine: ApplicationSandboxEngine
|
||||
|
||||
constructor(
|
||||
windowService: WindowService,
|
||||
windowFormService: WindowFormService,
|
||||
resourceService: ResourceService,
|
||||
sandboxEngine: ApplicationSandboxEngine
|
||||
) {
|
||||
this.windowService = windowService
|
||||
this.windowFormService = windowFormService
|
||||
this.resourceService = resourceService
|
||||
this.sandboxEngine = sandboxEngine
|
||||
}
|
||||
@@ -200,7 +200,7 @@ export class ApplicationLifecycleManager {
|
||||
maxHeight: app.manifest.window?.maxHeight
|
||||
}
|
||||
|
||||
const windowInstance = await this.windowService.createWindow(appId, windowConfig)
|
||||
const windowInstance = await this.windowFormService.createWindow(appId, windowConfig)
|
||||
windowId = windowInstance.id
|
||||
app.windowId = windowId
|
||||
}
|
||||
@@ -292,9 +292,9 @@ export class ApplicationLifecycleManager {
|
||||
|
||||
// 关闭窗体(如果还存在)
|
||||
if (app.windowId) {
|
||||
const window = this.windowService.getWindow(app.windowId)
|
||||
const window = this.windowFormService.getWindow(app.windowId)
|
||||
if (window) {
|
||||
await this.windowService.destroyWindow(app.windowId)
|
||||
await this.windowFormService.destroyWindow(app.windowId)
|
||||
}
|
||||
app.windowId = undefined
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -157,7 +157,7 @@ export interface WindowEvents extends IEventMap {
|
||||
/**
|
||||
* 窗体管理服务类
|
||||
*/
|
||||
export class WindowService {
|
||||
export class WindowFormService {
|
||||
private windows = reactive(new Map<string, WindowInstance>())
|
||||
private activeWindowId = ref<string | null>(null)
|
||||
private nextZIndex = 1000
|
||||
|
||||
@@ -78,7 +78,7 @@ const closeWindow = (windowId: string) => {
|
||||
|
||||
// 通知系统服务关闭窗口
|
||||
if (systemService) {
|
||||
const windowService = systemService.getWindowService()
|
||||
const windowService = systemService.getWindowFormService()
|
||||
windowService.destroyWindow(windowId)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ const systemStatus = ref<SystemStatus>({
|
||||
initialized: false,
|
||||
running: false,
|
||||
servicesStatus: {
|
||||
windowService: false,
|
||||
windowFormService: false,
|
||||
resourceService: false,
|
||||
sandboxEngine: false,
|
||||
lifecycleManager: false
|
||||
@@ -111,7 +111,7 @@ const startApp = async (appId: string) => {
|
||||
}
|
||||
|
||||
// 创建窗口
|
||||
const windowService = systemService.getWindowService()
|
||||
const windowService = systemService.getWindowFormService()
|
||||
const windowConfig = {
|
||||
title: appRegistration.manifest.name,
|
||||
width: appRegistration.manifest.window.width,
|
||||
|
||||
Reference in New Issue
Block a user