Repository navigation
feat(browser): 侧栏网页右键菜单(关联 #358) - #366
Merged
freedomkk-qfeng merged 2 commits intoNov 26, 2026
Merged
Conversation
A page in the Sidebar browser showed nothing on a right click. The desktop bridge now opens a native menu for what was clicked, in the application's language: link items (new tab, system browser, copy address), image items (copy image, copy address), editing or copy for fields and selected text, and back, forward and reload elsewhere. New tabs and the system browser go through the same paths as the Sidebar's own toolbar and DSH's popup checks. The broker marks a page whose latest input came from its Agent, so the Agent's right clicks and menu keys reach the page's own handlers without showing a menu on the user's screen. Closes ECNU#358
This was referenced Nov 26, 2026
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.
关联 #358
问题与修改
侧栏浏览器里的网页右键没有任何反应:DSH 只给应用页面装了右键菜单(
main.ts),侧栏网页(webview)没有。本 PR 在桌面桥里给每个侧栏网页加原生右键菜单,内容取决于右键点在哪里:
javascript:这类被 Chromium 拦下的链接不显示链接项;mailto:等非网页链接只能复制地址。copyImageAt只能从顶层文档取图。菜单文字跟随应用语言(DSH 的 8 种):编辑项用 DSH 主窗口菜单的译文;后退、前进、刷新、系统浏览器用 DSH 侧栏工具栏的译文;复制链接地址用 DSH“在应用中打开”菜单的译文。DSH 以后新增的语言显示英文。
两个打开项都走现有的路径:
window.open,经过 DSH 对地址的检查,和网页里的弹窗一样新开侧栏标签页。window.open,和侧栏工具栏的同名按钮走同一条路,打开失败时同样提示“无法打开链接”。Agent 的右键:Agent 经 broker 发出的右键和菜单键(Shift+F10、菜单键)也会触发网页的
context-menu事件,不拦的话,菜单会弹到用户屏幕上。broker 转发 Agent 的输入时给这个网页做个标记,用户自己按下鼠标或按键时清掉;有标记时不弹菜单,网页自己的contextmenu事件照常触发。这依赖现有的锁定层:Agent 操作某个标签页时用户的输入进不去,所以两者不会在一次操作里交错。菜单的实现在新文件
dsh-electron/src/sidebar-browser-menu.mjs。桌面桥在 DSH 绑定侧栏网页时挂上菜单,释放时卸下。插件 README(中英文)的「桌面侧栏」一节加了一条说明。验证
sidebar-browser.test.mjs(锁定的 Electron 44.0.0,真实 broker 和sidebar-client.js),新增右键测试:mailto:链接、坏图、跨站 iframe 里的图片、正常图片、输入框、选中的文字、空白处,核对每个菜单的内容,并逐项点击看效果:剪贴板内容、新标签页、交给系统浏览器的地址、撤销和剪切、后退、刷新。contextmenu事件照常发生。probe-native-desktop.mjs,本地构建的壳)新增一项:经真实桌面桥右键一个受保护网页,菜单按应用语言显示,并且只弹一份。反向验证:在网页上再挂一个菜单时,这一项失败。installer-cleanup.test.mjs里的“桌面桥离线恢复界面语言”用例通过(已给新模块加 mock)。popup;DSH 主窗口的菜单用的是同样的写法。已知问题与后续
sidebar-browser.test.mjs的each conversation drives only its own tabs会偶发失败(连接时还没有标签页)。main 在同一环境里 4 次失败 3 次,与本 PR 无关。回执里另有 #365 的 28 个文件:#365 合并时没有刷新回执,这里一并更正。