From 0ca5daad3b13868b2c37563f2cfe8d168c1895f2 Mon Sep 17 00:00:00 2001 From: Azure <983547216@qq.com> Date: Fri, 10 Oct 2025 10:37:11 +0800 Subject: [PATCH] 111 --- .qoder/quests/module-dependency-analysis.md | 4 +- .qoder/quests/project-code-optimization.md | 4 +- .../system-business-decoupling-design.md | 4 +- .../窗口表单事件管理器/窗口创建完成事件.md | 12 ++--- .../窗口表单事件管理器/窗口数据更新事件.md | 16 +++---- PROJECT_SUMMARY.md | 6 +-- src/events/IEventBuilder.ts | 2 +- src/services/ApplicationLifecycleManager.ts | 14 +++--- src/services/SystemServiceIntegration.ts | 46 +++++++++---------- src/services/WindowFormService.ts | 2 +- src/ui/components/WindowManager.vue | 2 +- src/ui/desktop-container/DesktopContainer.vue | 4 +- 12 files changed, 58 insertions(+), 58 deletions(-) diff --git a/.qoder/quests/module-dependency-analysis.md b/.qoder/quests/module-dependency-analysis.md index bf81b3e..55f9397 100644 --- a/.qoder/quests/module-dependency-analysis.md +++ b/.qoder/quests/module-dependency-analysis.md @@ -56,7 +56,7 @@ Vue Desktop 使用分层的事件管理系统: ```mermaid graph TD A[SystemServiceIntegration] --> B[EventCommunicationService] - A --> C[WindowService] + A --> C[WindowFormService] A --> D[ResourceService] B --> E[IEventBuilder] @@ -114,7 +114,7 @@ constructor(config: SystemServiceConfig = {}) { // 注入到依赖的服务中 // EventCommunicationService 需要 IEventBuilder 接口 - // WindowService 也需要 IEventBuilder 接口 + // WindowFormService 也需要 IEventBuilder 接口 } ``` diff --git a/.qoder/quests/project-code-optimization.md b/.qoder/quests/project-code-optimization.md index 8baf1e6..8aa8e21 100644 --- a/.qoder/quests/project-code-optimization.md +++ b/.qoder/quests/project-code-optimization.md @@ -17,7 +17,7 @@ graph TD A --> D[事件系统] A --> E[应用注册中心] - B --> B1[WindowService] + B --> B1[WindowFormService] B --> B2[ResourceService] B --> B3[EventCommunicationService] B --> B4[ApplicationSandboxEngine] @@ -39,7 +39,7 @@ graph TD | 模块 | 职责 | | --------------------------- | ---------------------------------- | -| WindowService | 管理应用窗体的创建、销毁、状态控制 | +| WindowFormService | 管理应用窗体的创建、销毁、状态控制 | | ResourceService | 管理应用资源访问权限和存储 | | EventCommunicationService | 处理应用间通信 | | ApplicationSandboxEngine | 为外部应用创建安全沙箱环境 | diff --git a/.qoder/quests/system-business-decoupling-design.md b/.qoder/quests/system-business-decoupling-design.md index 6199ca0..060e124 100644 --- a/.qoder/quests/system-business-decoupling-design.md +++ b/.qoder/quests/system-business-decoupling-design.md @@ -26,7 +26,7 @@ graph TB end subgraph "系统服务层" - WindowService[窗体服务] + WindowFormService[窗体服务] ResourceService[资源服务] EventService[事件服务] SecurityService[安全服务] @@ -47,7 +47,7 @@ graph TB end Desktop --> WindowManager - WindowManager --> WindowService + WindowManager --> WindowFormService AppContainer --> SandboxEngine SDKBridge --> SystemService[系统服务层] App1 --> AppContainer diff --git a/.qoder/repowiki/zh/content/事件系统/窗口表单事件管理器/窗口创建完成事件.md b/.qoder/repowiki/zh/content/事件系统/窗口表单事件管理器/窗口创建完成事件.md index 9fd1a43..590c5d2 100644 --- a/.qoder/repowiki/zh/content/事件系统/窗口表单事件管理器/窗口创建完成事件.md +++ b/.qoder/repowiki/zh/content/事件系统/窗口表单事件管理器/窗口创建完成事件.md @@ -3,7 +3,7 @@ **本文档引用文件** - [WindowFormEventManager.ts](file://src/events/WindowFormEventManager.ts) -- [WindowService.ts](file://src/services/WindowService.ts) +- [WindowFormService.ts](file://src/services/WindowFormService.ts) ## 目录 @@ -16,11 +16,11 @@ `windowFormCreated` 事件在新窗口实例成功挂载并完成首次渲染后触发,标志着窗口已完全初始化并可交互。该事件不携带任何参数,作为全局窗口创建完成的信号。 -根据 `WindowFormEventManager.ts` 中的定义,此事件是 `IWindowFormEvent` 接口的一部分,由 `wfem` 事件管理器负责分发。虽然当前实现中未直接显示触发逻辑,但结合 `WindowService.ts` 的窗口创建流程可知,该事件应在 `createWindow` 方法执行完毕、DOM 元素已添加至页面且应用内容加载完成后被通知。 +根据 `WindowFormEventManager.ts` 中的定义,此事件是 `IWindowFormEvent` 接口的一部分,由 `wfem` 事件管理器负责分发。虽然当前实现中未直接显示触发逻辑,但结合 `WindowFormService.ts` 的窗口创建流程可知,该事件应在 `createWindow` 方法执行完毕、DOM 元素已添加至页面且应用内容加载完成后被通知。 **Section sources** - [WindowFormEventManager.ts](file://src/events/WindowFormEventManager.ts#L41-L41) -- [WindowService.ts](file://src/services/WindowService.ts#L83-L118) +- [WindowFormService.ts](file://src/services/WindowService.ts#L83-L118) ## 应用场景分析 @@ -35,7 +35,7 @@ **Section sources** - [WindowFormEventManager.ts](file://src/events/WindowFormEventManager.ts#L41-L41) -- [WindowService.ts](file://src/services/WindowService.ts#L83-L118) +- [WindowFormService.ts](file://src/services/WindowService.ts#L83-L118) ## 事件监听代码范例 @@ -58,7 +58,7 @@ wfem.addEventListener('windowFormCreated', () => { **Section sources** - [WindowFormEventManager.ts](file://src/events/WindowFormEventManager.ts#L60-L60) -- [WindowService.ts](file://src/services/WindowService.ts#L83-L118) +- [WindowFormService.ts](file://src/services/WindowService.ts#L83-L118) ## 生命周期时序关系 @@ -73,4 +73,4 @@ wfem.addEventListener('windowFormCreated', () => { **Section sources** - [WindowFormEventManager.ts](file://src/events/WindowFormEventManager.ts#L41-L41) -- [WindowService.ts](file://src/services/WindowService.ts#L83-L118) \ No newline at end of file +- [WindowFormService.ts](file://src/services/WindowService.ts#L83-L118) \ No newline at end of file diff --git a/.qoder/repowiki/zh/content/事件系统/窗口表单事件管理器/窗口数据更新事件.md b/.qoder/repowiki/zh/content/事件系统/窗口表单事件管理器/窗口数据更新事件.md index a8f567b..06e56ae 100644 --- a/.qoder/repowiki/zh/content/事件系统/窗口表单事件管理器/窗口数据更新事件.md +++ b/.qoder/repowiki/zh/content/事件系统/窗口表单事件管理器/窗口数据更新事件.md @@ -3,7 +3,7 @@ **本文档引用文件** - [WindowFormEventManager.ts](file://src/events/WindowFormEventManager.ts) -- [WindowService.ts](file://src/services/WindowService.ts) +- [WindowFormService.ts](file://src/services/WindowFormService.ts) - [WindowFormTypes.ts](file://src/ui/types/WindowFormTypes.ts) @@ -73,14 +73,14 @@ I --> J[接收端更新UI] ``` **Diagram sources** -- [WindowService.ts](file://src/services/WindowService.ts#L512-L552) -- [WindowService.ts](file://src/services/WindowService.ts#L248-L304) -- [WindowService.ts](file://src/services/WindowService.ts#L179-L213) +- [WindowFormService.ts](file://src/services/WindowService.ts#L512-L552) +- [WindowFormService.ts](file://src/services/WindowService.ts#L248-L304) +- [WindowFormService.ts](file://src/services/WindowService.ts#L179-L213) **Section sources** -- [WindowService.ts](file://src/services/WindowService.ts#L512-L552) -- [WindowService.ts](file://src/services/WindowService.ts#L248-L304) -- [WindowService.ts](file://src/services/WindowService.ts#L179-L213) +- [WindowFormService.ts](file://src/services/WindowService.ts#L512-L552) +- [WindowFormService.ts](file://src/services/WindowService.ts#L248-L304) +- [WindowFormService.ts](file://src/services/WindowService.ts#L179-L213) ## 接收端批量更新UI的TypeScript示例 接收 `windowFormDataUpdate` 事件后,应使用接收到的完整数据对象一次性批量更新UI,避免逐个属性设置带来的性能开销和视觉闪烁。以下为推荐的处理方式: @@ -146,4 +146,4 @@ wfem.addEventListener('windowFormDataUpdate', debouncedHandler); **Section sources** - [WindowFormEventManager.ts](file://src/events/WindowFormEventManager.ts#L37-L37) -- [WindowService.ts](file://src/services/WindowService.ts#L67-L118) \ No newline at end of file +- [WindowFormService.ts](file://src/services/WindowService.ts#L67-L118) \ No newline at end of file diff --git a/PROJECT_SUMMARY.md b/PROJECT_SUMMARY.md index a4b037d..9d9e41d 100644 --- a/PROJECT_SUMMARY.md +++ b/PROJECT_SUMMARY.md @@ -17,7 +17,7 @@ ### 核心服务层 -- **[WindowService](./src/services/WindowService.ts)** - 窗体管理服务,支持完整的窗体生命周期 +- **[WindowFormService](src/services/WindowFormService.ts)** - 窗体管理服务,支持完整的窗体生命周期 - **[ResourceService](./src/services/ResourceService.ts)** - 资源管理服务,提供权限控制和资源访问 - **[ApplicationSandboxEngine](./src/services/ApplicationSandboxEngine.ts)** - 应用沙箱引擎,多层安全隔离 - **[ApplicationLifecycleManager](./src/services/ApplicationLifecycleManager.ts)** - 应用生命周期管理 @@ -89,7 +89,7 @@ │ │ ├── ExternalAppDiscovery.ts │ │ ├── ResourceService.ts │ │ ├── SystemServiceIntegration.ts -│ │ └── WindowService.ts +│ │ └── WindowFormService.ts │ ├── stores │ │ └── counter.ts │ ├── ui @@ -178,7 +178,7 @@ const systemService = inject('systemService') 可用服务: -- `getWindowService()` - 窗体服务 +- `getWindowFormService()` - 窗体服务 - `getResourceService()` - 资源服务 - `getSandboxEngine()` - 沙箱引擎 - `getLifecycleManager()` - 生命周期管理器 diff --git a/src/events/IEventBuilder.ts b/src/events/IEventBuilder.ts index cdc0af6..d6b543c 100644 --- a/src/events/IEventBuilder.ts +++ b/src/events/IEventBuilder.ts @@ -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' /** diff --git a/src/services/ApplicationLifecycleManager.ts b/src/services/ApplicationLifecycleManager.ts index 54446c8..7b142e6 100644 --- a/src/services/ApplicationLifecycleManager.ts +++ b/src/services/ApplicationLifecycleManager.ts @@ -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()) private appFiles = new Map>() // 应用文件存储 - 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 } diff --git a/src/services/SystemServiceIntegration.ts b/src/services/SystemServiceIntegration.ts index db5b825..af0533f 100644 --- a/src/services/SystemServiceIntegration.ts +++ b/src/services/SystemServiceIntegration.ts @@ -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 - 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 { + public async initialize(): Promise { 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 { + public async shutdown(): Promise { 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 diff --git a/src/services/WindowFormService.ts b/src/services/WindowFormService.ts index cfab658..ab477eb 100644 --- a/src/services/WindowFormService.ts +++ b/src/services/WindowFormService.ts @@ -157,7 +157,7 @@ export interface WindowEvents extends IEventMap { /** * 窗体管理服务类 */ -export class WindowService { +export class WindowFormService { private windows = reactive(new Map()) private activeWindowId = ref(null) private nextZIndex = 1000 diff --git a/src/ui/components/WindowManager.vue b/src/ui/components/WindowManager.vue index d826645..6a517c7 100644 --- a/src/ui/components/WindowManager.vue +++ b/src/ui/components/WindowManager.vue @@ -78,7 +78,7 @@ const closeWindow = (windowId: string) => { // 通知系统服务关闭窗口 if (systemService) { - const windowService = systemService.getWindowService() + const windowService = systemService.getWindowFormService() windowService.destroyWindow(windowId) } } diff --git a/src/ui/desktop-container/DesktopContainer.vue b/src/ui/desktop-container/DesktopContainer.vue index 041ae6a..fbfac0e 100644 --- a/src/ui/desktop-container/DesktopContainer.vue +++ b/src/ui/desktop-container/DesktopContainer.vue @@ -50,7 +50,7 @@ const systemStatus = ref({ 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,