Skip to content

feat: 仅在侧栏打开时启用划词浮窗 - #3

Merged
dolphin-boop merged 1 commit into
mainfrom
feat/panel-gated-selection
Sep 17, 2026
Merged

dolphin-boop merged 1 commit into
mainfrom
feat/panel-gated-selection

Conversation

@dolphin-boop

Copy link
Copy Markdown
Owner

问题:content.js 作为静态 content script 常驻所有页面,侧栏未打开时划线也会弹出三功能浮窗,造成打扰。

方案:

  • sidepanel.js 打开时用 chrome.runtime.connect 登记 yidu-panel-open:<tabId>,关闭时端口自动断开
  • background.js 维护 panelOpenTabs,向对应标签页推送 YIDU_PANEL_STATE;并响应 YIDU_PANEL_STATE_QUERY(覆盖内容脚本晚注入的场景)
  • content.js 默认 panelOpen = false,未打开侧栏时不渲染浮窗并隐藏已有浮窗

验证:npm test 34/34 通过,npm run check 通过;新增结构测试锁定该门控行为。

- 侧栏打开时通过长连接向 background 登记所属标签页,关闭即注销
- background 维护打开状态集合并向内容脚本推送 YIDU_PANEL_STATE
- 内容脚本默认关闭划词浮窗,仅在收到打开状态后响应选中
- 顺带修正 release 测试对截图文件名的硬编码,README 验证数更新为 34
@dolphin-boop
dolphin-boop merged commit b91f1ae into main Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant