dsh-plugin-workbench 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,32 @@
4
4
  格式基于 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),
5
5
  版本号遵循 [Semantic Versioning](https://semver.org/lang/zh-CN/)。
6
6
 
7
+ ## [0.0.8] - 2026-08-20
8
+
9
+ ### Fixed
10
+
11
+ - **删除/复制被占用文件夹不再报裸 "permission denied"**:Windows 上文件夹或其
12
+ 内部任一文件被其他程序占用(编辑器、资源管理器、终端 cd 其中、杀毒扫描)时,
13
+ 改名/删除会以 EPERM/EBUSY 失败。host 端 `rename` / `delete` / `copy` 端点
14
+ 现在先做**有界重试**(3 次、150/300ms 间隔),可自动扛过索引器/杀毒的瞬时
15
+ 占用;仍失败时返回可操作的提示「`名称` is in use by another program —
16
+ close any editor/Explorer view of it (or a terminal inside it) and retry」,
17
+ 替代原先无指引的 "permission denied"
18
+ - **树内复制文本不再误触发文件复制**:在树中选中文件/文件夹后,再去选中树内
19
+ 的实际文本(如行内错误提示)按 Ctrl/Cmd+C/X 时,此前会拦截浏览器原生复制、
20
+ 把选中的文件放进插件剪贴板。现改为:存在非空文本选区或焦点在可编辑元素时,
21
+ 快捷键交给浏览器原生处理,复制的是文字而非文件
22
+
23
+ ## [0.0.7] - 2026-08-19
24
+
25
+ ### Fixed
26
+
27
+ - **跨工作区粘贴(复制冲突)不再报 Zod 校验错误**:复制/粘贴遇到目标已存在时,
28
+ host 端此前返回自定义错误码 `code: 'exists'`,而通用 RPC 通道的错误体受核心
29
+ 封闭错误码联合校验(`rpcErrorSchema`)约束,客户端解析直接抛 `invalid_union`,
30
+ 覆盖确认对话框根本不会出现。现改为在**成功值**中返回 `exists: true` 标志
31
+ (OS 文件管理器语义),客户端据此询问是否覆盖,行为不变、报错消除
32
+
7
33
  ## [0.0.6] - 2026-08-19
8
34
 
9
35
  ### Added
package/README.md CHANGED
@@ -4,10 +4,12 @@
4
4
  ![License](https://img.shields.io/github/license/Pasumao/dsh-plugin-workbench)
5
5
  ![CI](https://img.shields.io/github/actions/workflow/status/Pasumao/dsh-plugin-workbench/ci.yml?branch=main)
6
6
  ![Stars](https://img.shields.io/github/stars/Pasumao/dsh-plugin-workbench?style=social)
7
+ ![AI Assisted](https://img.shields.io/badge/AI-Assisted-8A2BE2)
7
8
 
8
9
  **能直接改文件的 VS Code 风格工作台**——不是只读预览:文件树 + 可编辑代码预览
9
- (语法高亮、标签页、行号栏)+ 右键文件操作(新建 / 重命名 / 删除 / 在系统中打开 /
10
- 在资源管理器打开)+ 图片内联预览,每个工作区独立保存状态。装上之后,DSH 网页就是一个轻量代码编辑器。
10
+ (语法高亮、标签页、行号栏)+ 右键文件操作(新建 / 重命名 / 删除 / 复制 / 剪切 /
11
+ 粘贴 / 在系统中打开 / 在资源管理器打开)+ 图片内联预览,每个工作区独立保存状态。
12
+ 装上之后,DSH 网页就是一个轻量代码编辑器。
11
13
 
12
14
  > ⚠️ 安装后需打一个布局补丁(见下方安装节)。
13
15
 
@@ -23,9 +25,18 @@
23
25
  - **行号栏**:编辑器左侧逻辑行号,与文本滚动锁定对齐(纯文本/高亮模式均生效)
24
26
  - **图片预览**:png/jpg/gif/webp/avif/svg 等直接内联渲染(同源字节路由,20MB 上限)
25
27
  - **右键菜单**(VS Code 风格):文件/文件夹/空白区域均可右键——
26
- 新建文件、新建文件夹、重命名、删除(递归带确认)、复制路径、刷新、在系统中打开、
28
+ 新建文件、新建文件夹、重命名、删除(递归带确认)、复制路径、复制 / 剪切 / 粘贴、
29
+ 刷新、在系统中打开、
27
30
  在资源管理器打开(文件在所在文件夹中被选中,文件夹直接打开;
28
31
  Windows `explorer` / macOS `open`,WSL 自动转译)
32
+ - **复制 / 剪切 / 粘贴**:Ctrl/Cmd+C/X/V(或右键菜单),支持跨工作区粘贴;
33
+ 复制到同名已存在的目标时询问「是否覆盖」,与系统文件管理器一致;
34
+ 剪切(移动)成功后自动清空剪贴板
35
+ - **批量操作**:Ctrl/Cmd+点击、Ctrl+A 多选,右键菜单/Delete 批量删除选中项,
36
+ 拖拽整组移动
37
+ - **操作可撤销**:右上角「↩」或 Ctrl+Z 撤销最近操作(每工作区独立、上限 30 条):
38
+ 复制(删副本)、剪切/拖拽移动(移回原位)、重命名、新建、删除;删除为可撤销删除
39
+ (瞬移进隐藏 `.dsh-trash`,不复制字节)
29
40
  - **在资源管理器打开**:右键菜单项(同 VS Code 的 Reveal in File Explorer),
30
41
  把文件/文件夹定位到系统文件管理器(Windows 资源管理器、macOS Finder 等),
31
42
  经 loopback RPC 的 `reveal` 端点执行
@@ -38,6 +49,15 @@
38
49
  - 磁盘变更:宿主对打开文件做 `fs.watch`(监听父目录,可存活原子重命名),
39
50
  变更经 SSE `/dsh-plugin-files/events` 推送,干净标签自动同步
40
51
 
52
+ ## 配置
53
+
54
+ 无需环境变量或配置文件,安装后打一次布局补丁即可:
55
+
56
+ - **布局补丁**:`node node_modules/dsh-plugin-workbench/scripts/patch-layout.mjs`
57
+ (针对 `dsh-client-ui-layout@0.1.0-rc.6` 编写,DSH 升级覆盖 bundle 后需重跑);
58
+ - **行为偏好**(自动换行、亮暗主题、标签布局、文件树展开状态)按工作区持久化,无需手动配置;
59
+ - **文件操作通道**:经 loopback RPC `/dsh-plugin-files`,写操作显式以 `danger-full-access` 执行,无外部配置项。
60
+
41
61
  ## 安装
42
62
 
43
63
  > 布局补丁针对 `dsh-client-ui-layout@0.1.0-rc.6` 编写,其他版本需更新锚点。
@@ -49,6 +69,16 @@ dsh plugin --profile web add dsh-plugin-workbench
49
69
  dsh plugin --profile web add github:Pasumao/dsh-plugin-workbench
50
70
  ```
51
71
 
72
+ 源码安装(本地开发 / 调试):
73
+
74
+ ```bash
75
+ git clone https://github.com/Pasumao/dsh-plugin-workbench.git
76
+ cd dsh-plugin-workbench
77
+ pnpm install
78
+ pnpm run build # 产出 lib/index.js 与 lib/client.js
79
+ # 以 link: 方式挂载进 profile
80
+ ```
81
+
52
82
  安装后打布局补丁并重启:
53
83
 
54
84
  ```powershell
package/lib/client.js CHANGED
@@ -1280,10 +1280,7 @@ window.__ModuleLoader__.load({
1280
1280
  if (sameDest) dest = joinPath(targetDir, copyName(item.name));
1281
1281
  let overwritten = false;
1282
1282
  try {
1283
- try {
1284
- await copyPath(item.path, dest, false);
1285
- } catch (error) {
1286
- if (error.code !== "exists") throw error;
1283
+ if ((await copyPath(item.path, dest, false)).exists === true) {
1287
1284
  if (!window.confirm(t("confirm.overwrite", { name: item.name }))) continue;
1288
1285
  overwritten = true;
1289
1286
  await copyPath(item.path, dest, true);
@@ -1652,6 +1649,12 @@ window.__ModuleLoader__.load({
1652
1649
  const onTreeKeyDown = (0, react.useCallback)((e) => {
1653
1650
  const mod = e.ctrlKey || e.metaKey;
1654
1651
  const key = e.key.toLowerCase();
1652
+ if (mod && (key === "c" || key === "x")) {
1653
+ const target = e.target;
1654
+ if (target !== null && (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable)) return;
1655
+ const selection = window.getSelection();
1656
+ if (selection !== null && !selection.isCollapsed && selection.toString().length > 0) return;
1657
+ }
1655
1658
  if (mod && key === "c") {
1656
1659
  const items = selectedItems();
1657
1660
  if (items.length === 0) return;