feat(file-tree): 行菜单支持外部插件注册动作(registerFileAction,feature 'fileActions')

文件树的行菜单此前完全由插件自己组装(打开方式 / 下载 / 上传到此目录 /
复制 / 重命名 / 删除),外部插件没有任何位置能加一项——「把这个文件传到
我的云端」这类入口只能另开界面,而它需要的恰恰是这个文件。

新增第四个注册表 `registerFileAction(descriptor)`(能力 'fileActions'):

- 菜单项排在内置打开/下载行之后、复制/重命名之前,多条外部动作之间不加
  分隔线,第一个之前有一条;排序 order 升序、同 order 按注册序;
- `row: true` 在行右侧「引用」按钮旁再加一个悬停按钮(要求同时给 icon,
  无图标的注册只进菜单);
- 回调拿到行的绝对路径 + 这棵树的 root 与会话;目录默认不认领(`dirs`);
- `when` 每行渲染与每次开菜单各调一次,抛错只隐藏该注册,不打断文件树;
- `run` 抛错/reject 以 error.message 落进既有错误条,resolve 静默(成功
  提示由注册方自己给),同一 (id, path) 在飞行中的重复点击被忽略;
- 树只提供入口:不替注册方上传、复制或移动任何东西。

文档:指南新增 §7.3(类型、用例、渲染位置、两条约定),§1/§7 能力清单与
README 扩展点计数同步;CHANGELOG 中英各一条。

测试:新增 tests/file-actions.spec.tsx(12 例,注册表 5 + 文件树 7);
tests/file-tree-row-memo / file-tree-menu-perf 的最小 service stub 补
getFileActions(它们的计数器仍是重渲染探针)。
This commit is contained in:
lu.wang7 committed 2026-11-08 00:07:03 +08:00
1 parent bd6363021d
commit bff5beb689
11 files changed
+706 -6

No files matched your search

+34
View File
@@ -1048,6 +1048,40 @@ body[data-dsh-sidebar-dragging] .bottomPanel {
color: var(--dsw-alias-label-tertiary);
}
/* Externally registered row actions (feature `fileActions`, `row: true`):
glyph buttons beside the reference button, revealed with it on hover or
focus. The trailing affordances ride the reference button's auto margin,
so a second and third button simply follow it. */
.explorerAction {
flex: none;
display: none;
align-items: center;
justify-content: center;
width: 20px;
height: 20px;
padding: 0;
border: none;
border-radius: 4px;
background: transparent;
color: var(--dsw-alias-label-tertiary);
cursor: pointer;
}
.explorerAction:hover {
background: var(--dsw-alias-interactive-bg-hover);
color: var(--dsw-alias-label-primary);
}
.explorerAction:focus-visible {
outline: 2px solid var(--dsw-alias-brand-primary);
outline-offset: 1px;
}
.explorerRow:hover .explorerAction,
.explorerRow:focus-within .explorerAction {
display: inline-flex;
}
.explorerError {
font: var(--dsw-font-xxs-12);
color: var(--dsw-alias-state-error-primary);