dsh-gallery 1.4.1 → 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/client.js CHANGED
@@ -907,6 +907,12 @@ async function encodeMaskPngBytes(imageData, width, height) {
907
907
  scopeSession: '当前对话',
908
908
  scopeGlobalHint: '按对话分组的全部产出',
909
909
  scopeSessionHint: '仅本对话产出过的文件',
910
+ inheritedBadge: '继承',
911
+ inheritedBadgeHint: '继承自主线的产出;除删除会同步影响源对话外,用法与本对话产出相同',
912
+ inheritedDeleteWarn: '此文件继承自主线,删除将从源对话资产同步删除',
913
+ sharedBadge: '共享',
914
+ sharedBadgeHint: '此文件被分叉对话带走;除删除会同步影响共享对话外,用法与本对话产出相同',
915
+ sharedDeleteWarn: '此文件为共享资产,删除将同步删除共享对话文件',
910
916
  scopeUnknown: '未记录本对话产出',
911
917
  scopeNotFound: '找不到本对话的会话记录',
912
918
  scopeLogEmpty: '本对话的会话记录为空',
@@ -1109,10 +1115,31 @@ async function encodeMaskPngBytes(imageData, width, height) {
1109
1115
  // 右键菜单
1110
1116
  ctxHint: '右键更多操作',
1111
1117
  ctxHide: '隐藏(不再列出)',
1118
+ ctxHideSelected: '隐藏选中的 {n} 个文件',
1119
+ ctxHideFailed: '隐藏失败',
1120
+ batchHideSelected: '隐藏所选',
1121
+ batchHideHint: '把选中的全部文件从列表隐藏(不动文件,可在设置里恢复)',
1112
1122
  ctxUnhide: '取消隐藏',
1113
1123
  ctxReveal: '打开所在文件夹',
1114
1124
  ctxCopy: '写进输入框',
1115
1125
  ctxDelete: '删除文件',
1126
+ ctxDeleteSelected: '删除选中的 {n} 个文件',
1127
+ ctxDeleteManyTitle: '确认删除 {n} 个文件?此操作不可恢复',
1128
+ ctxDeleteManySummary: '共 {n} 个文件',
1129
+ ctxDeletePartial: '已删除 {n} 个,{fail} 个失败',
1130
+ batchDeleteSelected: '删除所选',
1131
+ batchDeleteHint: '删除选中的全部文件(会二次确认,不可恢复)',
1132
+ // 2026-11-25 按标签圈选:把某一类下的文件一次选中,再交给批量动作
1133
+ legendPick: '选',
1134
+ legendPickHint: '把「{label}」下的文件全部选中(已全选时再点一次取消)',
1135
+ legendPickEmpty: '这一类下还没有文件',
1136
+ legendPickTruncated: '数量太多,这次先选中了前 {n} 个',
1137
+ batchSelAll: '全选当前',
1138
+ batchSelAllHint: '选中当前列表里的全部文件',
1139
+ batchInvert: '反选',
1140
+ batchInvertHint: '选中当前列表里还没选中的文件',
1141
+ ctxCopyFileSelected: '复制选中的 {n} 个文件',
1142
+ labelEditSelected: '改这 {n} 张的标签',
1116
1143
  ctxDeleteConfirm: '确认删除?此操作不可恢复',
1117
1144
  ctxDeleteYes: '确认删除',
1118
1145
  ctxDeleteNo: '取消',
@@ -1243,6 +1270,18 @@ async function encodeMaskPngBytes(imageData, width, height) {
1243
1270
  hiddenCount: '已隐藏 {count} 个',
1244
1271
  hiddenClear: '全部恢复',
1245
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}',
1246
1285
  hiddenClearHint: '让所有被隐藏的文件重新出现在列表里(不会删除文件)',
1247
1286
  hiddenCleared: '已全部恢复',
1248
1287
  hiddenMore: '还有 {count} 个未显示',
@@ -1273,6 +1312,12 @@ async function encodeMaskPngBytes(imageData, width, height) {
1273
1312
  ctxCopyFileHint: '把该文件写入系统剪贴板,可在别的对话或资源管理器里粘贴',
1274
1313
  batchCopyFiles: '复制所选文件',
1275
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}',
1276
1321
  copyOk: '已复制 {n} 个文件到剪贴板;切到目标对话后右键「粘贴」或按 Ctrl+V',
1277
1322
  copyOkInternal: '已复制 {n} 个文件(系统剪贴板不可用,仅插件内粘贴有效)',
1278
1323
  copyFailed: '复制失败:{message}',
@@ -1332,6 +1377,12 @@ async function encodeMaskPngBytes(imageData, width, height) {
1332
1377
  scopeSession: 'This chat',
1333
1378
  scopeGlobalHint: 'All outputs, grouped by conversation',
1334
1379
  scopeSessionHint: 'Only files produced in this chat',
1380
+ inheritedBadge: 'Inherited',
1381
+ inheritedBadgeHint: 'Inherited from the parent chat; works like this chat’s own output, except deleting it also affects the source chat',
1382
+ inheritedDeleteWarn: 'Inherited from the parent chat — deleting it will also remove it from the source chat’s assets',
1383
+ sharedBadge: 'Shared',
1384
+ sharedBadgeHint: 'Shared with a forked chat; works like this chat’s own output, except deleting it also affects that chat',
1385
+ sharedDeleteWarn: 'Shared asset — deleting it will also remove the file from the shared chat',
1335
1386
  scopeUnknown: 'No outputs recorded for this chat',
1336
1387
  scopeNotFound: 'Cannot find this chat’s session log',
1337
1388
  scopeLogEmpty: 'This chat’s session log is empty',
@@ -1533,10 +1584,30 @@ async function encodeMaskPngBytes(imageData, width, height) {
1533
1584
  zoomResetHint: 'Reset zoom (or press 0)',
1534
1585
  ctxHint: 'Right-click for more',
1535
1586
  ctxHide: 'Hide (stop listing)',
1587
+ ctxHideSelected: 'Hide {n} selected files',
1588
+ ctxHideFailed: 'Hide failed',
1589
+ batchHideSelected: 'Hide selected',
1590
+ batchHideHint: 'Hide every selected file from the list (files untouched; restore in settings)',
1536
1591
  ctxUnhide: 'Unhide',
1537
1592
  ctxReveal: 'Open containing folder',
1538
1593
  ctxCopy: 'Write into chat input',
1539
1594
  ctxDelete: 'Delete file',
1595
+ ctxDeleteSelected: 'Delete {n} selected files',
1596
+ ctxDeleteManyTitle: 'Delete {n} files permanently? This cannot be undone',
1597
+ ctxDeleteManySummary: '{n} files',
1598
+ ctxDeletePartial: 'Deleted {n}, {fail} failed',
1599
+ batchDeleteSelected: 'Delete selected',
1600
+ batchDeleteHint: 'Delete every selected file (asks for confirmation, cannot be undone)',
1601
+ legendPick: 'Pick',
1602
+ legendPickHint: 'Select every file labeled "{label}" (click again to clear)',
1603
+ legendPickEmpty: 'Nothing in this category yet',
1604
+ legendPickTruncated: 'Too many; only the first {n} were selected',
1605
+ batchSelAll: 'Select visible',
1606
+ batchSelAllHint: 'Select every file in the current list',
1607
+ batchInvert: 'Invert',
1608
+ batchInvertHint: 'Select the files in the current list that are not selected yet',
1609
+ ctxCopyFileSelected: 'Copy {n} selected files',
1610
+ labelEditSelected: 'Re-label these {n} files',
1540
1611
  ctxDeleteConfirm: 'Delete permanently? This cannot be undone',
1541
1612
  ctxDeleteYes: 'Delete',
1542
1613
  ctxDeleteNo: 'Cancel',
@@ -1663,6 +1734,17 @@ async function encodeMaskPngBytes(imageData, width, height) {
1663
1734
  hiddenCount: '{count} hidden',
1664
1735
  hiddenClear: 'Restore all',
1665
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}',
1666
1748
  hiddenClearHint: 'Show all hidden files again (files are not deleted)',
1667
1749
  hiddenCleared: 'All restored',
1668
1750
  hiddenMore: '{count} more not shown',
@@ -1693,6 +1775,11 @@ async function encodeMaskPngBytes(imageData, width, height) {
1693
1775
  ctxCopyFileHint: 'Write this file to the system clipboard; paste it in another chat or Explorer',
1694
1776
  batchCopyFiles: 'Copy selected files',
1695
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}',
1696
1783
  copyOk: 'Copied {n} file(s) to the clipboard; right-click "Paste" or press Ctrl+V in the target chat',
1697
1784
  copyOkInternal: 'Copied {n} file(s) (system clipboard unavailable; in-plugin paste only)',
1698
1785
  copyFailed: 'Copy failed: {message}',
@@ -2684,6 +2771,24 @@ async function encodeMaskPngBytes(imageData, width, height) {
2684
2771
  font-size: 12px;
2685
2772
  }
2686
2773
 
2774
+ /* 2026-11-24:分叉「继承」与主线「共享」是同一批文件的两侧视角——同款虚线框,只标来源、不降交互 */
2775
+ .dg-cardWrap.dg-inheritedCard,
2776
+ .dg-cardWrap.dg-sharedCard { outline: 1px dashed #9b8cf0; outline-offset: 1px; }
2777
+ .dg-inheritedBadge,
2778
+ .dg-sharedBadge {
2779
+ position: absolute;
2780
+ top: 6px; left: 50%; transform: translateX(-50%);
2781
+ z-index: 7;
2782
+ padding: 1px 8px;
2783
+ border-radius: 10px;
2784
+ font-size: 10px; font-weight: 600; line-height: 1.6;
2785
+ color: #5b4bc4;
2786
+ background: rgba(255, 255, 255, .94);
2787
+ border: 1px solid #b9aef0;
2788
+ pointer-events: none;
2789
+ white-space: nowrap;
2790
+ }
2791
+
2687
2792
  /* ===== 分页条:常驻网格下方 ===== */
2688
2793
  .dg-pager {
2689
2794
  flex: 0 0 auto;
@@ -2820,6 +2925,24 @@ async function encodeMaskPngBytes(imageData, width, height) {
2820
2925
  background: var(--dsw-alias-bg-layer-2);
2821
2926
  border-radius: 6px;
2822
2927
  }
2928
+ .dg-confirmList {
2929
+ max-height: 168px; overflow-y: auto;
2930
+ display: flex; flex-direction: column; gap: 2px;
2931
+ padding: 6px 9px;
2932
+ background: var(--dsw-alias-bg-layer-2);
2933
+ border-radius: 6px;
2934
+ font-size: 11px; line-height: 1.6;
2935
+ color: var(--dsw-alias-label-secondary);
2936
+ }
2937
+ .dg-confirmListItem { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
2938
+ .dg-confirmWarn {
2939
+ font-size: 11px; line-height: 1.5;
2940
+ color: #b26a1d;
2941
+ background: rgba(212, 137, 60, .1);
2942
+ border: 1px solid rgba(212, 137, 60, .35);
2943
+ border-radius: 6px;
2944
+ padding: 6px 9px;
2945
+ }
2823
2946
  .dg-confirmActions { display: flex; justify-content: flex-end; gap: 8px; }
2824
2947
  .dg-dangerBtn {
2825
2948
  color: #fff;
@@ -3455,6 +3578,16 @@ async function encodeMaskPngBytes(imageData, width, height) {
3455
3578
  .dg-legendToggle.dg-legendOff { opacity: 0.42; }
3456
3579
  .dg-legendToggle.dg-legendOff .dg-legendSwatch { filter: grayscale(1); }
3457
3580
  .dg-legendCount { font-size: 11px; color: #a9b1bd; margin-left: 2px; }
3581
+ .dg-legendCell { display: inline-flex; align-items: center; gap: 2px; }
3582
+ .dg-legendPick {
3583
+ appearance: none; border: 1px solid transparent; background: transparent;
3584
+ color: #8f97a3; font: inherit; font-size: 11px; line-height: 16px;
3585
+ padding: 0 5px; border-radius: 5px; cursor: pointer; opacity: 0.5;
3586
+ }
3587
+ .dg-legendCell:hover .dg-legendPick { opacity: 1; }
3588
+ .dg-legendPick:hover { border-color: rgba(120, 160, 255, 0.45); background: rgba(74, 124, 255, 0.16); color: #cfe0ff; }
3589
+ .dg-legendPick:disabled { cursor: default; }
3590
+ .dg-legendPick[data-on="1"] { opacity: 1; color: #a9c2ff; border-color: rgba(74, 124, 255, 0.5); background: rgba(74, 124, 255, 0.2); }
3458
3591
  .dg-legendSwatchPending { opacity: 0.55; border-style: dashed !important; }
3459
3592
 
3460
3593
  /* 卡片包装层 + 确认角标 + 多选框 */
@@ -5268,7 +5401,7 @@ function serializeFeedback(feedback) {
5268
5401
  ? entry('original', t('ctxOpenOriginal'), '🔍', () => actions.onOpenOriginal())
5269
5402
  : null,
5270
5403
  actions.onHide !== undefined
5271
- ? entry('hide', t('ctxHide'), '🚫', () => actions.onHide())
5404
+ ? entry('hide', actions.hideLabel ?? t('ctxHide'), '🚫', () => actions.onHide())
5272
5405
  : null,
5273
5406
  actions.onReveal !== undefined
5274
5407
  ? entry('reveal', t('ctxReveal'), '📂', () => actions.onReveal())
@@ -5278,17 +5411,17 @@ function serializeFeedback(feedback) {
5278
5411
  : null,
5279
5412
  // v0.16.0:复制**文件本体**到系统剪贴板(与上面的「复制路径」文本区分)
5280
5413
  actions.onCopyFile !== undefined
5281
- ? entry('copyFile', t('ctxCopyFile'), '📄', () => actions.onCopyFile())
5414
+ ? entry('copyFile', actions.copyFileLabel ?? t('ctxCopyFile'), '📄', () => actions.onCopyFile())
5282
5415
  : null,
5283
5416
  actions.onDelete !== undefined
5284
- ? entry('delete', t('ctxDelete'), '🗑', () => actions.onDelete(), true)
5417
+ ? entry('delete', actions.deleteLabel ?? t('ctxDelete'), '🗑', () => actions.onDelete(), true)
5285
5418
  : null,
5286
5419
  // ---- v0.14.2 手动标签:表态层已下线,只留「改标签 / 恢复自动」两个入口 ----
5287
5420
  actions.onEditLabel !== undefined
5288
5421
  ? h('div', { className: 'dg-ctxDivider', key: 'labelDivider' }, t('labelEdit'))
5289
5422
  : null,
5290
5423
  actions.onEditLabel !== undefined
5291
- ? entry('label-edit', t('labelEdit'), '✎', () => actions.onEditLabel())
5424
+ ? entry('label-edit', actions.editLabelLabel ?? t('labelEdit'), '✎', () => actions.onEditLabel())
5292
5425
  : null,
5293
5426
  actions.onResetLabel !== undefined
5294
5427
  ? entry('label-reset', t('labelCtxReset'), '↺', () => actions.onResetLabel())
@@ -5396,7 +5529,7 @@ function serializeFeedback(feedback) {
5396
5529
  }
5397
5530
 
5398
5531
  /** 删除确认弹窗:删除不可逆,必须二次确认。 */
5399
- function ConfirmDialog({ t, name, busy, onCancel, onConfirm }) {
5532
+ function ConfirmDialog({ t, name, title, files, busy, warn, onCancel, onConfirm }) {
5400
5533
  React.useEffect(() => {
5401
5534
  const onKey = (event) => {
5402
5535
  if (busy) return
@@ -5416,8 +5549,16 @@ function serializeFeedback(feedback) {
5416
5549
  'aria-modal': true,
5417
5550
  'data-gallery-confirm-delete': name,
5418
5551
  }, [
5419
- h('div', { className: 'dg-confirmTitle', key: 'title' }, t('ctxDeleteConfirm')),
5552
+ h('div', { className: 'dg-confirmTitle', key: 'title' }, title ?? t('ctxDeleteConfirm')),
5420
5553
  h('div', { className: 'dg-confirmName', key: 'name' }, name),
5554
+ // 批量删除时列出文件名,避免「删的到底是哪些」说不清
5555
+ Array.isArray(files) && files.length > 0
5556
+ ? h('div', { className: 'dg-confirmList', key: 'files' },
5557
+ files.slice(0, 40).map((f, i) => h('div', { className: 'dg-confirmListItem', key: `f${i}` }, String(f))))
5558
+ : null,
5559
+ warn
5560
+ ? h('div', { className: 'dg-confirmWarn', key: 'warn' }, warn)
5561
+ : null,
5421
5562
  h('div', { className: 'dg-confirmActions', key: 'actions' }, [
5422
5563
  h('button', {
5423
5564
  type: 'button', key: 'no', className: 'dg-btn',
@@ -6294,35 +6435,57 @@ ${absPath}
6294
6435
  let cancelled = false
6295
6436
  let started = false
6296
6437
  let sourceUrl = null
6438
+ let retryTimer = null
6297
6439
  const controller = new AbortController()
6298
6440
 
6299
- const run = () => {
6441
+ // 2026-11-24:图刚写出时取图可能超时 / 解码失败,旧版一次失败就永久
6442
+ // 显示「无法加载」,而点开大图时文件已完整。现在失败先重试两次;
6443
+ // 解码仍失败就退回原图 Blob 直接显示(大图路径同样用 <img>)。
6444
+ const run = (attempt = 0) => {
6300
6445
  if (started) return
6301
6446
  started = true
6302
6447
  setState({ status: 'pending' })
6303
6448
  limiter(async () => {
6304
6449
  const blob = await fetchRaw(item.relPath, controller.signal)
6305
- const thumb = await makeScaled(blob, THUMB_SIZE, true)
6306
- if (cancelled) {
6307
- if (thumb.url !== null) URL.revokeObjectURL(thumb.url)
6308
- return
6450
+ if (cancelled) return
6451
+ try {
6452
+ const thumb = await makeScaled(blob, THUMB_SIZE, true)
6453
+ if (cancelled) {
6454
+ if (thumb.url !== null) URL.revokeObjectURL(thumb.url)
6455
+ return
6456
+ }
6457
+ sourceUrl = thumb.url
6458
+ setState({ status: 'ready', url: thumb.url })
6459
+ } catch (decodeError) {
6460
+ // 部分 WebView 对刚写入的 RGBA 图 createImageBitmap 会失败;
6461
+ // 原图 Blob 交给 <img> 是查看器已验证可用的路径,照此兜底。
6462
+ const url = URL.createObjectURL(blob)
6463
+ if (cancelled) { URL.revokeObjectURL(url); return }
6464
+ sourceUrl = url
6465
+ setState({ status: 'ready', url, thumbFallback: true })
6309
6466
  }
6310
- sourceUrl = thumb.url
6311
- setState({ status: 'ready', url: thumb.url })
6312
6467
  }).catch((error) => {
6313
6468
  if (cancelled || controller.signal.aborted) return
6469
+ if (attempt < 2) {
6470
+ started = false
6471
+ retryTimer = setTimeout(() => run(attempt + 1), 1500 * (attempt + 1))
6472
+ return
6473
+ }
6314
6474
  setState({ status: 'failed', message: String(error?.message ?? error) })
6315
6475
  })
6316
6476
  }
6317
6477
 
6478
+ const cleanup = () => {
6479
+ cancelled = true
6480
+ if (retryTimer !== null) clearTimeout(retryTimer)
6481
+ controller.abort()
6482
+ if (sourceUrl !== null) URL.revokeObjectURL(sourceUrl)
6483
+ }
6484
+
6318
6485
  // 环境不支持 IntersectionObserver 时直接加载,保证可用性。
6319
6486
  if (typeof IntersectionObserver !== 'function') {
6320
6487
  run()
6321
- return () => {
6322
- cancelled = true
6323
- controller.abort()
6324
- if (sourceUrl !== null) URL.revokeObjectURL(sourceUrl)
6325
- }
6488
+ return cleanup
6326
6489
  }
6327
6490
 
6328
6491
  const observer = new IntersectionObserver((entries) => {
@@ -6335,10 +6498,8 @@ ${absPath}
6335
6498
  observer.observe(node)
6336
6499
 
6337
6500
  return () => {
6338
- cancelled = true
6339
6501
  observer.disconnect()
6340
- controller.abort()
6341
- if (sourceUrl !== null) URL.revokeObjectURL(sourceUrl)
6502
+ cleanup()
6342
6503
  }
6343
6504
  }, [node, item.relPath, limiter])
6344
6505
 
@@ -6398,6 +6559,7 @@ ${absPath}
6398
6559
  loading: 'lazy',
6399
6560
  width: THUMB_SIZE,
6400
6561
  height: THUMB_SIZE,
6562
+ 'data-gallery-thumb-raw': state.thumbFallback ? '1' : undefined,
6401
6563
  })
6402
6564
  : h('div', { className: 'dg-placeholder', 'data-gallery-placeholder': state.status },
6403
6565
  state.status === 'failed'
@@ -8898,6 +9060,39 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
8898
9060
  }, [info, t])
8899
9061
 
8900
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
+
8901
9096
  const clearHidden = React.useCallback(async () => {
8902
9097
  if (info === null || info.hiddenCount === 0) return
8903
9098
  setClearing(true)
@@ -9036,6 +9231,47 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
9036
9231
  error === null ? null : h('p', { className: 'dg-status dg-error', key: 'err' }, error),
9037
9232
  saved ? h('p', { className: 'dg-status dg-ok', key: 'ok' }, t('savedImmediately')) : null,
9038
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
+
9039
9275
  h('div', { className: 'dg-settingsActions', key: 'actions' }, [
9040
9276
  h('button', {
9041
9277
  type: 'button', className: 'dg-btn', key: 'reset',
@@ -10215,11 +10451,20 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
10215
10451
  })
10216
10452
  }, [])
10217
10453
 
10218
- /** 隐藏当前右键的条目(只从列表移除,不动文件)。 */
10219
- const doHide = React.useCallback(async (item) => {
10454
+ /**
10455
+ * 隐藏条目(只从列表移除,不动文件)。
10456
+ * 2026-11-25:接受单个条目或 relPath 数组;批量隐藏一次写完。
10457
+ */
10458
+ const doHide = React.useCallback(async (target) => {
10459
+ const rels = (Array.isArray(target) ? target : [target?.relPath ?? ''])
10460
+ .map((rp) => String(rp ?? ''))
10461
+ .filter((rp) => rp !== '')
10462
+ if (rels.length === 0) return
10220
10463
  try {
10221
- const payload = await callHost('hide', { path: item.relPath })
10464
+ const payload = await callHost('hide', { paths: rels })
10222
10465
  if (payload?.ok === false) throw new Error(payload?.error?.message ?? t('errorTitle'))
10466
+ setSelected(new Set())
10467
+ setBatchMode(false)
10223
10468
  await load(undefined, kind, scope, page).then((data) => setView({ status: 'ready', data })).catch(() => {})
10224
10469
  } catch (error) {
10225
10470
  console.error('dsh-gallery: 隐藏失败', error)
@@ -10236,22 +10481,43 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
10236
10481
  }
10237
10482
  }, [t])
10238
10483
 
10239
- /** 执行删除(需二次确认)。 */
10484
+ /** 粘贴/操作提示(成功/失败),3 秒自动消失。 */
10485
+ const [pasteNotice, setPasteNotice] = React.useState(null)
10486
+ const showPasteNotice = React.useCallback((kindOf, text) => {
10487
+ setPasteNotice({ kind: kindOf, text })
10488
+ }, [])
10489
+
10490
+ /**
10491
+ * 执行删除(需二次确认)。
10492
+ * 2026-11-25:批量选中时一次删完全部 —— Host 的 delete 接受 paths 数组,
10493
+ * 单条只是长度 1 的特例,两侧不再有两套逻辑。
10494
+ */
10240
10495
  const doDelete = React.useCallback(async () => {
10241
10496
  const target = deleteTarget
10242
10497
  if (target === null || target.busy === true) return
10498
+ const items = Array.isArray(target.items) ? target.items : []
10499
+ const rels = items.map((it) => String(it?.relPath ?? '')).filter((rp) => rp !== '')
10500
+ if (rels.length === 0) { setDeleteTarget(null); return }
10243
10501
  setDeleteTarget({ ...target, busy: true })
10244
10502
  try {
10245
- const payload = await callHost('delete', { path: target.item.relPath, confirm: true })
10503
+ const payload = await callHost('delete', { paths: rels, confirm: true })
10246
10504
  if (payload?.ok === false) throw new Error(payload?.error?.message ?? t('errorTitle'))
10505
+ const failed = (Array.isArray(payload?.failed) ? payload.failed.length : 0)
10506
+ + (Array.isArray(payload?.notFound) ? payload.notFound.length : 0)
10507
+ if (failed > 0) {
10508
+ showPasteNotice('fail', format(t('ctxDeletePartial'), { n: rels.length - failed, fail: failed }))
10509
+ }
10247
10510
  setDeleteTarget(null)
10511
+ setSelected(new Set())
10512
+ setBatchMode(false)
10248
10513
  kickChanges()
10249
10514
  await load(undefined, kind, scope, page).then((data) => setView({ status: 'ready', data })).catch(() => {})
10250
10515
  } catch (error) {
10251
10516
  console.error('dsh-gallery: 删除失败', error)
10252
10517
  setDeleteTarget(null)
10518
+ showPasteNotice('fail', t('ctxDeleteFailed'))
10253
10519
  }
10254
- }, [deleteTarget, load, kind, scope, page, t])
10520
+ }, [deleteTarget, load, kind, scope, page, t, showPasteNotice])
10255
10521
 
10256
10522
  const refresh = React.useCallback(async () => {
10257
10523
  setRefreshing(true)
@@ -10266,18 +10532,12 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
10266
10532
  }, [load, kind, scope, page])
10267
10533
 
10268
10534
  // ---- v0.16.0 粘贴:剪贴板图片/文件作为「素材」落当前对话 ----
10269
- /** 粘贴提示(成功/失败),3 秒自动消失。 */
10270
- const [pasteNotice, setPasteNotice] = React.useState(null)
10271
10535
  React.useEffect(() => {
10272
10536
  if (pasteNotice === null) return undefined
10273
10537
  const timer = setTimeout(() => setPasteNotice(null), 3000)
10274
10538
  return () => clearTimeout(timer)
10275
10539
  }, [pasteNotice])
10276
10540
 
10277
- const showPasteNotice = React.useCallback((kindOf, text) => {
10278
- setPasteNotice({ kind: kindOf, text })
10279
- }, [])
10280
-
10281
10541
  /**
10282
10542
  * v0.16.2 粘贴落点解析:hover 的对话组优先,否则 slot 的当前对话。
10283
10543
  *
@@ -10406,21 +10666,33 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
10406
10666
  const parsed = extractFromPasteEvent(clipboardData)
10407
10667
  if (parsed.images.length > 0 || parsed.files.length > 0) {
10408
10668
  if (typeof event?.preventDefault === 'function') event.preventDefault()
10669
+ // 🔴 2026-11-25:只解析到一张位图时,剪贴板可能其实是「多个文件的 FileDropList」,
10670
+ // Chromium 的 paste 事件只给其中一张。先问 Host 要真实文件列表,拿到多个就按文件走。
10671
+ if (parsed.files.length === 0 && parsed.images.length === 1) {
10672
+ const got = await pasteFromClipboard()
10673
+ if (got) return true
10674
+ }
10409
10675
  await ingestPasted(parsed)
10410
10676
  return true
10411
10677
  }
10412
10678
  return pasteFromClipboard()
10413
10679
  }, [ingestPasted, pasteFromClipboard])
10414
10680
 
10415
- /** 右键菜单「粘贴」:先图片(Clipboard API),再文件(含音视频,系统剪贴板)。 */
10681
+ /**
10682
+ * 右键菜单「粘贴」。
10683
+ * 🔴 2026-11-25:**文件列表优先**。批量复制多张图时系统剪贴板是 CF_HDROP,
10684
+ * 而 Clipboard API 的 read() 往往只回一张位图 —— 先走图片通道就会「只粘最后一张」。
10685
+ * 截图(纯位图、没有文件列表)仍会落到图片通道。
10686
+ */
10416
10687
  const doPaste = React.useCallback(async () => {
10688
+ const got = await pasteFromClipboard()
10689
+ if (got) return
10417
10690
  const images = await readClipboardImages()
10418
10691
  if (images.length > 0) {
10419
10692
  await ingestPasted({ images, files: [] })
10420
10693
  return
10421
10694
  }
10422
- const got = await pasteFromClipboard()
10423
- if (!got) showPasteNotice('fail', t('pasteEmpty'))
10695
+ showPasteNotice('fail', t('pasteEmpty'))
10424
10696
  }, [ingestPasted, pasteFromClipboard, showPasteNotice, t])
10425
10697
 
10426
10698
  /** v0.16.0 图片裁剪:把裁剪出的 PNG base64 交给 Host 落盘(源图同目录,标素材)。 */
@@ -10535,6 +10807,35 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
10535
10807
  }
10536
10808
  }, [callHost, t, showPasteNotice])
10537
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
+
10538
10839
  React.useEffect(() => {
10539
10840
  let alive = true
10540
10841
  const controller = new AbortController()
@@ -10957,21 +11258,139 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
10957
11258
  * · 「未归类」只在确实存在时出现
10958
11259
  * · 只记本次使用,不持久化
10959
11260
  */
11261
+ /**
11262
+ * 按标签一次圈定(2026-11-25)。
11263
+ *
11264
+ * 为什么必须问宿主要全量路径:列表接口在「当前对话」视图是分页的(每页 60),
11265
+ * 带 category 过滤也只过滤当前页 —— 只在已加载条目里挑,点了「选」却只选中
11266
+ * 60 张,等于又一次「批量没生效」。categoryPaths 是纯读接口,只回 relPath。
11267
+ * 旧宿主没有这个 op 时退回本地已加载条目:能用,只是可能不全。
11268
+ */
11269
+ // 圈选进行中:按钮显示「…」并禁用。
11270
+ // 没有这道门,手快点两下会被当成「选了又取消」(切换语义),看着像没生效。
11271
+ const pickBusyRef = React.useRef('')
11272
+ const [pickBusy, setPickBusy] = React.useState('')
11273
+ const selectByCategory = React.useCallback(async (cat) => {
11274
+ if (!['final', 'input', 'intermediate', 'unknown'].includes(cat)) return
11275
+ if (pickBusyRef.current !== '') return
11276
+ pickBusyRef.current = cat
11277
+ setPickBusy(cat)
11278
+ try {
11279
+ const poolFrom = () => {
11280
+ const out = []
11281
+ const seen = new Set()
11282
+ const push = (it) => {
11283
+ const rp = String(it?.relPath ?? '')
11284
+ if (rp === '' || seen.has(rp)) return
11285
+ const c = String(it?.category ?? '') === '' ? 'unknown' : String(it.category)
11286
+ if (c !== cat) return
11287
+ seen.add(rp)
11288
+ out.push(rp)
11289
+ }
11290
+ for (const it of (Array.isArray(items) ? items : [])) push(it)
11291
+ for (const it of (Array.isArray(visibleItems) ? visibleItems : [])) push(it)
11292
+ if (Array.isArray(data?.groups)) {
11293
+ for (const gr of data.groups) for (const f of (Array.isArray(gr?.files) ? gr.files : [])) push(f)
11294
+ }
11295
+ return out
11296
+ }
11297
+ let rels = []
11298
+ let truncated = false
11299
+ try {
11300
+ const payload = await callHost('categoryPaths', { kind, scope, sessionId, category: cat })
11301
+ if (payload?.ok === true && Array.isArray(payload.paths)) {
11302
+ rels = payload.paths.map((rp) => String(rp ?? '')).filter((rp) => rp !== '')
11303
+ truncated = payload.truncated === true
11304
+ }
11305
+ } catch (error) {
11306
+ console.warn('dsh-gallery: categoryPaths 不可用,退回已加载条目', error)
11307
+ }
11308
+ if (rels.length === 0) rels = poolFrom()
11309
+ if (rels.length === 0) {
11310
+ showPasteNotice('fail', t('legendPickEmpty'))
11311
+ return
11312
+ }
11313
+ setSelected((prev) => {
11314
+ const next = new Set(prev)
11315
+ const allIn = rels.every((rp) => next.has(rp))
11316
+ for (const rp of rels) {
11317
+ if (allIn) next.delete(rp)
11318
+ else next.add(rp)
11319
+ }
11320
+ return next
11321
+ })
11322
+ // 该分类当前是关着的就先打开:不然圈中了却看不见,看着像没生效
11323
+ if (categoryFilter[cat] === false) toggleCategory(cat)
11324
+ setBatchMode(true)
11325
+ if (truncated) showPasteNotice('ok', format(t('legendPickTruncated'), { n: rels.length }))
11326
+ } finally {
11327
+ pickBusyRef.current = ''
11328
+ setPickBusy('')
11329
+ }
11330
+ }, [kind, scope, sessionId, items, visibleItems, data, categoryFilter, toggleCategory, showPasteNotice, t])
11331
+
11332
+ /**
11333
+ * 哪些分类已经「整类选中」——只用来给图例上的「选」按钮点亮。
11334
+ * 跨页选中的项不一定在已加载列表里,那时计数偏小、按钮不点亮,但不影响操作。
11335
+ */
11336
+ const pickedCategories = React.useMemo(() => {
11337
+ const out = new Set()
11338
+ if (selected.size === 0) return out
11339
+ const c = { final: 0, input: 0, intermediate: 0, unknown: 0 }
11340
+ const seen = new Set()
11341
+ const push = (it) => {
11342
+ const rp = String(it?.relPath ?? '')
11343
+ if (rp === '' || seen.has(rp) || !selected.has(rp)) return
11344
+ seen.add(rp)
11345
+ const b = bucketOf(it)
11346
+ if (Object.prototype.hasOwnProperty.call(c, b)) c[b] += 1
11347
+ }
11348
+ for (const it of (Array.isArray(items) ? items : [])) push(it)
11349
+ for (const it of (Array.isArray(visibleItems) ? visibleItems : [])) push(it)
11350
+ if (Array.isArray(data?.groups)) {
11351
+ for (const gr of data.groups) for (const f of (Array.isArray(gr?.files) ? gr.files : [])) push(f)
11352
+ }
11353
+ for (const k of Object.keys(c)) {
11354
+ if (c[k] > 0 && c[k] >= Number(catCounts[k] ?? 0)) out.add(k)
11355
+ }
11356
+ return out
11357
+ }, [selected, items, visibleItems, data, bucketOf, catCounts])
11358
+
10960
11359
  const filterToggle = (key, label, swatchClass, count, alwaysShow) => {
10961
11360
  const on = categoryFilter[key] !== false
10962
11361
  if (!on && !alwaysShow && count === 0) return null
10963
- return h('button', {
10964
- type: 'button',
10965
- key: 'tog:' + key,
10966
- className: `dg-legendItem dg-legendToggle${on ? '' : ' dg-legendOff'}`,
10967
- 'data-gallery-filter': key,
10968
- 'data-gallery-filter-on': on ? '1' : '0',
10969
- title: on ? format(t('filterHideHint'), { label }) : format(t('filterShowHint'), { label }),
10970
- onClick: () => toggleCategory(key),
11362
+ return h('span', {
11363
+ className: 'dg-legendCell',
11364
+ key: 'cell:' + key,
11365
+ 'data-gallery-legend-cell': key,
10971
11366
  }, [
10972
- h('span', { className: `dg-legendSwatch ${swatchClass}`, key: 's' }),
10973
- h('span', { key: 'l' }, label),
10974
- count > 0 ? h('span', { className: 'dg-legendCount', key: 'n' }, String(count)) : null,
11367
+ h('button', {
11368
+ type: 'button',
11369
+ key: 'tog',
11370
+ className: `dg-legendItem dg-legendToggle${on ? '' : ' dg-legendOff'}`,
11371
+ 'data-gallery-filter': key,
11372
+ 'data-gallery-filter-on': on ? '1' : '0',
11373
+ title: on ? format(t('filterHideHint'), { label }) : format(t('filterShowHint'), { label }),
11374
+ onClick: () => toggleCategory(key),
11375
+ }, [
11376
+ h('span', { className: `dg-legendSwatch ${swatchClass}`, key: 's' }),
11377
+ h('span', { key: 'l' }, label),
11378
+ count > 0 ? h('span', { className: 'dg-legendCount', key: 'n' }, String(count)) : null,
11379
+ ]),
11380
+ // 2026-11-25:图例上直接「选」——按标签圈定是批量操作的入口
11381
+ count > 0
11382
+ ? h('button', {
11383
+ type: 'button',
11384
+ key: 'pick',
11385
+ className: 'dg-legendPick',
11386
+ 'data-gallery-legend-pick': key,
11387
+ 'data-on': pickedCategories.has(key) ? '1' : '0',
11388
+ 'data-busy': pickBusy === key ? '1' : '0',
11389
+ disabled: pickBusy !== '',
11390
+ title: format(t('legendPickHint'), { label }),
11391
+ onClick: (event) => { event.stopPropagation(); void selectByCategory(key) },
11392
+ }, pickBusy === key ? '…' : t('legendPick'))
11393
+ : null,
10975
11394
  ])
10976
11395
  }
10977
11396
 
@@ -11022,6 +11441,35 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
11022
11441
  openViewer(idx, null, list, false, null, rels[1])
11023
11442
  }, [selected, items, data, visibleItems, openViewer, showPasteNotice, t])
11024
11443
 
11444
+ /**
11445
+ * 按 relPath 集合取回完整条目(2026-11-25)。
11446
+ * 选中项可能跨分类 / 跨对话组,当前列表里找不到时退回「relPath + 末段文件名」,
11447
+ * 保证批量删除的确认清单不缺项。
11448
+ */
11449
+ const itemsForRelPaths = React.useCallback((rels) => {
11450
+ const want = new Set((Array.isArray(rels) ? rels : []).map((rp) => String(rp ?? '')).filter((rp) => rp !== ''))
11451
+ const out = []
11452
+ const push = (it) => {
11453
+ const rp = String(it?.relPath ?? '')
11454
+ if (rp === '' || !want.has(rp)) return
11455
+ if (out.some((x) => String(x?.relPath ?? '') === rp)) return
11456
+ out.push(it)
11457
+ }
11458
+ for (const it of (Array.isArray(items) ? items : [])) push(it)
11459
+ for (const it of (Array.isArray(visibleItems) ? visibleItems : [])) push(it)
11460
+ if (Array.isArray(data?.groups)) {
11461
+ for (const gr of data.groups) {
11462
+ for (const f of (Array.isArray(gr?.files) ? gr.files : [])) push(f)
11463
+ }
11464
+ }
11465
+ for (const rp of want) {
11466
+ if (out.some((x) => String(x?.relPath ?? '') === rp)) continue
11467
+ const seg = rp.split('/')
11468
+ out.push({ relPath: rp, name: seg[seg.length - 1] ?? rp })
11469
+ }
11470
+ return out
11471
+ }, [items, visibleItems, data])
11472
+
11025
11473
  const selectedCount = selected.size
11026
11474
  const batchBar = selectedCount > 0
11027
11475
  ? h('div', { className: 'dg-batchBar', key: 'batchBar', 'data-gallery-batch-bar': true }, [
@@ -11041,6 +11489,27 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
11041
11489
  title: t('batchCopyHint'),
11042
11490
  onClick: () => { void doCopyAssets([...selected]) },
11043
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})`),
11499
+ // 2026-11-25 批量删除:一次删掉全部选中,二次确认后不可恢复
11500
+ h('button', {
11501
+ type: 'button', className: 'dg-btn dg-btnSmall dg-dangerBtn', key: 'deleteSel',
11502
+ 'data-gallery-batch-delete': true,
11503
+ title: t('batchDeleteHint'),
11504
+ onClick: () => { setDeleteTarget({ items: itemsForRelPaths([...selected]), busy: false }) },
11505
+ }, `🗑 ${t('batchDeleteSelected')} (${selectedCount})`),
11506
+ // 2026-11-25 批量隐藏:只从列表移除,不动文件
11507
+ h('button', {
11508
+ type: 'button', className: 'dg-btn dg-btnSmall', key: 'hideSel',
11509
+ 'data-gallery-batch-hide': true,
11510
+ title: t('batchHideHint'),
11511
+ onClick: () => { void doHide([...selected]) },
11512
+ }, `🚫 ${t('batchHideSelected')} (${selectedCount})`),
11044
11513
  // 2026-11-17:正好选两张时给「对比」入口
11045
11514
  selectedCount === 2
11046
11515
  ? h('button', {
@@ -11050,6 +11519,29 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
11050
11519
  onClick: () => openCompareFromSelection(),
11051
11520
  }, '\u21c4 ' + t('cmpBatchEnter'))
11052
11521
  : null,
11522
+ // 2026-11-25:一屏一屏点太慢,给「全选当前 / 反选」
11523
+ h('button', {
11524
+ type: 'button', className: 'dg-btn dg-btnSmall', key: 'selAll',
11525
+ 'data-gallery-batch-selall': true,
11526
+ title: t('batchSelAllHint'),
11527
+ onClick: () => {
11528
+ const rels = visibleItems.map((it) => String(it?.relPath ?? '')).filter((rp) => rp !== '')
11529
+ if (rels.length === 0) return
11530
+ setSelected(new Set(rels))
11531
+ setBatchMode(true)
11532
+ },
11533
+ }, t('batchSelAll')),
11534
+ h('button', {
11535
+ type: 'button', className: 'dg-btn dg-btnSmall', key: 'invert',
11536
+ 'data-gallery-batch-invert': true,
11537
+ title: t('batchInvertHint'),
11538
+ onClick: () => {
11539
+ const rels = visibleItems.map((it) => String(it?.relPath ?? '')).filter((rp) => rp !== '')
11540
+ if (rels.length === 0) return
11541
+ setSelected((prev) => new Set(rels.filter((rp) => !prev.has(rp))))
11542
+ setBatchMode(true)
11543
+ },
11544
+ }, t('batchInvert')),
11053
11545
  h('button', {
11054
11546
  type: 'button', className: 'dg-btn dg-btnSmall', key: 'clearmark',
11055
11547
  'data-gallery-batch-clear': true,
@@ -11252,8 +11744,10 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
11252
11744
  // v1.3.0:这批刚产出的终稿加高亮 class(上限 3 张,由 freshFinalSet 控制)
11253
11745
  const isFreshFinal = freshFinalSet.has(item.relPath)
11254
11746
  return h('div', {
11255
- className: `dg-cardWrap${checked ? ' dg-cardChecked' : ''}${selectMode ? ' dg-cardSelectable' : ''}${isFreshFinal ? ' dg-cardFreshFinal' : ''}`,
11747
+ className: `dg-cardWrap${checked ? ' dg-cardChecked' : ''}${selectMode ? ' dg-cardSelectable' : ''}${isFreshFinal ? ' dg-cardFreshFinal' : ''}${item.inherited ? ' dg-inheritedCard' : ''}${item.shared ? ' dg-sharedCard' : ''}`,
11256
11748
  'data-gallery-fresh-final': isFreshFinal ? '1' : '0',
11749
+ 'data-gallery-inherited': item.inherited ? '1' : '0',
11750
+ 'data-gallery-shared': item.shared ? '1' : '0',
11257
11751
  key: key + ':wrap',
11258
11752
  // 三类卡片统一可拖(图片/文件/音视频):捕获阶段 dragstart 据此起原生拖出真文件。
11259
11753
  draggable: true,
@@ -11281,6 +11775,20 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
11281
11775
  : undefined,
11282
11776
  }, [
11283
11777
  node,
11778
+ // 2026-11-24:来源标记——只标来源,不降级交互(点开/批注/引用/批量照常)
11779
+ item.shared
11780
+ ? h('span', {
11781
+ className: 'dg-sharedBadge',
11782
+ key: 'sharedBadge',
11783
+ title: t('sharedBadgeHint'),
11784
+ }, t('sharedBadge'))
11785
+ : item.inherited
11786
+ ? h('span', {
11787
+ className: 'dg-inheritedBadge',
11788
+ key: 'inheritedBadge',
11789
+ title: t('inheritedBadgeHint'),
11790
+ }, t('inheritedBadge'))
11791
+ : null,
11284
11792
  // 图片卡片右上角「复制文件」(2026-11-19 老板要):等价右键菜单那条,
11285
11793
  // 写系统剪贴板,Ctrl+V 能直接粘出文件;文件卡片另有自己的按钮,故只对图片出。
11286
11794
  kind === 'image'
@@ -11653,6 +12161,7 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
11653
12161
  (visibleItems.length > 0
11654
12162
  ? h('div', { className: `dg-grid${kind === 'file' ? ' dg-fileGrid' : ''}${kind === 'media' ? ' dg-mediaGrid' : ''}`, key: 'grid' }, kind === 'media' ? mediaGridChildren : gridChildren)
11655
12163
  : h('div', { className: 'dg-groupEmpty', key: 'filterEmpty' }, t('filterEmptyHint'))),
12164
+
11656
12165
  data.scan.capped
11657
12166
  ? h('div', { className: 'dg-more', key: 'capped' }, t('capped'))
11658
12167
  : null,
@@ -11934,22 +12443,50 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
11934
12443
  onOpenOriginal: isImageItem(ctxMenu.item)
11935
12444
  ? () => { openViewerByItem(ctxMenu.item, true) }
11936
12445
  : undefined,
11937
- onHide: () => { void doHide(ctxMenu.item) },
12446
+ onHide: () => {
12447
+ const curRel = String(ctxMenu.item?.relPath ?? '')
12448
+ // 批量模式下右键已选中的卡片:隐藏整批,而不是只隐藏这一张
12449
+ void doHide(selected.size > 1 && selected.has(curRel) ? [...selected] : [ctxMenu.item])
12450
+ },
12451
+ hideLabel: selected.size > 1 && selected.has(String(ctxMenu.item?.relPath ?? ''))
12452
+ ? format(t('ctxHideSelected'), { n: selected.size })
12453
+ : undefined,
11938
12454
  onReveal: () => { void doReveal(ctxMenu.item) },
11939
12455
  // v0.17.0:【写进输入框】而不是复制到剪贴板 —— 少一步粘贴。
11940
12456
  // 写不进 composer 时自动退回剪贴板(见 writeAssetToComposer)。
11941
12457
  onCopy: () => { writeAssetToComposer(ctxMenu.item, ctxMenu.absPath) },
11942
12458
  // v0.16.0 单文件复制:写系统剪贴板文件列表,可在别的对话粘贴
11943
- onCopyFile: () => { void doCopyAssets([ctxMenu.item.relPath]) },
11944
- onDelete: () => setDeleteTarget({ item: ctxMenu.item, busy: false }),
12459
+ // 2026-11-25:批量选中时右键已选卡片 = 复制整批(与删除 / 隐藏同口径)
12460
+ onCopyFile: () => {
12461
+ const curRel = String(ctxMenu.item?.relPath ?? '')
12462
+ void doCopyAssets(selected.size > 1 && selected.has(curRel) ? [...selected] : [curRel])
12463
+ },
12464
+ copyFileLabel: selected.size > 1 && selected.has(String(ctxMenu.item?.relPath ?? ''))
12465
+ ? format(t('ctxCopyFileSelected'), { n: selected.size })
12466
+ : undefined,
12467
+ onDelete: () => {
12468
+ const curRel = String(ctxMenu.item?.relPath ?? '')
12469
+ // 批量模式下右键已选中的卡片:删整批,而不是只删这一张
12470
+ const rels = selected.size > 1 && selected.has(curRel) ? [...selected] : [curRel]
12471
+ setDeleteTarget({ items: itemsForRelPaths(rels), busy: false })
12472
+ },
12473
+ deleteLabel: selected.size > 1 && selected.has(String(ctxMenu.item?.relPath ?? ''))
12474
+ ? format(t('ctxDeleteSelected'), { n: selected.size })
12475
+ : undefined,
11945
12476
  // v0.16.0:列表级粘贴(右键任意卡片也出现)
11946
12477
  onPaste: () => { void doPaste() },
11947
12478
  // v0.14.2:改标签 / 恢复自动,表态层已下线
11948
12479
  onEditLabel: () => {
11949
12480
  const target = ctxMenu.item
12481
+ const curRel = String(target?.relPath ?? '')
11950
12482
  closeContextMenu()
11951
- openLabelDialog(target)
12483
+ // 2026-11-25:批量选中时改标签 = 改整批
12484
+ if (selected.size > 1 && selected.has(curRel)) openBatchLabelDialog()
12485
+ else openLabelDialog(target)
11952
12486
  },
12487
+ editLabelLabel: selected.size > 1 && selected.has(String(ctxMenu.item?.relPath ?? ''))
12488
+ ? format(t('labelEditSelected'), { n: selected.size })
12489
+ : undefined,
11953
12490
  ...(manualLabelOf(ctxMenu.item.relPath) !== null
11954
12491
  ? {
11955
12492
  onResetLabel: () => {
@@ -11985,12 +12522,25 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
11985
12522
  : null
11986
12523
 
11987
12524
  // 删除确认弹窗
12525
+ const deleteItems = deleteTarget === null
12526
+ ? []
12527
+ : (Array.isArray(deleteTarget.items) ? deleteTarget.items : [])
12528
+ const deleteMany = deleteItems.length > 1
11988
12529
  const confirmLayer = deleteTarget !== null
11989
12530
  ? h(ConfirmDialog, {
11990
12531
  key: 'confirmLayer',
11991
12532
  t,
11992
- name: deleteTarget.item.name,
12533
+ title: deleteMany ? format(t('ctxDeleteManyTitle'), { n: deleteItems.length }) : undefined,
12534
+ name: deleteMany
12535
+ ? format(t('ctxDeleteManySummary'), { n: deleteItems.length })
12536
+ : String(deleteItems[0]?.name ?? ''),
12537
+ files: deleteMany
12538
+ ? deleteItems.map((it) => String(it?.name ?? it?.relPath ?? ''))
12539
+ : undefined,
11993
12540
  busy: deleteTarget.busy === true,
12541
+ warn: deleteItems.some((it) => it?.inherited === true)
12542
+ ? t('inheritedDeleteWarn')
12543
+ : (deleteItems.some((it) => it?.shared === true) ? t('sharedDeleteWarn') : null),
11994
12544
  onCancel: () => setDeleteTarget(null),
11995
12545
  onConfirm: () => { void doDelete() },
11996
12546
  })