dsh-gallery 1.4.0 → 1.4.2
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 +73 -0
- package/README.md +34 -3
- package/client.js +459 -53
- package/host/groups.js +3 -0
- package/host/http.js +183 -65
- package/host/scan.js +398 -6
- package/package.json +1 -1
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: '取消',
|
|
@@ -1332,6 +1359,12 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
1332
1359
|
scopeSession: 'This chat',
|
|
1333
1360
|
scopeGlobalHint: 'All outputs, grouped by conversation',
|
|
1334
1361
|
scopeSessionHint: 'Only files produced in this chat',
|
|
1362
|
+
inheritedBadge: 'Inherited',
|
|
1363
|
+
inheritedBadgeHint: 'Inherited from the parent chat; works like this chat’s own output, except deleting it also affects the source chat',
|
|
1364
|
+
inheritedDeleteWarn: 'Inherited from the parent chat — deleting it will also remove it from the source chat’s assets',
|
|
1365
|
+
sharedBadge: 'Shared',
|
|
1366
|
+
sharedBadgeHint: 'Shared with a forked chat; works like this chat’s own output, except deleting it also affects that chat',
|
|
1367
|
+
sharedDeleteWarn: 'Shared asset — deleting it will also remove the file from the shared chat',
|
|
1335
1368
|
scopeUnknown: 'No outputs recorded for this chat',
|
|
1336
1369
|
scopeNotFound: 'Cannot find this chat’s session log',
|
|
1337
1370
|
scopeLogEmpty: 'This chat’s session log is empty',
|
|
@@ -1533,10 +1566,30 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
1533
1566
|
zoomResetHint: 'Reset zoom (or press 0)',
|
|
1534
1567
|
ctxHint: 'Right-click for more',
|
|
1535
1568
|
ctxHide: 'Hide (stop listing)',
|
|
1569
|
+
ctxHideSelected: 'Hide {n} selected files',
|
|
1570
|
+
ctxHideFailed: 'Hide failed',
|
|
1571
|
+
batchHideSelected: 'Hide selected',
|
|
1572
|
+
batchHideHint: 'Hide every selected file from the list (files untouched; restore in settings)',
|
|
1536
1573
|
ctxUnhide: 'Unhide',
|
|
1537
1574
|
ctxReveal: 'Open containing folder',
|
|
1538
1575
|
ctxCopy: 'Write into chat input',
|
|
1539
1576
|
ctxDelete: 'Delete file',
|
|
1577
|
+
ctxDeleteSelected: 'Delete {n} selected files',
|
|
1578
|
+
ctxDeleteManyTitle: 'Delete {n} files permanently? This cannot be undone',
|
|
1579
|
+
ctxDeleteManySummary: '{n} files',
|
|
1580
|
+
ctxDeletePartial: 'Deleted {n}, {fail} failed',
|
|
1581
|
+
batchDeleteSelected: 'Delete selected',
|
|
1582
|
+
batchDeleteHint: 'Delete every selected file (asks for confirmation, cannot be undone)',
|
|
1583
|
+
legendPick: 'Pick',
|
|
1584
|
+
legendPickHint: 'Select every file labeled "{label}" (click again to clear)',
|
|
1585
|
+
legendPickEmpty: 'Nothing in this category yet',
|
|
1586
|
+
legendPickTruncated: 'Too many; only the first {n} were selected',
|
|
1587
|
+
batchSelAll: 'Select visible',
|
|
1588
|
+
batchSelAllHint: 'Select every file in the current list',
|
|
1589
|
+
batchInvert: 'Invert',
|
|
1590
|
+
batchInvertHint: 'Select the files in the current list that are not selected yet',
|
|
1591
|
+
ctxCopyFileSelected: 'Copy {n} selected files',
|
|
1592
|
+
labelEditSelected: 'Re-label these {n} files',
|
|
1540
1593
|
ctxDeleteConfirm: 'Delete permanently? This cannot be undone',
|
|
1541
1594
|
ctxDeleteYes: 'Delete',
|
|
1542
1595
|
ctxDeleteNo: 'Cancel',
|
|
@@ -2684,6 +2737,24 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
2684
2737
|
font-size: 12px;
|
|
2685
2738
|
}
|
|
2686
2739
|
|
|
2740
|
+
/* 2026-11-24:分叉「继承」与主线「共享」是同一批文件的两侧视角——同款虚线框,只标来源、不降交互 */
|
|
2741
|
+
.dg-cardWrap.dg-inheritedCard,
|
|
2742
|
+
.dg-cardWrap.dg-sharedCard { outline: 1px dashed #9b8cf0; outline-offset: 1px; }
|
|
2743
|
+
.dg-inheritedBadge,
|
|
2744
|
+
.dg-sharedBadge {
|
|
2745
|
+
position: absolute;
|
|
2746
|
+
top: 6px; left: 50%; transform: translateX(-50%);
|
|
2747
|
+
z-index: 7;
|
|
2748
|
+
padding: 1px 8px;
|
|
2749
|
+
border-radius: 10px;
|
|
2750
|
+
font-size: 10px; font-weight: 600; line-height: 1.6;
|
|
2751
|
+
color: #5b4bc4;
|
|
2752
|
+
background: rgba(255, 255, 255, .94);
|
|
2753
|
+
border: 1px solid #b9aef0;
|
|
2754
|
+
pointer-events: none;
|
|
2755
|
+
white-space: nowrap;
|
|
2756
|
+
}
|
|
2757
|
+
|
|
2687
2758
|
/* ===== 分页条:常驻网格下方 ===== */
|
|
2688
2759
|
.dg-pager {
|
|
2689
2760
|
flex: 0 0 auto;
|
|
@@ -2820,6 +2891,24 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
2820
2891
|
background: var(--dsw-alias-bg-layer-2);
|
|
2821
2892
|
border-radius: 6px;
|
|
2822
2893
|
}
|
|
2894
|
+
.dg-confirmList {
|
|
2895
|
+
max-height: 168px; overflow-y: auto;
|
|
2896
|
+
display: flex; flex-direction: column; gap: 2px;
|
|
2897
|
+
padding: 6px 9px;
|
|
2898
|
+
background: var(--dsw-alias-bg-layer-2);
|
|
2899
|
+
border-radius: 6px;
|
|
2900
|
+
font-size: 11px; line-height: 1.6;
|
|
2901
|
+
color: var(--dsw-alias-label-secondary);
|
|
2902
|
+
}
|
|
2903
|
+
.dg-confirmListItem { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
2904
|
+
.dg-confirmWarn {
|
|
2905
|
+
font-size: 11px; line-height: 1.5;
|
|
2906
|
+
color: #b26a1d;
|
|
2907
|
+
background: rgba(212, 137, 60, .1);
|
|
2908
|
+
border: 1px solid rgba(212, 137, 60, .35);
|
|
2909
|
+
border-radius: 6px;
|
|
2910
|
+
padding: 6px 9px;
|
|
2911
|
+
}
|
|
2823
2912
|
.dg-confirmActions { display: flex; justify-content: flex-end; gap: 8px; }
|
|
2824
2913
|
.dg-dangerBtn {
|
|
2825
2914
|
color: #fff;
|
|
@@ -3455,6 +3544,16 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
3455
3544
|
.dg-legendToggle.dg-legendOff { opacity: 0.42; }
|
|
3456
3545
|
.dg-legendToggle.dg-legendOff .dg-legendSwatch { filter: grayscale(1); }
|
|
3457
3546
|
.dg-legendCount { font-size: 11px; color: #a9b1bd; margin-left: 2px; }
|
|
3547
|
+
.dg-legendCell { display: inline-flex; align-items: center; gap: 2px; }
|
|
3548
|
+
.dg-legendPick {
|
|
3549
|
+
appearance: none; border: 1px solid transparent; background: transparent;
|
|
3550
|
+
color: #8f97a3; font: inherit; font-size: 11px; line-height: 16px;
|
|
3551
|
+
padding: 0 5px; border-radius: 5px; cursor: pointer; opacity: 0.5;
|
|
3552
|
+
}
|
|
3553
|
+
.dg-legendCell:hover .dg-legendPick { opacity: 1; }
|
|
3554
|
+
.dg-legendPick:hover { border-color: rgba(120, 160, 255, 0.45); background: rgba(74, 124, 255, 0.16); color: #cfe0ff; }
|
|
3555
|
+
.dg-legendPick:disabled { cursor: default; }
|
|
3556
|
+
.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
3557
|
.dg-legendSwatchPending { opacity: 0.55; border-style: dashed !important; }
|
|
3459
3558
|
|
|
3460
3559
|
/* 卡片包装层 + 确认角标 + 多选框 */
|
|
@@ -5268,7 +5367,7 @@ function serializeFeedback(feedback) {
|
|
|
5268
5367
|
? entry('original', t('ctxOpenOriginal'), '🔍', () => actions.onOpenOriginal())
|
|
5269
5368
|
: null,
|
|
5270
5369
|
actions.onHide !== undefined
|
|
5271
|
-
? entry('hide', t('ctxHide'), '🚫', () => actions.onHide())
|
|
5370
|
+
? entry('hide', actions.hideLabel ?? t('ctxHide'), '🚫', () => actions.onHide())
|
|
5272
5371
|
: null,
|
|
5273
5372
|
actions.onReveal !== undefined
|
|
5274
5373
|
? entry('reveal', t('ctxReveal'), '📂', () => actions.onReveal())
|
|
@@ -5278,17 +5377,17 @@ function serializeFeedback(feedback) {
|
|
|
5278
5377
|
: null,
|
|
5279
5378
|
// v0.16.0:复制**文件本体**到系统剪贴板(与上面的「复制路径」文本区分)
|
|
5280
5379
|
actions.onCopyFile !== undefined
|
|
5281
|
-
? entry('copyFile', t('ctxCopyFile'), '📄', () => actions.onCopyFile())
|
|
5380
|
+
? entry('copyFile', actions.copyFileLabel ?? t('ctxCopyFile'), '📄', () => actions.onCopyFile())
|
|
5282
5381
|
: null,
|
|
5283
5382
|
actions.onDelete !== undefined
|
|
5284
|
-
? entry('delete', t('ctxDelete'), '🗑', () => actions.onDelete(), true)
|
|
5383
|
+
? entry('delete', actions.deleteLabel ?? t('ctxDelete'), '🗑', () => actions.onDelete(), true)
|
|
5285
5384
|
: null,
|
|
5286
5385
|
// ---- v0.14.2 手动标签:表态层已下线,只留「改标签 / 恢复自动」两个入口 ----
|
|
5287
5386
|
actions.onEditLabel !== undefined
|
|
5288
5387
|
? h('div', { className: 'dg-ctxDivider', key: 'labelDivider' }, t('labelEdit'))
|
|
5289
5388
|
: null,
|
|
5290
5389
|
actions.onEditLabel !== undefined
|
|
5291
|
-
? entry('label-edit', t('labelEdit'), '✎', () => actions.onEditLabel())
|
|
5390
|
+
? entry('label-edit', actions.editLabelLabel ?? t('labelEdit'), '✎', () => actions.onEditLabel())
|
|
5292
5391
|
: null,
|
|
5293
5392
|
actions.onResetLabel !== undefined
|
|
5294
5393
|
? entry('label-reset', t('labelCtxReset'), '↺', () => actions.onResetLabel())
|
|
@@ -5396,7 +5495,7 @@ function serializeFeedback(feedback) {
|
|
|
5396
5495
|
}
|
|
5397
5496
|
|
|
5398
5497
|
/** 删除确认弹窗:删除不可逆,必须二次确认。 */
|
|
5399
|
-
function ConfirmDialog({ t, name, busy, onCancel, onConfirm }) {
|
|
5498
|
+
function ConfirmDialog({ t, name, title, files, busy, warn, onCancel, onConfirm }) {
|
|
5400
5499
|
React.useEffect(() => {
|
|
5401
5500
|
const onKey = (event) => {
|
|
5402
5501
|
if (busy) return
|
|
@@ -5416,8 +5515,16 @@ function serializeFeedback(feedback) {
|
|
|
5416
5515
|
'aria-modal': true,
|
|
5417
5516
|
'data-gallery-confirm-delete': name,
|
|
5418
5517
|
}, [
|
|
5419
|
-
h('div', { className: 'dg-confirmTitle', key: 'title' }, t('ctxDeleteConfirm')),
|
|
5518
|
+
h('div', { className: 'dg-confirmTitle', key: 'title' }, title ?? t('ctxDeleteConfirm')),
|
|
5420
5519
|
h('div', { className: 'dg-confirmName', key: 'name' }, name),
|
|
5520
|
+
// 批量删除时列出文件名,避免「删的到底是哪些」说不清
|
|
5521
|
+
Array.isArray(files) && files.length > 0
|
|
5522
|
+
? h('div', { className: 'dg-confirmList', key: 'files' },
|
|
5523
|
+
files.slice(0, 40).map((f, i) => h('div', { className: 'dg-confirmListItem', key: `f${i}` }, String(f))))
|
|
5524
|
+
: null,
|
|
5525
|
+
warn
|
|
5526
|
+
? h('div', { className: 'dg-confirmWarn', key: 'warn' }, warn)
|
|
5527
|
+
: null,
|
|
5421
5528
|
h('div', { className: 'dg-confirmActions', key: 'actions' }, [
|
|
5422
5529
|
h('button', {
|
|
5423
5530
|
type: 'button', key: 'no', className: 'dg-btn',
|
|
@@ -6294,35 +6401,57 @@ ${absPath}
|
|
|
6294
6401
|
let cancelled = false
|
|
6295
6402
|
let started = false
|
|
6296
6403
|
let sourceUrl = null
|
|
6404
|
+
let retryTimer = null
|
|
6297
6405
|
const controller = new AbortController()
|
|
6298
6406
|
|
|
6299
|
-
|
|
6407
|
+
// 2026-11-24:图刚写出时取图可能超时 / 解码失败,旧版一次失败就永久
|
|
6408
|
+
// 显示「无法加载」,而点开大图时文件已完整。现在失败先重试两次;
|
|
6409
|
+
// 解码仍失败就退回原图 Blob 直接显示(大图路径同样用 <img>)。
|
|
6410
|
+
const run = (attempt = 0) => {
|
|
6300
6411
|
if (started) return
|
|
6301
6412
|
started = true
|
|
6302
6413
|
setState({ status: 'pending' })
|
|
6303
6414
|
limiter(async () => {
|
|
6304
6415
|
const blob = await fetchRaw(item.relPath, controller.signal)
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6416
|
+
if (cancelled) return
|
|
6417
|
+
try {
|
|
6418
|
+
const thumb = await makeScaled(blob, THUMB_SIZE, true)
|
|
6419
|
+
if (cancelled) {
|
|
6420
|
+
if (thumb.url !== null) URL.revokeObjectURL(thumb.url)
|
|
6421
|
+
return
|
|
6422
|
+
}
|
|
6423
|
+
sourceUrl = thumb.url
|
|
6424
|
+
setState({ status: 'ready', url: thumb.url })
|
|
6425
|
+
} catch (decodeError) {
|
|
6426
|
+
// 部分 WebView 对刚写入的 RGBA 图 createImageBitmap 会失败;
|
|
6427
|
+
// 原图 Blob 交给 <img> 是查看器已验证可用的路径,照此兜底。
|
|
6428
|
+
const url = URL.createObjectURL(blob)
|
|
6429
|
+
if (cancelled) { URL.revokeObjectURL(url); return }
|
|
6430
|
+
sourceUrl = url
|
|
6431
|
+
setState({ status: 'ready', url, thumbFallback: true })
|
|
6309
6432
|
}
|
|
6310
|
-
sourceUrl = thumb.url
|
|
6311
|
-
setState({ status: 'ready', url: thumb.url })
|
|
6312
6433
|
}).catch((error) => {
|
|
6313
6434
|
if (cancelled || controller.signal.aborted) return
|
|
6435
|
+
if (attempt < 2) {
|
|
6436
|
+
started = false
|
|
6437
|
+
retryTimer = setTimeout(() => run(attempt + 1), 1500 * (attempt + 1))
|
|
6438
|
+
return
|
|
6439
|
+
}
|
|
6314
6440
|
setState({ status: 'failed', message: String(error?.message ?? error) })
|
|
6315
6441
|
})
|
|
6316
6442
|
}
|
|
6317
6443
|
|
|
6444
|
+
const cleanup = () => {
|
|
6445
|
+
cancelled = true
|
|
6446
|
+
if (retryTimer !== null) clearTimeout(retryTimer)
|
|
6447
|
+
controller.abort()
|
|
6448
|
+
if (sourceUrl !== null) URL.revokeObjectURL(sourceUrl)
|
|
6449
|
+
}
|
|
6450
|
+
|
|
6318
6451
|
// 环境不支持 IntersectionObserver 时直接加载,保证可用性。
|
|
6319
6452
|
if (typeof IntersectionObserver !== 'function') {
|
|
6320
6453
|
run()
|
|
6321
|
-
return
|
|
6322
|
-
cancelled = true
|
|
6323
|
-
controller.abort()
|
|
6324
|
-
if (sourceUrl !== null) URL.revokeObjectURL(sourceUrl)
|
|
6325
|
-
}
|
|
6454
|
+
return cleanup
|
|
6326
6455
|
}
|
|
6327
6456
|
|
|
6328
6457
|
const observer = new IntersectionObserver((entries) => {
|
|
@@ -6335,10 +6464,8 @@ ${absPath}
|
|
|
6335
6464
|
observer.observe(node)
|
|
6336
6465
|
|
|
6337
6466
|
return () => {
|
|
6338
|
-
cancelled = true
|
|
6339
6467
|
observer.disconnect()
|
|
6340
|
-
|
|
6341
|
-
if (sourceUrl !== null) URL.revokeObjectURL(sourceUrl)
|
|
6468
|
+
cleanup()
|
|
6342
6469
|
}
|
|
6343
6470
|
}, [node, item.relPath, limiter])
|
|
6344
6471
|
|
|
@@ -6398,6 +6525,7 @@ ${absPath}
|
|
|
6398
6525
|
loading: 'lazy',
|
|
6399
6526
|
width: THUMB_SIZE,
|
|
6400
6527
|
height: THUMB_SIZE,
|
|
6528
|
+
'data-gallery-thumb-raw': state.thumbFallback ? '1' : undefined,
|
|
6401
6529
|
})
|
|
6402
6530
|
: h('div', { className: 'dg-placeholder', 'data-gallery-placeholder': state.status },
|
|
6403
6531
|
state.status === 'failed'
|
|
@@ -10215,11 +10343,20 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
10215
10343
|
})
|
|
10216
10344
|
}, [])
|
|
10217
10345
|
|
|
10218
|
-
/**
|
|
10219
|
-
|
|
10346
|
+
/**
|
|
10347
|
+
* 隐藏条目(只从列表移除,不动文件)。
|
|
10348
|
+
* 2026-11-25:接受单个条目或 relPath 数组;批量隐藏一次写完。
|
|
10349
|
+
*/
|
|
10350
|
+
const doHide = React.useCallback(async (target) => {
|
|
10351
|
+
const rels = (Array.isArray(target) ? target : [target?.relPath ?? ''])
|
|
10352
|
+
.map((rp) => String(rp ?? ''))
|
|
10353
|
+
.filter((rp) => rp !== '')
|
|
10354
|
+
if (rels.length === 0) return
|
|
10220
10355
|
try {
|
|
10221
|
-
const payload = await callHost('hide', {
|
|
10356
|
+
const payload = await callHost('hide', { paths: rels })
|
|
10222
10357
|
if (payload?.ok === false) throw new Error(payload?.error?.message ?? t('errorTitle'))
|
|
10358
|
+
setSelected(new Set())
|
|
10359
|
+
setBatchMode(false)
|
|
10223
10360
|
await load(undefined, kind, scope, page).then((data) => setView({ status: 'ready', data })).catch(() => {})
|
|
10224
10361
|
} catch (error) {
|
|
10225
10362
|
console.error('dsh-gallery: 隐藏失败', error)
|
|
@@ -10236,22 +10373,43 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
10236
10373
|
}
|
|
10237
10374
|
}, [t])
|
|
10238
10375
|
|
|
10239
|
-
/**
|
|
10376
|
+
/** 粘贴/操作提示(成功/失败),3 秒自动消失。 */
|
|
10377
|
+
const [pasteNotice, setPasteNotice] = React.useState(null)
|
|
10378
|
+
const showPasteNotice = React.useCallback((kindOf, text) => {
|
|
10379
|
+
setPasteNotice({ kind: kindOf, text })
|
|
10380
|
+
}, [])
|
|
10381
|
+
|
|
10382
|
+
/**
|
|
10383
|
+
* 执行删除(需二次确认)。
|
|
10384
|
+
* 2026-11-25:批量选中时一次删完全部 —— Host 的 delete 接受 paths 数组,
|
|
10385
|
+
* 单条只是长度 1 的特例,两侧不再有两套逻辑。
|
|
10386
|
+
*/
|
|
10240
10387
|
const doDelete = React.useCallback(async () => {
|
|
10241
10388
|
const target = deleteTarget
|
|
10242
10389
|
if (target === null || target.busy === true) return
|
|
10390
|
+
const items = Array.isArray(target.items) ? target.items : []
|
|
10391
|
+
const rels = items.map((it) => String(it?.relPath ?? '')).filter((rp) => rp !== '')
|
|
10392
|
+
if (rels.length === 0) { setDeleteTarget(null); return }
|
|
10243
10393
|
setDeleteTarget({ ...target, busy: true })
|
|
10244
10394
|
try {
|
|
10245
|
-
const payload = await callHost('delete', {
|
|
10395
|
+
const payload = await callHost('delete', { paths: rels, confirm: true })
|
|
10246
10396
|
if (payload?.ok === false) throw new Error(payload?.error?.message ?? t('errorTitle'))
|
|
10397
|
+
const failed = (Array.isArray(payload?.failed) ? payload.failed.length : 0)
|
|
10398
|
+
+ (Array.isArray(payload?.notFound) ? payload.notFound.length : 0)
|
|
10399
|
+
if (failed > 0) {
|
|
10400
|
+
showPasteNotice('fail', format(t('ctxDeletePartial'), { n: rels.length - failed, fail: failed }))
|
|
10401
|
+
}
|
|
10247
10402
|
setDeleteTarget(null)
|
|
10403
|
+
setSelected(new Set())
|
|
10404
|
+
setBatchMode(false)
|
|
10248
10405
|
kickChanges()
|
|
10249
10406
|
await load(undefined, kind, scope, page).then((data) => setView({ status: 'ready', data })).catch(() => {})
|
|
10250
10407
|
} catch (error) {
|
|
10251
10408
|
console.error('dsh-gallery: 删除失败', error)
|
|
10252
10409
|
setDeleteTarget(null)
|
|
10410
|
+
showPasteNotice('fail', t('ctxDeleteFailed'))
|
|
10253
10411
|
}
|
|
10254
|
-
}, [deleteTarget, load, kind, scope, page, t])
|
|
10412
|
+
}, [deleteTarget, load, kind, scope, page, t, showPasteNotice])
|
|
10255
10413
|
|
|
10256
10414
|
const refresh = React.useCallback(async () => {
|
|
10257
10415
|
setRefreshing(true)
|
|
@@ -10266,18 +10424,12 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
10266
10424
|
}, [load, kind, scope, page])
|
|
10267
10425
|
|
|
10268
10426
|
// ---- v0.16.0 粘贴:剪贴板图片/文件作为「素材」落当前对话 ----
|
|
10269
|
-
/** 粘贴提示(成功/失败),3 秒自动消失。 */
|
|
10270
|
-
const [pasteNotice, setPasteNotice] = React.useState(null)
|
|
10271
10427
|
React.useEffect(() => {
|
|
10272
10428
|
if (pasteNotice === null) return undefined
|
|
10273
10429
|
const timer = setTimeout(() => setPasteNotice(null), 3000)
|
|
10274
10430
|
return () => clearTimeout(timer)
|
|
10275
10431
|
}, [pasteNotice])
|
|
10276
10432
|
|
|
10277
|
-
const showPasteNotice = React.useCallback((kindOf, text) => {
|
|
10278
|
-
setPasteNotice({ kind: kindOf, text })
|
|
10279
|
-
}, [])
|
|
10280
|
-
|
|
10281
10433
|
/**
|
|
10282
10434
|
* v0.16.2 粘贴落点解析:hover 的对话组优先,否则 slot 的当前对话。
|
|
10283
10435
|
*
|
|
@@ -10406,21 +10558,33 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
10406
10558
|
const parsed = extractFromPasteEvent(clipboardData)
|
|
10407
10559
|
if (parsed.images.length > 0 || parsed.files.length > 0) {
|
|
10408
10560
|
if (typeof event?.preventDefault === 'function') event.preventDefault()
|
|
10561
|
+
// 🔴 2026-11-25:只解析到一张位图时,剪贴板可能其实是「多个文件的 FileDropList」,
|
|
10562
|
+
// Chromium 的 paste 事件只给其中一张。先问 Host 要真实文件列表,拿到多个就按文件走。
|
|
10563
|
+
if (parsed.files.length === 0 && parsed.images.length === 1) {
|
|
10564
|
+
const got = await pasteFromClipboard()
|
|
10565
|
+
if (got) return true
|
|
10566
|
+
}
|
|
10409
10567
|
await ingestPasted(parsed)
|
|
10410
10568
|
return true
|
|
10411
10569
|
}
|
|
10412
10570
|
return pasteFromClipboard()
|
|
10413
10571
|
}, [ingestPasted, pasteFromClipboard])
|
|
10414
10572
|
|
|
10415
|
-
/**
|
|
10573
|
+
/**
|
|
10574
|
+
* 右键菜单「粘贴」。
|
|
10575
|
+
* 🔴 2026-11-25:**文件列表优先**。批量复制多张图时系统剪贴板是 CF_HDROP,
|
|
10576
|
+
* 而 Clipboard API 的 read() 往往只回一张位图 —— 先走图片通道就会「只粘最后一张」。
|
|
10577
|
+
* 截图(纯位图、没有文件列表)仍会落到图片通道。
|
|
10578
|
+
*/
|
|
10416
10579
|
const doPaste = React.useCallback(async () => {
|
|
10580
|
+
const got = await pasteFromClipboard()
|
|
10581
|
+
if (got) return
|
|
10417
10582
|
const images = await readClipboardImages()
|
|
10418
10583
|
if (images.length > 0) {
|
|
10419
10584
|
await ingestPasted({ images, files: [] })
|
|
10420
10585
|
return
|
|
10421
10586
|
}
|
|
10422
|
-
|
|
10423
|
-
if (!got) showPasteNotice('fail', t('pasteEmpty'))
|
|
10587
|
+
showPasteNotice('fail', t('pasteEmpty'))
|
|
10424
10588
|
}, [ingestPasted, pasteFromClipboard, showPasteNotice, t])
|
|
10425
10589
|
|
|
10426
10590
|
/** v0.16.0 图片裁剪:把裁剪出的 PNG base64 交给 Host 落盘(源图同目录,标素材)。 */
|
|
@@ -10957,21 +11121,139 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
10957
11121
|
* · 「未归类」只在确实存在时出现
|
|
10958
11122
|
* · 只记本次使用,不持久化
|
|
10959
11123
|
*/
|
|
11124
|
+
/**
|
|
11125
|
+
* 按标签一次圈定(2026-11-25)。
|
|
11126
|
+
*
|
|
11127
|
+
* 为什么必须问宿主要全量路径:列表接口在「当前对话」视图是分页的(每页 60),
|
|
11128
|
+
* 带 category 过滤也只过滤当前页 —— 只在已加载条目里挑,点了「选」却只选中
|
|
11129
|
+
* 60 张,等于又一次「批量没生效」。categoryPaths 是纯读接口,只回 relPath。
|
|
11130
|
+
* 旧宿主没有这个 op 时退回本地已加载条目:能用,只是可能不全。
|
|
11131
|
+
*/
|
|
11132
|
+
// 圈选进行中:按钮显示「…」并禁用。
|
|
11133
|
+
// 没有这道门,手快点两下会被当成「选了又取消」(切换语义),看着像没生效。
|
|
11134
|
+
const pickBusyRef = React.useRef('')
|
|
11135
|
+
const [pickBusy, setPickBusy] = React.useState('')
|
|
11136
|
+
const selectByCategory = React.useCallback(async (cat) => {
|
|
11137
|
+
if (!['final', 'input', 'intermediate', 'unknown'].includes(cat)) return
|
|
11138
|
+
if (pickBusyRef.current !== '') return
|
|
11139
|
+
pickBusyRef.current = cat
|
|
11140
|
+
setPickBusy(cat)
|
|
11141
|
+
try {
|
|
11142
|
+
const poolFrom = () => {
|
|
11143
|
+
const out = []
|
|
11144
|
+
const seen = new Set()
|
|
11145
|
+
const push = (it) => {
|
|
11146
|
+
const rp = String(it?.relPath ?? '')
|
|
11147
|
+
if (rp === '' || seen.has(rp)) return
|
|
11148
|
+
const c = String(it?.category ?? '') === '' ? 'unknown' : String(it.category)
|
|
11149
|
+
if (c !== cat) return
|
|
11150
|
+
seen.add(rp)
|
|
11151
|
+
out.push(rp)
|
|
11152
|
+
}
|
|
11153
|
+
for (const it of (Array.isArray(items) ? items : [])) push(it)
|
|
11154
|
+
for (const it of (Array.isArray(visibleItems) ? visibleItems : [])) push(it)
|
|
11155
|
+
if (Array.isArray(data?.groups)) {
|
|
11156
|
+
for (const gr of data.groups) for (const f of (Array.isArray(gr?.files) ? gr.files : [])) push(f)
|
|
11157
|
+
}
|
|
11158
|
+
return out
|
|
11159
|
+
}
|
|
11160
|
+
let rels = []
|
|
11161
|
+
let truncated = false
|
|
11162
|
+
try {
|
|
11163
|
+
const payload = await callHost('categoryPaths', { kind, scope, sessionId, category: cat })
|
|
11164
|
+
if (payload?.ok === true && Array.isArray(payload.paths)) {
|
|
11165
|
+
rels = payload.paths.map((rp) => String(rp ?? '')).filter((rp) => rp !== '')
|
|
11166
|
+
truncated = payload.truncated === true
|
|
11167
|
+
}
|
|
11168
|
+
} catch (error) {
|
|
11169
|
+
console.warn('dsh-gallery: categoryPaths 不可用,退回已加载条目', error)
|
|
11170
|
+
}
|
|
11171
|
+
if (rels.length === 0) rels = poolFrom()
|
|
11172
|
+
if (rels.length === 0) {
|
|
11173
|
+
showPasteNotice('fail', t('legendPickEmpty'))
|
|
11174
|
+
return
|
|
11175
|
+
}
|
|
11176
|
+
setSelected((prev) => {
|
|
11177
|
+
const next = new Set(prev)
|
|
11178
|
+
const allIn = rels.every((rp) => next.has(rp))
|
|
11179
|
+
for (const rp of rels) {
|
|
11180
|
+
if (allIn) next.delete(rp)
|
|
11181
|
+
else next.add(rp)
|
|
11182
|
+
}
|
|
11183
|
+
return next
|
|
11184
|
+
})
|
|
11185
|
+
// 该分类当前是关着的就先打开:不然圈中了却看不见,看着像没生效
|
|
11186
|
+
if (categoryFilter[cat] === false) toggleCategory(cat)
|
|
11187
|
+
setBatchMode(true)
|
|
11188
|
+
if (truncated) showPasteNotice('ok', format(t('legendPickTruncated'), { n: rels.length }))
|
|
11189
|
+
} finally {
|
|
11190
|
+
pickBusyRef.current = ''
|
|
11191
|
+
setPickBusy('')
|
|
11192
|
+
}
|
|
11193
|
+
}, [kind, scope, sessionId, items, visibleItems, data, categoryFilter, toggleCategory, showPasteNotice, t])
|
|
11194
|
+
|
|
11195
|
+
/**
|
|
11196
|
+
* 哪些分类已经「整类选中」——只用来给图例上的「选」按钮点亮。
|
|
11197
|
+
* 跨页选中的项不一定在已加载列表里,那时计数偏小、按钮不点亮,但不影响操作。
|
|
11198
|
+
*/
|
|
11199
|
+
const pickedCategories = React.useMemo(() => {
|
|
11200
|
+
const out = new Set()
|
|
11201
|
+
if (selected.size === 0) return out
|
|
11202
|
+
const c = { final: 0, input: 0, intermediate: 0, unknown: 0 }
|
|
11203
|
+
const seen = new Set()
|
|
11204
|
+
const push = (it) => {
|
|
11205
|
+
const rp = String(it?.relPath ?? '')
|
|
11206
|
+
if (rp === '' || seen.has(rp) || !selected.has(rp)) return
|
|
11207
|
+
seen.add(rp)
|
|
11208
|
+
const b = bucketOf(it)
|
|
11209
|
+
if (Object.prototype.hasOwnProperty.call(c, b)) c[b] += 1
|
|
11210
|
+
}
|
|
11211
|
+
for (const it of (Array.isArray(items) ? items : [])) push(it)
|
|
11212
|
+
for (const it of (Array.isArray(visibleItems) ? visibleItems : [])) push(it)
|
|
11213
|
+
if (Array.isArray(data?.groups)) {
|
|
11214
|
+
for (const gr of data.groups) for (const f of (Array.isArray(gr?.files) ? gr.files : [])) push(f)
|
|
11215
|
+
}
|
|
11216
|
+
for (const k of Object.keys(c)) {
|
|
11217
|
+
if (c[k] > 0 && c[k] >= Number(catCounts[k] ?? 0)) out.add(k)
|
|
11218
|
+
}
|
|
11219
|
+
return out
|
|
11220
|
+
}, [selected, items, visibleItems, data, bucketOf, catCounts])
|
|
11221
|
+
|
|
10960
11222
|
const filterToggle = (key, label, swatchClass, count, alwaysShow) => {
|
|
10961
11223
|
const on = categoryFilter[key] !== false
|
|
10962
11224
|
if (!on && !alwaysShow && count === 0) return null
|
|
10963
|
-
return h('
|
|
10964
|
-
|
|
10965
|
-
key: '
|
|
10966
|
-
|
|
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),
|
|
11225
|
+
return h('span', {
|
|
11226
|
+
className: 'dg-legendCell',
|
|
11227
|
+
key: 'cell:' + key,
|
|
11228
|
+
'data-gallery-legend-cell': key,
|
|
10971
11229
|
}, [
|
|
10972
|
-
h('
|
|
10973
|
-
|
|
10974
|
-
|
|
11230
|
+
h('button', {
|
|
11231
|
+
type: 'button',
|
|
11232
|
+
key: 'tog',
|
|
11233
|
+
className: `dg-legendItem dg-legendToggle${on ? '' : ' dg-legendOff'}`,
|
|
11234
|
+
'data-gallery-filter': key,
|
|
11235
|
+
'data-gallery-filter-on': on ? '1' : '0',
|
|
11236
|
+
title: on ? format(t('filterHideHint'), { label }) : format(t('filterShowHint'), { label }),
|
|
11237
|
+
onClick: () => toggleCategory(key),
|
|
11238
|
+
}, [
|
|
11239
|
+
h('span', { className: `dg-legendSwatch ${swatchClass}`, key: 's' }),
|
|
11240
|
+
h('span', { key: 'l' }, label),
|
|
11241
|
+
count > 0 ? h('span', { className: 'dg-legendCount', key: 'n' }, String(count)) : null,
|
|
11242
|
+
]),
|
|
11243
|
+
// 2026-11-25:图例上直接「选」——按标签圈定是批量操作的入口
|
|
11244
|
+
count > 0
|
|
11245
|
+
? h('button', {
|
|
11246
|
+
type: 'button',
|
|
11247
|
+
key: 'pick',
|
|
11248
|
+
className: 'dg-legendPick',
|
|
11249
|
+
'data-gallery-legend-pick': key,
|
|
11250
|
+
'data-on': pickedCategories.has(key) ? '1' : '0',
|
|
11251
|
+
'data-busy': pickBusy === key ? '1' : '0',
|
|
11252
|
+
disabled: pickBusy !== '',
|
|
11253
|
+
title: format(t('legendPickHint'), { label }),
|
|
11254
|
+
onClick: (event) => { event.stopPropagation(); void selectByCategory(key) },
|
|
11255
|
+
}, pickBusy === key ? '…' : t('legendPick'))
|
|
11256
|
+
: null,
|
|
10975
11257
|
])
|
|
10976
11258
|
}
|
|
10977
11259
|
|
|
@@ -11022,6 +11304,35 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
11022
11304
|
openViewer(idx, null, list, false, null, rels[1])
|
|
11023
11305
|
}, [selected, items, data, visibleItems, openViewer, showPasteNotice, t])
|
|
11024
11306
|
|
|
11307
|
+
/**
|
|
11308
|
+
* 按 relPath 集合取回完整条目(2026-11-25)。
|
|
11309
|
+
* 选中项可能跨分类 / 跨对话组,当前列表里找不到时退回「relPath + 末段文件名」,
|
|
11310
|
+
* 保证批量删除的确认清单不缺项。
|
|
11311
|
+
*/
|
|
11312
|
+
const itemsForRelPaths = React.useCallback((rels) => {
|
|
11313
|
+
const want = new Set((Array.isArray(rels) ? rels : []).map((rp) => String(rp ?? '')).filter((rp) => rp !== ''))
|
|
11314
|
+
const out = []
|
|
11315
|
+
const push = (it) => {
|
|
11316
|
+
const rp = String(it?.relPath ?? '')
|
|
11317
|
+
if (rp === '' || !want.has(rp)) return
|
|
11318
|
+
if (out.some((x) => String(x?.relPath ?? '') === rp)) return
|
|
11319
|
+
out.push(it)
|
|
11320
|
+
}
|
|
11321
|
+
for (const it of (Array.isArray(items) ? items : [])) push(it)
|
|
11322
|
+
for (const it of (Array.isArray(visibleItems) ? visibleItems : [])) push(it)
|
|
11323
|
+
if (Array.isArray(data?.groups)) {
|
|
11324
|
+
for (const gr of data.groups) {
|
|
11325
|
+
for (const f of (Array.isArray(gr?.files) ? gr.files : [])) push(f)
|
|
11326
|
+
}
|
|
11327
|
+
}
|
|
11328
|
+
for (const rp of want) {
|
|
11329
|
+
if (out.some((x) => String(x?.relPath ?? '') === rp)) continue
|
|
11330
|
+
const seg = rp.split('/')
|
|
11331
|
+
out.push({ relPath: rp, name: seg[seg.length - 1] ?? rp })
|
|
11332
|
+
}
|
|
11333
|
+
return out
|
|
11334
|
+
}, [items, visibleItems, data])
|
|
11335
|
+
|
|
11025
11336
|
const selectedCount = selected.size
|
|
11026
11337
|
const batchBar = selectedCount > 0
|
|
11027
11338
|
? h('div', { className: 'dg-batchBar', key: 'batchBar', 'data-gallery-batch-bar': true }, [
|
|
@@ -11041,6 +11352,20 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
11041
11352
|
title: t('batchCopyHint'),
|
|
11042
11353
|
onClick: () => { void doCopyAssets([...selected]) },
|
|
11043
11354
|
}, `⧉ ${t('batchCopyFiles')} (${selectedCount})`),
|
|
11355
|
+
// 2026-11-25 批量删除:一次删掉全部选中,二次确认后不可恢复
|
|
11356
|
+
h('button', {
|
|
11357
|
+
type: 'button', className: 'dg-btn dg-btnSmall dg-dangerBtn', key: 'deleteSel',
|
|
11358
|
+
'data-gallery-batch-delete': true,
|
|
11359
|
+
title: t('batchDeleteHint'),
|
|
11360
|
+
onClick: () => { setDeleteTarget({ items: itemsForRelPaths([...selected]), busy: false }) },
|
|
11361
|
+
}, `🗑 ${t('batchDeleteSelected')} (${selectedCount})`),
|
|
11362
|
+
// 2026-11-25 批量隐藏:只从列表移除,不动文件
|
|
11363
|
+
h('button', {
|
|
11364
|
+
type: 'button', className: 'dg-btn dg-btnSmall', key: 'hideSel',
|
|
11365
|
+
'data-gallery-batch-hide': true,
|
|
11366
|
+
title: t('batchHideHint'),
|
|
11367
|
+
onClick: () => { void doHide([...selected]) },
|
|
11368
|
+
}, `🚫 ${t('batchHideSelected')} (${selectedCount})`),
|
|
11044
11369
|
// 2026-11-17:正好选两张时给「对比」入口
|
|
11045
11370
|
selectedCount === 2
|
|
11046
11371
|
? h('button', {
|
|
@@ -11050,6 +11375,29 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
11050
11375
|
onClick: () => openCompareFromSelection(),
|
|
11051
11376
|
}, '\u21c4 ' + t('cmpBatchEnter'))
|
|
11052
11377
|
: null,
|
|
11378
|
+
// 2026-11-25:一屏一屏点太慢,给「全选当前 / 反选」
|
|
11379
|
+
h('button', {
|
|
11380
|
+
type: 'button', className: 'dg-btn dg-btnSmall', key: 'selAll',
|
|
11381
|
+
'data-gallery-batch-selall': true,
|
|
11382
|
+
title: t('batchSelAllHint'),
|
|
11383
|
+
onClick: () => {
|
|
11384
|
+
const rels = visibleItems.map((it) => String(it?.relPath ?? '')).filter((rp) => rp !== '')
|
|
11385
|
+
if (rels.length === 0) return
|
|
11386
|
+
setSelected(new Set(rels))
|
|
11387
|
+
setBatchMode(true)
|
|
11388
|
+
},
|
|
11389
|
+
}, t('batchSelAll')),
|
|
11390
|
+
h('button', {
|
|
11391
|
+
type: 'button', className: 'dg-btn dg-btnSmall', key: 'invert',
|
|
11392
|
+
'data-gallery-batch-invert': true,
|
|
11393
|
+
title: t('batchInvertHint'),
|
|
11394
|
+
onClick: () => {
|
|
11395
|
+
const rels = visibleItems.map((it) => String(it?.relPath ?? '')).filter((rp) => rp !== '')
|
|
11396
|
+
if (rels.length === 0) return
|
|
11397
|
+
setSelected((prev) => new Set(rels.filter((rp) => !prev.has(rp))))
|
|
11398
|
+
setBatchMode(true)
|
|
11399
|
+
},
|
|
11400
|
+
}, t('batchInvert')),
|
|
11053
11401
|
h('button', {
|
|
11054
11402
|
type: 'button', className: 'dg-btn dg-btnSmall', key: 'clearmark',
|
|
11055
11403
|
'data-gallery-batch-clear': true,
|
|
@@ -11252,8 +11600,10 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
11252
11600
|
// v1.3.0:这批刚产出的终稿加高亮 class(上限 3 张,由 freshFinalSet 控制)
|
|
11253
11601
|
const isFreshFinal = freshFinalSet.has(item.relPath)
|
|
11254
11602
|
return h('div', {
|
|
11255
|
-
className: `dg-cardWrap${checked ? ' dg-cardChecked' : ''}${selectMode ? ' dg-cardSelectable' : ''}${isFreshFinal ? ' dg-cardFreshFinal' : ''}`,
|
|
11603
|
+
className: `dg-cardWrap${checked ? ' dg-cardChecked' : ''}${selectMode ? ' dg-cardSelectable' : ''}${isFreshFinal ? ' dg-cardFreshFinal' : ''}${item.inherited ? ' dg-inheritedCard' : ''}${item.shared ? ' dg-sharedCard' : ''}`,
|
|
11256
11604
|
'data-gallery-fresh-final': isFreshFinal ? '1' : '0',
|
|
11605
|
+
'data-gallery-inherited': item.inherited ? '1' : '0',
|
|
11606
|
+
'data-gallery-shared': item.shared ? '1' : '0',
|
|
11257
11607
|
key: key + ':wrap',
|
|
11258
11608
|
// 三类卡片统一可拖(图片/文件/音视频):捕获阶段 dragstart 据此起原生拖出真文件。
|
|
11259
11609
|
draggable: true,
|
|
@@ -11281,6 +11631,20 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
11281
11631
|
: undefined,
|
|
11282
11632
|
}, [
|
|
11283
11633
|
node,
|
|
11634
|
+
// 2026-11-24:来源标记——只标来源,不降级交互(点开/批注/引用/批量照常)
|
|
11635
|
+
item.shared
|
|
11636
|
+
? h('span', {
|
|
11637
|
+
className: 'dg-sharedBadge',
|
|
11638
|
+
key: 'sharedBadge',
|
|
11639
|
+
title: t('sharedBadgeHint'),
|
|
11640
|
+
}, t('sharedBadge'))
|
|
11641
|
+
: item.inherited
|
|
11642
|
+
? h('span', {
|
|
11643
|
+
className: 'dg-inheritedBadge',
|
|
11644
|
+
key: 'inheritedBadge',
|
|
11645
|
+
title: t('inheritedBadgeHint'),
|
|
11646
|
+
}, t('inheritedBadge'))
|
|
11647
|
+
: null,
|
|
11284
11648
|
// 图片卡片右上角「复制文件」(2026-11-19 老板要):等价右键菜单那条,
|
|
11285
11649
|
// 写系统剪贴板,Ctrl+V 能直接粘出文件;文件卡片另有自己的按钮,故只对图片出。
|
|
11286
11650
|
kind === 'image'
|
|
@@ -11653,6 +12017,7 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
11653
12017
|
(visibleItems.length > 0
|
|
11654
12018
|
? h('div', { className: `dg-grid${kind === 'file' ? ' dg-fileGrid' : ''}${kind === 'media' ? ' dg-mediaGrid' : ''}`, key: 'grid' }, kind === 'media' ? mediaGridChildren : gridChildren)
|
|
11655
12019
|
: h('div', { className: 'dg-groupEmpty', key: 'filterEmpty' }, t('filterEmptyHint'))),
|
|
12020
|
+
|
|
11656
12021
|
data.scan.capped
|
|
11657
12022
|
? h('div', { className: 'dg-more', key: 'capped' }, t('capped'))
|
|
11658
12023
|
: null,
|
|
@@ -11934,22 +12299,50 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
11934
12299
|
onOpenOriginal: isImageItem(ctxMenu.item)
|
|
11935
12300
|
? () => { openViewerByItem(ctxMenu.item, true) }
|
|
11936
12301
|
: undefined,
|
|
11937
|
-
onHide: () => {
|
|
12302
|
+
onHide: () => {
|
|
12303
|
+
const curRel = String(ctxMenu.item?.relPath ?? '')
|
|
12304
|
+
// 批量模式下右键已选中的卡片:隐藏整批,而不是只隐藏这一张
|
|
12305
|
+
void doHide(selected.size > 1 && selected.has(curRel) ? [...selected] : [ctxMenu.item])
|
|
12306
|
+
},
|
|
12307
|
+
hideLabel: selected.size > 1 && selected.has(String(ctxMenu.item?.relPath ?? ''))
|
|
12308
|
+
? format(t('ctxHideSelected'), { n: selected.size })
|
|
12309
|
+
: undefined,
|
|
11938
12310
|
onReveal: () => { void doReveal(ctxMenu.item) },
|
|
11939
12311
|
// v0.17.0:【写进输入框】而不是复制到剪贴板 —— 少一步粘贴。
|
|
11940
12312
|
// 写不进 composer 时自动退回剪贴板(见 writeAssetToComposer)。
|
|
11941
12313
|
onCopy: () => { writeAssetToComposer(ctxMenu.item, ctxMenu.absPath) },
|
|
11942
12314
|
// v0.16.0 单文件复制:写系统剪贴板文件列表,可在别的对话粘贴
|
|
11943
|
-
|
|
11944
|
-
|
|
12315
|
+
// 2026-11-25:批量选中时右键已选卡片 = 复制整批(与删除 / 隐藏同口径)
|
|
12316
|
+
onCopyFile: () => {
|
|
12317
|
+
const curRel = String(ctxMenu.item?.relPath ?? '')
|
|
12318
|
+
void doCopyAssets(selected.size > 1 && selected.has(curRel) ? [...selected] : [curRel])
|
|
12319
|
+
},
|
|
12320
|
+
copyFileLabel: selected.size > 1 && selected.has(String(ctxMenu.item?.relPath ?? ''))
|
|
12321
|
+
? format(t('ctxCopyFileSelected'), { n: selected.size })
|
|
12322
|
+
: undefined,
|
|
12323
|
+
onDelete: () => {
|
|
12324
|
+
const curRel = String(ctxMenu.item?.relPath ?? '')
|
|
12325
|
+
// 批量模式下右键已选中的卡片:删整批,而不是只删这一张
|
|
12326
|
+
const rels = selected.size > 1 && selected.has(curRel) ? [...selected] : [curRel]
|
|
12327
|
+
setDeleteTarget({ items: itemsForRelPaths(rels), busy: false })
|
|
12328
|
+
},
|
|
12329
|
+
deleteLabel: selected.size > 1 && selected.has(String(ctxMenu.item?.relPath ?? ''))
|
|
12330
|
+
? format(t('ctxDeleteSelected'), { n: selected.size })
|
|
12331
|
+
: undefined,
|
|
11945
12332
|
// v0.16.0:列表级粘贴(右键任意卡片也出现)
|
|
11946
12333
|
onPaste: () => { void doPaste() },
|
|
11947
12334
|
// v0.14.2:改标签 / 恢复自动,表态层已下线
|
|
11948
12335
|
onEditLabel: () => {
|
|
11949
12336
|
const target = ctxMenu.item
|
|
12337
|
+
const curRel = String(target?.relPath ?? '')
|
|
11950
12338
|
closeContextMenu()
|
|
11951
|
-
|
|
12339
|
+
// 2026-11-25:批量选中时改标签 = 改整批
|
|
12340
|
+
if (selected.size > 1 && selected.has(curRel)) openBatchLabelDialog()
|
|
12341
|
+
else openLabelDialog(target)
|
|
11952
12342
|
},
|
|
12343
|
+
editLabelLabel: selected.size > 1 && selected.has(String(ctxMenu.item?.relPath ?? ''))
|
|
12344
|
+
? format(t('labelEditSelected'), { n: selected.size })
|
|
12345
|
+
: undefined,
|
|
11953
12346
|
...(manualLabelOf(ctxMenu.item.relPath) !== null
|
|
11954
12347
|
? {
|
|
11955
12348
|
onResetLabel: () => {
|
|
@@ -11985,12 +12378,25 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
11985
12378
|
: null
|
|
11986
12379
|
|
|
11987
12380
|
// 删除确认弹窗
|
|
12381
|
+
const deleteItems = deleteTarget === null
|
|
12382
|
+
? []
|
|
12383
|
+
: (Array.isArray(deleteTarget.items) ? deleteTarget.items : [])
|
|
12384
|
+
const deleteMany = deleteItems.length > 1
|
|
11988
12385
|
const confirmLayer = deleteTarget !== null
|
|
11989
12386
|
? h(ConfirmDialog, {
|
|
11990
12387
|
key: 'confirmLayer',
|
|
11991
12388
|
t,
|
|
11992
|
-
|
|
12389
|
+
title: deleteMany ? format(t('ctxDeleteManyTitle'), { n: deleteItems.length }) : undefined,
|
|
12390
|
+
name: deleteMany
|
|
12391
|
+
? format(t('ctxDeleteManySummary'), { n: deleteItems.length })
|
|
12392
|
+
: String(deleteItems[0]?.name ?? ''),
|
|
12393
|
+
files: deleteMany
|
|
12394
|
+
? deleteItems.map((it) => String(it?.name ?? it?.relPath ?? ''))
|
|
12395
|
+
: undefined,
|
|
11993
12396
|
busy: deleteTarget.busy === true,
|
|
12397
|
+
warn: deleteItems.some((it) => it?.inherited === true)
|
|
12398
|
+
? t('inheritedDeleteWarn')
|
|
12399
|
+
: (deleteItems.some((it) => it?.shared === true) ? t('sharedDeleteWarn') : null),
|
|
11994
12400
|
onCancel: () => setDeleteTarget(null),
|
|
11995
12401
|
onConfirm: () => { void doDelete() },
|
|
11996
12402
|
})
|