Repository navigation
feat: 支持按通道名注册事件监听器和全局事件分发 - #3
Conversation
- 添加 addEventListener/removeEventListener 方法,支持按通道名过滤事件 - MagicDrag 子类可通过静态 channelName 指定跨标签页通信通道 - Manager 统一分发所有拖拽信号(包括 HEARTBEAT 等系统消息) - 无监听器时记录可观测日志,便于调试 - 修复跨标签页拖拽时 activeTabId 更新逻辑 - 新增 .npmignore 和 specs/ 目录 - 更新项目文档和配置文件
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- 将 MagicDrag.channelName 改为 readonly - 移除冗余的类型别名 MagicDragAnyEventListenerStore - 更新 MagicDragManager 使用正确的类型 MagicDragEventListenerStore 修复了以下 ESLint 错误: - sonarjs/public-static-readonly - sonarjs/redundant-type-aliases
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1685ca4b7f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- 添加 messageListeners Set 来存储通过 addEventListener 注册的监听器 - 实现 addEventListener 方法 - 实现 removeEventListener 方法 - 修改 postMessage 方法以同时触发 onmessage 和 addEventListener 监听器 修复了测试环境中的 TypeError: channel.addEventListener is not a function 错误
问题:在 handleExternalDragMove 中,只有当鼠标进入某个 Tab 时才更新 activeTabId,但鼠标离开 Tab 时不会清除它。这导致当用户拖出所有 Tab 后,activeTabId 仍然保持为最后一个进入的 Tab ID,使得 MagicDrag.handleDragEnd 中的 abort 条件 (!dragState.activeTabId) 永远无法满足。 修复:在 handleExternalDragMove 中添加逻辑,当鼠标不在当前 Tab 内且 activeTabId 等于当前 Tab ID 时,将 activeTabId 设为 null。这样当用户拖出所有 Tab 时,activeTabId 会变为 null,从而正确触发 DRAG_ABORT。
概述
channelName指定跨标签页通信通道主要改动
新增功能
事件监听器管理
addEventListener(type, listener, options)- 注册事件监听器,支持按channelName过滤removeEventListener(type, listener)- 移除事件监听器通道名支持
channelName属性指定使用的通信通道全局事件分发
可观测性增强
行为变更
activeTabId在拖拽开始和进入目标标签页时更新,确保跨标签页拖拽状态正确文档和配置
.npmignore,优化发布的包大小specs/目录,包含 001-manager-dispatch 的完整设计文档测试
Breaking Changes
无
相关 Issue
Closes #?