dsh-gallery 1.4.2 → 1.5.0
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 +46 -0
- package/README.md +32 -5
- package/client.js +144 -0
- package/host/constants.js +6 -0
- package/host/context.js +33 -0
- package/host/http.js +266 -34
- package/host/manifest.js +379 -0
- package/host/tools.js +206 -2
- package/index.js +10 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,49 @@
|
|
|
1
|
+
## v1.5.0 · 交付清单(一个内核两个出口)+ 本地登记可清除(2026-11-25)
|
|
2
|
+
|
|
3
|
+
> 这一版只**加东西**,不改任何已有交互:现有标签 / 遮罩 / 批量 / 对比全部照旧。
|
|
4
|
+
> 改了 Host(新增模块)与前端(批量条 + 设置区各加一处),**需彻底重启 DSH(含托盘)生效**。
|
|
5
|
+
|
|
6
|
+
**1. 导出交付清单(批量条 →「导出清单」)**
|
|
7
|
+
选中一批 → 点一下 → CSV 与 JSON 同时落到 `<DSH_HOME>/gallery-exports/`,同名自动加 `-2`,绝不覆盖。
|
|
8
|
+
|
|
9
|
+
- CSV **带 UTF-8 BOM**。这条不能省:Excel 双击打开无 BOM 的 UTF-8 会按系统 ANSI(中文环境 GBK)解析,中文全变乱码。
|
|
10
|
+
- 列:序号 / 文件名 / 相对路径 / 分类 / 尺寸 / 体积 / 修改时间 / 来源对话 / 来源视频 / 时间码 / 遮罩 / 备注(备注列可由调用方关掉)。
|
|
11
|
+
- 转义按 RFC 4180 走:逗号、引号、换行都整格包引号,内部引号写成两个 —— 少做一步,Excel 就会把一格拆成两列。
|
|
12
|
+
- **尺寸不额外读盘**:扫描结果本身带 `width` / `height` / `size`,直接取;只有缺字段的才读文件头补(`regions.js` 的零依赖解析,一次 open 同时拿 stat)。实测全库 6930 条,需要读盘的只有个位数。
|
|
13
|
+
- **落点刻意不在产出目录**:清单是 `.csv` / `.json`,而扫描扩展名里正好有这两类,写进产出目录下次刷新它就成了一个「文件资产」,越导越多。所以固定落 `<DSH_HOME>/gallery-exports/`。
|
|
14
|
+
|
|
15
|
+
**2. 第 5 个 Agent 工具 `gallery_manifest`(只读)**
|
|
16
|
+
`find / context / regions / reply` 之外新增一个:按分类或选中范围取结构化清单,带尺寸、体积、来源对话、**来源视频与时间码**、有无遮罩、反馈备注。
|
|
17
|
+
|
|
18
|
+
- 这是「收集完能驱动下一轮」的那一半:您说「把这批定稿的清单给我,然后按批注改」,一次调用就能拿到全部依据,不用手工截图或抄文件名。
|
|
19
|
+
- 与导出共用 `host/manifest.js` 的同一个 `buildManifest()` —— 模型读到的条数、分类计数、时间码,跟您导出的 CSV 必须完全对得上。
|
|
20
|
+
- 只读:不落盘、不发消息。要文件请点面板上的「导出清单」。
|
|
21
|
+
- 首次调用约 7 秒(全库 6930 个文件的扫描成本),之后 12 秒内复用;同一轮连问两次不会扫两遍。
|
|
22
|
+
|
|
23
|
+
**3. 本地登记(隐私):看得见、清得掉**
|
|
24
|
+
设置面板底部新增一栏,把「插件到底在你机器上存了什么」摆在明面上:
|
|
25
|
+
|
|
26
|
+
- **清空浏览记录**:删 `dsh-gallery-context.json`(你看过哪几张),不影响标签、遮罩、反馈。
|
|
27
|
+
- **清空全部标注**:手动标签 + 截帧登记 + 反馈 + 判定标记。**要点两次**:第一下只把按钮变成「确认清空?」,并明确告知「点这一下什么都没动」。
|
|
28
|
+
- Host 侧是两阶段:先 `dryRun` 报出各类条数并发一个 `digest`,确认时必须回传同一个 digest,中途登记有变化就拒绝(409)—— 防「看着 3 条、删掉 30 条」。
|
|
29
|
+
- **只清登记文件,绝不碰任何资产文件**:`clearState` 里唯一的删除操作是浏览记录,其余四类写回空结构(保留 schema)。
|
|
30
|
+
- 新增设置项 `contextTtlHours`(默认 **0 = 永不自动清理**):这是「你最近看了哪几张」的记录,自动删掉会让助手答不上「我刚看的那张是什么」,所以默认不碰,想要自动清的人自己开。
|
|
31
|
+
|
|
32
|
+
**4. 文档纠错(旧文档的错,不是新功能)**
|
|
33
|
+
README 隐私段原写「只有**五个**文件」,实际第六个 `dsh-gallery-context.json`(浏览记录)从 v0.10 就在写,一直没列入。
|
|
34
|
+
本版补齐为六个,并新增「能不能自己清干净」一行。同时把「按标签」的说法统一为「按分类」—— 插件里是四个固定分类,没有自由标签,旧措辞会让人以为能自定义标签。
|
|
35
|
+
|
|
36
|
+
**5. 显式选中的继承 / 共享资产不再被静默丢弃(交付前排障)**
|
|
37
|
+
批量选了 10 张、其中 2 张带「继承」角标,导出只出 8 条,而提示照样写「已导出 8 条清单」—— 用户不数一遍根本发现不了。
|
|
38
|
+
根因不在内核:`buildManifest()` 的两种行为都对(默认排除、`includeInherited:true` 包含),
|
|
39
|
+
错在两个调用方(op `exportManifest` 与工具 `gallery_manifest`)都**没把「用户在界面上手动选中」这件事透进去**,于是永远走默认排除。
|
|
40
|
+
现在改成:显式指名(有 `relPaths` / `selected`)就一定全导;只有「不选、按分类整批扫」时才排除,避免父子会话重复计数。
|
|
41
|
+
测试也补在调用方这一层(只测内核测不出这个坑,两种行为都是对的)。
|
|
42
|
+
|
|
43
|
+
**验证**
|
|
44
|
+
全量 **410/410**;白屏两关(`hooks-tdz` + `client-render-smoke`)通过;新增 `manifest.test.mjs` 15 条、`privacy.test.mjs` 7 条。
|
|
45
|
+
实测:全库 6930 条一次导出 CSV 978 KB / 19 ms 组装 / 读盘 0 次;Agent 工具 `total 136 / returned 8 / 尺寸全部补齐`。
|
|
46
|
+
|
|
1
47
|
## v1.4.2 · 资产台:深层文件 / 脚本音频 / 分叉共享 / 反向隔离 / 缩略图兜底 + 批量操作(2026-11-25 发布)
|
|
2
48
|
|
|
3
49
|
> 相对 1.4.0 的补丁版 + 交互补充:改了 Host 扫描与前端卡片,需彻底重启 DSH(含托盘)生效。
|
package/README.md
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
> 视频音频能在面板里直接播放并拖进度条,
|
|
9
9
|
> **让你在任务进行中就能看到产出、当场校验,而不是结束后才发现做错了。**
|
|
10
10
|
>
|
|
11
|
-
> 📌 **版本状态(2026-11-25)**:当前版本 `1.
|
|
11
|
+
> 📌 **版本状态(2026-11-25)**:当前版本 `1.5.0` —— 在 1.4.2 基础上新增 **「导出清单」把选中这批导成 CSV + JSON 交付清单**、**第 5 个 Agent 工具 `gallery_manifest`(让我直接读同一份清单,接着做下一轮)**、**设置里的「本地登记(隐私)」可一键清空浏览记录 / 全部标注**,并修正隐私文档漏列的第六个状态文件(改了 Host 与前端,需彻底重启 DSH 含托盘生效)。
|
|
12
|
+
> 1.4.2 的内容见下方「批量:圈一批,一次处理完」等章节。
|
|
12
13
|
> 注:线上 1.4.1 实际只包含「深层交付文件保底」一项,其余资产台改动从 1.4.2 起才生效。
|
|
13
14
|
> 1.4.0(2026-11-19)新增右键按住涂抹画遮罩(只描区域外轮廓)+ 卡面「复制文件 / 写进输入框」+ 反馈自动过期 + 临时文件不再漏。
|
|
14
15
|
> 1.2.0 新增**前后对比**:两张图叠在同一位置,中间一条滑块左右拖;**放大后两张锁在同一处、分割线留在屏幕上不动**,
|
|
@@ -25,7 +26,7 @@
|
|
|
25
26
|
> 图上**批注框跟随缩放平移**(放大后圈选仍落在原图同一处);**标注态按住鼠标中键拖动**即可平移图片、已画框跟着走。
|
|
26
27
|
> **`Ctrl+V` 直接在资产区粘贴素材**(图片/文件都行,标「素材」),**落在鼠标所指的那个对话组**;图片查看器有**带取色放大镜的裁剪**(绿框八向手柄、显示裁剪尺寸与光标处坐标色值),音视频播放器有**入点/出点选段裁剪**,产物归素材来源的那个对话、自动标「素材」。
|
|
27
28
|
|
|
28
|
-
[](#)
|
|
29
30
|
[](LICENSE)
|
|
30
31
|
[](#技术说明给想改代码的人)
|
|
31
32
|
[](#兼容性)
|
|
@@ -344,7 +345,7 @@ github:Hope2023Dcr/dsh-gallery
|
|
|
344
345
|
> ```
|
|
345
346
|
|
|
346
347
|
> 上面那个 commit 是 **v0.14.1** 的历史基线(表态层当时还在)。正式版可用
|
|
347
|
-
> `git+https://github.com/Hope2023Dcr/dsh-gallery.git#v1.
|
|
348
|
+
> `git+https://github.com/Hope2023Dcr/dsh-gallery.git#v1.5.0` 锁定版本。
|
|
348
349
|
> **更推荐直接用 npm**(`npm i dsh-gallery`)—— 版本号跟着 `latest` 走,不用每次手工核对哈希。
|
|
349
350
|
|
|
350
351
|
> ⚠️ 这种方式需要**能访问 GitHub**。DSH 的「国内镜像」只代理 npm 包,不代替 GitHub 下载。
|
|
@@ -496,6 +497,27 @@ config:
|
|
|
496
497
|
|
|
497
498
|
---
|
|
498
499
|
|
|
500
|
+
## 导出交付清单(v1.5.0)
|
|
501
|
+
|
|
502
|
+
选一批 → 批量条上点「导出清单」→ CSV 与 JSON 同时落到 `<DSH_HOME>/gallery-exports/`(`~/.dsh/gallery-exports/`)。
|
|
503
|
+
|
|
504
|
+
| 项 | 说明 |
|
|
505
|
+
|---|---|
|
|
506
|
+
| **格式** | CSV 给 Excel / WPS 看(**带 UTF-8 BOM**,否则双击打开中文会乱码);JSON 给下一轮或脚本读 |
|
|
507
|
+
| **列** | 序号、文件名、相对路径、分类、尺寸、体积、修改时间、来源对话、来源视频、时间码、遮罩、备注 |
|
|
508
|
+
| **尺寸从哪来** | 扫描结果本身带宽高就直接用(一次盘都不读);缺了才读文件头(`regions.js` 的零依赖解析)。实测全库 6930 条,需要读盘补的只有几条 |
|
|
509
|
+
| **来源视频 / 时间码** | 截帧才有:`卖炭翁_EP01.mp4 @ 00-02-17-892`,直接写进清单,交给后期不用再翻文件名猜 |
|
|
510
|
+
| **重名** | 绝不覆盖:同名自动加 `-2`、`-3` |
|
|
511
|
+
| **继承了别的对话的资产** | 只要您**手动选中**了它,就一定进清单(带「继承 / 共享」角标也照导)。只有「不选、按分类整批扫」时才排除,避免父子会话重复计数 |
|
|
512
|
+
| **落点为什么不在产出目录** | 清单是 `.csv` / `.json`,而扫描扩展名里正好有这两类 —— 写进产出目录,下次刷新它就成了一个「文件资产」出现在资产台里,越导越多 |
|
|
513
|
+
|
|
514
|
+
**和 Agent 的那一半是同一个内核**:模型那边对应的工具是 `gallery_manifest`(只读、不落盘)。
|
|
515
|
+
您导出的 CSV 和模型读到的清单,条数、分类计数、来源时间码完全一致 —— 两处都调 `host/manifest.js` 的同一个 `buildManifest()`。
|
|
516
|
+
|
|
517
|
+
> 想让我「按这份清单接着改」,直接把清单文件路径告诉我,或者让我调 `gallery_manifest` 取同一份数据即可,不必手工抄文件名。
|
|
518
|
+
|
|
519
|
+
---
|
|
520
|
+
|
|
499
521
|
## 安全
|
|
500
522
|
|
|
501
523
|
**风险等级:低~中。** 插件只操作本机产出目录、不上传任何数据;但**按需会调起四类本机程序**——
|
|
@@ -539,7 +561,9 @@ config:
|
|
|
539
561
|
|---|---|
|
|
540
562
|
| **网络请求** | **零**。插件不发起任何外部请求(已核查源码:无 `http`/`https`/`axios`/`WebSocket` 引用) |
|
|
541
563
|
| **上传** | **无**。没有任何上报、遥测、统计 |
|
|
542
|
-
| **落盘写操作** |
|
|
564
|
+
| **落盘写操作** | 只有**六个文件**,都在 `<DSH_HOME>/` 下:`dsh-gallery.json`(扫描目录列表 + 隐藏列表)、`dsh-gallery-marks.json`(判定标记)、`dsh-gallery-labels.json`(你手动改过的分类覆写)、`dsh-gallery-frames.json`(截帧 / 遮罩的来源与归属登记)、`dsh-gallery-feedback.json`(待处理反馈,v0.16.4 起)、`dsh-gallery-context.json`(你最近打开过哪几张、面板停在哪,v0.10 起)。没有第七个写入位置 |
|
|
565
|
+
| **导出清单** | v1.5.0 起多一个**你主动触发**的写入位置:`<DSH_HOME>/gallery-exports/`。只有点「导出清单」才会写,写的是 CSV / JSON 清单本身,**不写任何资产、不改任何原文件** |
|
|
566
|
+
| **能不能自己清干净** | 能。设置面板底部「本地登记(隐私)」里有「清空浏览记录」与「清空全部标注」;后者要点两次确认。也可以直接删上面六个 JSON(插件对文件缺失是容错的,删了只是少掉对应记忆) |
|
|
543
567
|
| **会话日志** | **只读**。解析 `~/.dsh/sessions/**` 来判定「本对话产出」,不修改、不复制、不上传 |
|
|
544
568
|
| **文件内容** | 预览时实时读磁盘,**不写进任何索引或缓存文件** |
|
|
545
569
|
| **内存缓存** | 会话日志解析结果只在内存里(按 `路径+mtime+size` 做键),不落盘 |
|
|
@@ -821,9 +845,12 @@ v1.3.0 解决的是「Agent 改完怎么回到眼前」;这一版全是**你
|
|
|
821
845
|
| **图片裁剪 + 像素取色放大镜(全分辨率取像素、绿框八向手柄、坐标色值)** | ✅ **v0.16.0**(放大镜 v1.0.2 重做) |
|
|
822
846
|
| **音视频入点/出点选段裁剪(本机 ffmpeg)** | ✅ **v0.16.0**(copy 偏差 > 0.5s 自动重编码兜底) |
|
|
823
847
|
| 自由笔刷 / 橡皮 / 笔刷大小 | ❌ 未做(多点闭合已覆盖实际需求) |
|
|
824
|
-
|
|
|
848
|
+
| **导出交付清单(CSV / JSON,助手读同一份)** | ✅ **v1.5.0**(2026-11-25;「按清单自动派单」仍未做) |
|
|
825
849
|
| 版本历史(同一文件跨 turn 的修改点) | ❌ 未做 |
|
|
826
850
|
| **前后对比(滑块 + 平铺、放大对齐、智能推荐配对)** | ✅ **v1.2.0**(2026-11-18;参数回灌仍未做) |
|
|
851
|
+
| **导出交付清单(CSV 带 BOM 给 Excel、JSON 给下一轮)** | ✅ **v1.5.0**(落 `~/.dsh/gallery-exports/`,同名不覆盖;显式选中的继承/共享资产照常导出) |
|
|
852
|
+
| **助手按分类 / 选中范围取结构化清单(`gallery_manifest`,只读)** | ✅ **v1.5.0**(与导出共用同一内核,条数不会对不上账) |
|
|
853
|
+
| **本地登记可见 + 可清(浏览记录 / 全部标注)** | ✅ **v1.5.0**(清全部标注要点两次;只清登记、不碰资产文件) |
|
|
827
854
|
| 自动 steer / cancel(独立包 `dsh-gallery-decision`) | ❌ 已放弃:与反馈栏重叠、绕过人工闸门 |
|
|
828
855
|
| 跨扫描目录合并视图(现在按目录分组) | ❌ 未做 |
|
|
829
856
|
| 文件内容变更 diff 预览 | ❌ 未做 |
|
package/client.js
CHANGED
|
@@ -1270,6 +1270,18 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
1270
1270
|
hiddenCount: '已隐藏 {count} 个',
|
|
1271
1271
|
hiddenClear: '全部恢复',
|
|
1272
1272
|
hiddenClearing: '恢复中…',
|
|
1273
|
+
// v1.5.0 隐私:本地登记说明与清空入口
|
|
1274
|
+
privacyLabel: '本地登记(隐私)',
|
|
1275
|
+
privacyHint: '下面这些文件在 ~/.dsh/ 下,明文保存,从不外发',
|
|
1276
|
+
privacyClearContext: '清空浏览记录',
|
|
1277
|
+
privacyClearContextHint: '删掉「你看过哪几张图」的记录;不影响标签、遮罩、反馈',
|
|
1278
|
+
privacyClearAnnotations: '清空全部标注',
|
|
1279
|
+
privacyClearAnnotationsHint: '删掉手动标签、截帧登记、反馈与判定标记;需要点两次确认,不可恢复',
|
|
1280
|
+
privacyClearAnnotationsConfirm: '确认清空?(再点一次)',
|
|
1281
|
+
privacyArmHint: '再点一次才会真的删;点这一下什么都没动',
|
|
1282
|
+
privacyClearing: '正在清空…',
|
|
1283
|
+
privacyCleared: '已清空 {n} 条本地登记',
|
|
1284
|
+
privacyClearFailed: '清空失败:{message}',
|
|
1273
1285
|
hiddenClearHint: '让所有被隐藏的文件重新出现在列表里(不会删除文件)',
|
|
1274
1286
|
hiddenCleared: '已全部恢复',
|
|
1275
1287
|
hiddenMore: '还有 {count} 个未显示',
|
|
@@ -1300,6 +1312,12 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
1300
1312
|
ctxCopyFileHint: '把该文件写入系统剪贴板,可在别的对话或资源管理器里粘贴',
|
|
1301
1313
|
batchCopyFiles: '复制所选文件',
|
|
1302
1314
|
batchCopyHint: '把选中的文件写入系统剪贴板,可在别的对话或资源管理器里粘贴',
|
|
1315
|
+
// v1.5.0 导出交付清单:CSV 进 Excel、JSON 给下一轮,落在 ~/.dsh/gallery-exports/
|
|
1316
|
+
batchExportManifest: '导出清单',
|
|
1317
|
+
batchExportHint: '把选中的这批导出成交付清单(CSV 给 Excel 看、JSON 给下一轮读),存到 ~/.dsh/gallery-exports/;同名不覆盖',
|
|
1318
|
+
exportOk: '已导出 {n} 条清单:{path}',
|
|
1319
|
+
exportEmpty: '这批没有可导出的文件(可能还没打分类)',
|
|
1320
|
+
exportFailed: '导出清单失败:{message}',
|
|
1303
1321
|
copyOk: '已复制 {n} 个文件到剪贴板;切到目标对话后右键「粘贴」或按 Ctrl+V',
|
|
1304
1322
|
copyOkInternal: '已复制 {n} 个文件(系统剪贴板不可用,仅插件内粘贴有效)',
|
|
1305
1323
|
copyFailed: '复制失败:{message}',
|
|
@@ -1716,6 +1734,17 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
1716
1734
|
hiddenCount: '{count} hidden',
|
|
1717
1735
|
hiddenClear: 'Restore all',
|
|
1718
1736
|
hiddenClearing: 'Restoring…',
|
|
1737
|
+
privacyLabel: 'Local records (privacy)',
|
|
1738
|
+
privacyHint: 'These files live under ~/.dsh/ in plain text and are never sent anywhere',
|
|
1739
|
+
privacyClearContext: 'Clear view history',
|
|
1740
|
+
privacyClearContextHint: 'Delete the "which images you opened" record; tags, masks and feedback stay',
|
|
1741
|
+
privacyClearAnnotations: 'Clear all annotations',
|
|
1742
|
+
privacyClearAnnotationsHint: 'Delete manual labels, frame records, feedback and marks; two clicks required, cannot be undone',
|
|
1743
|
+
privacyClearAnnotationsConfirm: 'Confirm clear? (click again)',
|
|
1744
|
+
privacyArmHint: 'Nothing has been deleted yet — click again to confirm',
|
|
1745
|
+
privacyClearing: 'Clearing…',
|
|
1746
|
+
privacyCleared: 'Cleared {n} local records',
|
|
1747
|
+
privacyClearFailed: 'Clear failed: {message}',
|
|
1719
1748
|
hiddenClearHint: 'Show all hidden files again (files are not deleted)',
|
|
1720
1749
|
hiddenCleared: 'All restored',
|
|
1721
1750
|
hiddenMore: '{count} more not shown',
|
|
@@ -1746,6 +1775,11 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
1746
1775
|
ctxCopyFileHint: 'Write this file to the system clipboard; paste it in another chat or Explorer',
|
|
1747
1776
|
batchCopyFiles: 'Copy selected files',
|
|
1748
1777
|
batchCopyHint: 'Write the selected files to the system clipboard; paste them in another chat or Explorer',
|
|
1778
|
+
batchExportManifest: 'Export list',
|
|
1779
|
+
batchExportHint: 'Export the selection as a delivery list (CSV for Excel, JSON for the next round) into ~/.dsh/gallery-exports/; existing files are never overwritten',
|
|
1780
|
+
exportOk: 'Exported {n} items: {path}',
|
|
1781
|
+
exportEmpty: 'Nothing exportable in this batch (maybe no category yet)',
|
|
1782
|
+
exportFailed: 'Export failed: {message}',
|
|
1749
1783
|
copyOk: 'Copied {n} file(s) to the clipboard; right-click "Paste" or press Ctrl+V in the target chat',
|
|
1750
1784
|
copyOkInternal: 'Copied {n} file(s) (system clipboard unavailable; in-plugin paste only)',
|
|
1751
1785
|
copyFailed: 'Copy failed: {message}',
|
|
@@ -9026,6 +9060,39 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
9026
9060
|
}, [info, t])
|
|
9027
9061
|
|
|
9028
9062
|
/** 全部恢复:清空隐藏列表,让被隐藏的条目重新出现在列表里。 */
|
|
9063
|
+
/**
|
|
9064
|
+
* v1.5.0 隐私:清空本地登记。
|
|
9065
|
+
*
|
|
9066
|
+
* 两段式:先 dryRun 拿条数与 digest,再带着同一个 digest 真删 ——
|
|
9067
|
+
* Host 侧会校验 digest,中途登记有变化就拒绝,避免「看着 3 条、删掉 30 条」。
|
|
9068
|
+
* 「清空全部标注」额外要求点两次(clearArm),因为那批数据不可再生。
|
|
9069
|
+
*/
|
|
9070
|
+
const [privacyBusy, setPrivacyBusy] = React.useState('')
|
|
9071
|
+
const [privacyNote, setPrivacyNote] = React.useState('')
|
|
9072
|
+
const [clearArm, setClearArm] = React.useState('')
|
|
9073
|
+
const clearLocal = React.useCallback(async (scope) => {
|
|
9074
|
+
if (privacyBusy !== '') return
|
|
9075
|
+
setPrivacyBusy(scope)
|
|
9076
|
+
setPrivacyNote('')
|
|
9077
|
+
setError(null)
|
|
9078
|
+
try {
|
|
9079
|
+
const dry = await callHost('clearState', { scope, dryRun: true })
|
|
9080
|
+
if (dry?.ok !== true) throw new Error(dry?.error?.message ?? t('errorTitle'))
|
|
9081
|
+
const counts = dry.counts ?? {}
|
|
9082
|
+
const total = Object.keys(counts).reduce((n, k) => n + (Number(counts[k]) || 0), 0)
|
|
9083
|
+
const done = await callHost('clearState', { scope, dryRun: false, digest: dry.digest })
|
|
9084
|
+
if (done?.ok !== true) throw new Error(done?.error?.message ?? t('errorTitle'))
|
|
9085
|
+
setPrivacyNote(format(t('privacyCleared'), { n: total }))
|
|
9086
|
+
setClearArm('')
|
|
9087
|
+
setTimeout(() => setPrivacyNote(''), 6000)
|
|
9088
|
+
if (typeof onSaved === 'function') onSaved()
|
|
9089
|
+
} catch (e) {
|
|
9090
|
+
setPrivacyNote(format(t('privacyClearFailed'), { message: String(e?.message ?? e) }))
|
|
9091
|
+
} finally {
|
|
9092
|
+
setPrivacyBusy('')
|
|
9093
|
+
}
|
|
9094
|
+
}, [privacyBusy, t, onSaved])
|
|
9095
|
+
|
|
9029
9096
|
const clearHidden = React.useCallback(async () => {
|
|
9030
9097
|
if (info === null || info.hiddenCount === 0) return
|
|
9031
9098
|
setClearing(true)
|
|
@@ -9164,6 +9231,47 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
9164
9231
|
error === null ? null : h('p', { className: 'dg-status dg-error', key: 'err' }, error),
|
|
9165
9232
|
saved ? h('p', { className: 'dg-status dg-ok', key: 'ok' }, t('savedImmediately')) : null,
|
|
9166
9233
|
|
|
9234
|
+
// ---- v1.5.0 本地登记(隐私):看清存了什么,也能自己清干净 ----
|
|
9235
|
+
h('div', { className: 'dg-field', key: 'privacy' }, [
|
|
9236
|
+
h('div', { className: 'dg-fieldHead', key: 'head' }, [
|
|
9237
|
+
h('span', { className: 'dg-fieldLabel', key: 'l' }, t('privacyLabel')),
|
|
9238
|
+
h('span', { className: 'dg-fieldHint', key: 'h' }, t('privacyHint')),
|
|
9239
|
+
]),
|
|
9240
|
+
h('div', { className: 'dg-settingsActions', key: 'ops' }, [
|
|
9241
|
+
h('button', {
|
|
9242
|
+
type: 'button', className: 'dg-btn dg-btnSmall', key: 'clearCtx',
|
|
9243
|
+
'data-gallery-clear-context': true,
|
|
9244
|
+
disabled: privacyBusy !== '',
|
|
9245
|
+
title: t('privacyClearContextHint'),
|
|
9246
|
+
onClick: () => { void clearLocal('context') },
|
|
9247
|
+
}, privacyBusy === 'context' ? t('privacyClearing') : t('privacyClearContext')),
|
|
9248
|
+
h('button', {
|
|
9249
|
+
type: 'button',
|
|
9250
|
+
className: `dg-btn dg-btnSmall${clearArm === 'annotations' ? ' dg-dangerBtn' : ''}`,
|
|
9251
|
+
key: 'clearAnn',
|
|
9252
|
+
'data-gallery-clear-annotations': true,
|
|
9253
|
+
'data-armed': clearArm === 'annotations' ? '1' : '0',
|
|
9254
|
+
disabled: privacyBusy !== '',
|
|
9255
|
+
title: t('privacyClearAnnotationsHint'),
|
|
9256
|
+
onClick: () => {
|
|
9257
|
+
if (clearArm !== 'annotations') {
|
|
9258
|
+
setClearArm('annotations')
|
|
9259
|
+
setPrivacyNote(t('privacyArmHint'))
|
|
9260
|
+
return
|
|
9261
|
+
}
|
|
9262
|
+
void clearLocal('annotations')
|
|
9263
|
+
},
|
|
9264
|
+
}, privacyBusy === 'annotations'
|
|
9265
|
+
? t('privacyClearing')
|
|
9266
|
+
: (clearArm === 'annotations'
|
|
9267
|
+
? t('privacyClearAnnotationsConfirm')
|
|
9268
|
+
: t('privacyClearAnnotations'))),
|
|
9269
|
+
]),
|
|
9270
|
+
privacyNote === ''
|
|
9271
|
+
? null
|
|
9272
|
+
: h('p', { className: 'dg-status', key: 'note' }, privacyNote),
|
|
9273
|
+
]),
|
|
9274
|
+
|
|
9167
9275
|
h('div', { className: 'dg-settingsActions', key: 'actions' }, [
|
|
9168
9276
|
h('button', {
|
|
9169
9277
|
type: 'button', className: 'dg-btn', key: 'reset',
|
|
@@ -10699,6 +10807,35 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
10699
10807
|
}
|
|
10700
10808
|
}, [callHost, t, showPasteNotice])
|
|
10701
10809
|
|
|
10810
|
+
/**
|
|
10811
|
+
* 导出交付清单(v1.5.0)。
|
|
10812
|
+
*
|
|
10813
|
+
* 与 Agent 的第 5 个工具 `gallery_manifest` 走 Host 侧同一个 buildManifest:
|
|
10814
|
+
* 您导出的 CSV 和模型读到的清单,条数、分类计数、来源时间码必须完全一致。
|
|
10815
|
+
* 落盘位置在 DSH_HOME/gallery-exports/,**不在扫描根内** ——
|
|
10816
|
+
* 清单是 .csv/.json,而扫描会认这两类扩展名,写进产出目录就会变成一堆新「资产」。
|
|
10817
|
+
*/
|
|
10818
|
+
const doExportManifest = React.useCallback(async (relPaths) => {
|
|
10819
|
+
const paths = [...new Set((Array.isArray(relPaths) ? relPaths : [])
|
|
10820
|
+
.map((p) => String(p ?? '')).filter((p) => p !== ''))]
|
|
10821
|
+
if (paths.length === 0) return false
|
|
10822
|
+
try {
|
|
10823
|
+
const payload = await callHost('exportManifest', {
|
|
10824
|
+
relPaths: paths,
|
|
10825
|
+
format: 'both',
|
|
10826
|
+
includeNotes: true,
|
|
10827
|
+
})
|
|
10828
|
+
if (payload?.ok !== true) throw new Error(payload?.error?.message ?? 'exportManifest failed')
|
|
10829
|
+
const files = Array.isArray(payload.files) ? payload.files : []
|
|
10830
|
+
const head = files.length > 0 ? String(files[0].path ?? '') : String(payload.dir ?? '')
|
|
10831
|
+
showPasteNotice('ok', format(t('exportOk'), { n: payload.count ?? paths.length, path: head }))
|
|
10832
|
+
return true
|
|
10833
|
+
} catch (error) {
|
|
10834
|
+
showPasteNotice('fail', format(t('exportFailed'), { message: String(error?.message ?? error) }))
|
|
10835
|
+
return false
|
|
10836
|
+
}
|
|
10837
|
+
}, [callHost, t, showPasteNotice])
|
|
10838
|
+
|
|
10702
10839
|
React.useEffect(() => {
|
|
10703
10840
|
let alive = true
|
|
10704
10841
|
const controller = new AbortController()
|
|
@@ -11352,6 +11489,13 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
11352
11489
|
title: t('batchCopyHint'),
|
|
11353
11490
|
onClick: () => { void doCopyAssets([...selected]) },
|
|
11354
11491
|
}, `⧉ ${t('batchCopyFiles')} (${selectedCount})`),
|
|
11492
|
+
// v1.5.0 导出交付清单:CSV 进 Excel 做物料表、JSON 给下一轮/脚本读
|
|
11493
|
+
h('button', {
|
|
11494
|
+
type: 'button', className: 'dg-btn dg-btnSmall', key: 'exportManifest',
|
|
11495
|
+
'data-gallery-batch-export': true,
|
|
11496
|
+
title: t('batchExportHint'),
|
|
11497
|
+
onClick: () => { void doExportManifest([...selected]) },
|
|
11498
|
+
}, `\u{1F4CB} ${t('batchExportManifest')} (${selectedCount})`),
|
|
11355
11499
|
// 2026-11-25 批量删除:一次删掉全部选中,二次确认后不可恢复
|
|
11356
11500
|
h('button', {
|
|
11357
11501
|
type: 'button', className: 'dg-btn dg-btnSmall dg-dangerBtn', key: 'deleteSel',
|
package/host/constants.js
CHANGED
|
@@ -84,6 +84,12 @@ export const DEFAULTS = {
|
|
|
84
84
|
windowHours: 24 * 365,
|
|
85
85
|
maxItems: 60,
|
|
86
86
|
maxDepth: 3,
|
|
87
|
+
/**
|
|
88
|
+
* v1.5.0 隐私:浏览记录(dsh-gallery-context.json)保留多少小时。
|
|
89
|
+
* **0 = 永不自动清理**(默认):这是一份「你最近看了哪几张」的记录,
|
|
90
|
+
* 自动删掉会让助手答不上「我刚看的那张是什么」,所以默认不碰,由用户自己决定。
|
|
91
|
+
*/
|
|
92
|
+
contextTtlHours: 0,
|
|
87
93
|
extensions: ['.png', '.jpg', '.jpeg', '.webp'],
|
|
88
94
|
/**
|
|
89
95
|
* 音视频画廊(v0.10.1):视频 + 音频,独立一个 kind。
|
package/host/context.js
CHANGED
|
@@ -203,6 +203,39 @@ export async function writePanel(settingsFile, panel) {
|
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
/** 读完整状态(面板 + 最近看过的列表)。文件坏了返回空状态,绝不抛错。 */
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* 启动时按 TTL 清一次浏览记录(v1.5.0,隐私开关)。
|
|
209
|
+
*
|
|
210
|
+
* 三条规矩,少一条就会误删:
|
|
211
|
+
* 1. **只在这里删,读路径永远纯读**(与反馈 TTL 同一条铁律);
|
|
212
|
+
* 2. 没有时间戳的条目**一律保留** —— 宁可少删,不可错删;
|
|
213
|
+
* 3. TTL <= 0 直接返回,不动文件。
|
|
214
|
+
*/
|
|
215
|
+
export async function sweepContext(settingsFile, ttlHours) {
|
|
216
|
+
const hours = Number(ttlHours)
|
|
217
|
+
if (!Number.isFinite(hours) || hours <= 0) return { removed: 0, kept: 0 }
|
|
218
|
+
const file = contextFilePath(settingsFile)
|
|
219
|
+
let doc
|
|
220
|
+
try {
|
|
221
|
+
doc = JSON.parse(await fsp.readFile(file, 'utf8'))
|
|
222
|
+
} catch {
|
|
223
|
+
return { removed: 0, kept: 0 }
|
|
224
|
+
}
|
|
225
|
+
const recent = Array.isArray(doc?.recent) ? doc.recent : []
|
|
226
|
+
if (recent.length === 0) return { removed: 0, kept: 0 }
|
|
227
|
+
const cutoff = Date.now() - hours * 3600 * 1000
|
|
228
|
+
const kept = recent.filter((it) => {
|
|
229
|
+
const t = Number(it?.updatedAt ?? it?.viewedAt ?? 0)
|
|
230
|
+
if (!(t > 0)) return true
|
|
231
|
+
return t >= cutoff
|
|
232
|
+
})
|
|
233
|
+
const removed = recent.length - kept.length
|
|
234
|
+
if (removed === 0) return { removed: 0, kept: kept.length }
|
|
235
|
+
await writeFileAtomic(file, JSON.stringify({ ...doc, recent: kept, updatedAt: Date.now() }, null, 2))
|
|
236
|
+
return { removed, kept: kept.length }
|
|
237
|
+
}
|
|
238
|
+
|
|
206
239
|
export async function readState(settingsFile) {
|
|
207
240
|
return readStateFile(contextFilePath(settingsFile))
|
|
208
241
|
}
|