Closed
Conversation
主要更改:
1. 数据库表结构更新 (extension.ts)
- 将 disabled (boolean) 字段改为 enabled (uuid array)
- 每个客户端可以独立启用/禁用插件
- 添加 isEnabledForClient() 方法检查插件是否对特定客户端启用
2. ExtensionManager 核心实现 (extensionManager.ts)
- 完整的插件生命周期状态机:
DISCOVERED → LOADING → LOADED → INITIALIZING → READY → ACTIVATING → ACTIVE
支持 DEACTIVATING → READY 和 UNLOADING → UNLOADED 转换
任何阶段可进入 ERROR 状态,支持重试机制
- 插件接口定义 (IExtension):initialize, activate, deactivate, dispose
- ExtensionInstance 类:管理单个插件实例的状态和错误
- ExtensionManager 类:
* 从数据库发现插件
* 并行加载插件(使用 Promise.allSettled 实现错误隔离)
* 动态启用/禁用插件
* 完整的 startup/shutdown 流程
* 重试机制(最多3次)
3. UI 组件更新
- ExtensionCard 组件:
* 添加 clientId prop
* 更新 toggle 逻辑使用新的 enable/disable 方法
* 根据 clientId 显示正确的启用状态
- Extensions View:
* 添加客户端选择下拉框
* 从所有插件的 enabled 数组中提取可用的客户端 ID
* 根据选择的客户端过滤和显示插件状态
- 样式更新:为客户端选择器添加响应式布局
特性:
- 并行加载:使用 Promise.allSettled 同时加载多个插件
- 错误隔离:单个插件失败不影响其他插件
- 状态追踪:详细的日志记录每个状态转换
- 灵活配置:每个客户端独立的插件配置
1. 实现 Module Federation 实际加载逻辑 - 使用动态 script 标签加载远程入口 - 支持动态 import 导入远程模块 - 实现 loadRemoteEntry 方法 2. 添加 Client 模型 (src/business/client.ts) - 使用 zod-class 定义客户端模型 - 支持 ping 检查在线状态 - 支持向远程客户端发送请求 - 实现 enableExtension/disableExtension 远程调用 3. 完善配置管理 (src/config.ts) - 添加 zod schema 验证 - 实现 localStorage 持久化 - 添加 LOCAL_CLIENT_ID 字段 - 提供 configUtils 工具函数 4. 扩展 ExtensionManager 功能 - 添加 enableExtensionForClient 方法 - 添加 disableExtensionForClient 方法 - 自动判断本地/远程客户端并调用相应逻辑 系统设计: - 所有节点平等,无"后端"概念 - 本地客户端 ID 存储在 localStorage - 支持联邦化的插件管理 Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.