dsh-gallery 0.13.6 → 0.14.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 +138 -0
- package/README.md +82 -16
- package/client.js +953 -43
- package/host/http.js +188 -1
- package/host/marks.js +28 -0
- package/host/protocol.js +57 -0
- package/package.json +9 -3
package/client.js
CHANGED
|
@@ -30,6 +30,63 @@ const VIDEO_EXTS = ['.mp4', '.webm', '.mov', '.m4v', '.mkv', '.avi', '.ogv']
|
|
|
30
30
|
/** 音频扩展名。 */
|
|
31
31
|
const AUDIO_EXTS = ['.mp3', '.wav', '.m4a', '.aac', '.flac', '.ogg', '.oga', '.opus', '.wma']
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* 框选批注的坐标契约(v0.14.0)—— Host 与 Client 的唯一真源。
|
|
35
|
+
*
|
|
36
|
+
* 为什么用归一化坐标:批注要落在「图片的某个位置」上,而不是「屏幕上某个像素」。
|
|
37
|
+
* 写像素值的话,换个窗口尺寸 / 换个缩放比例就全错了。
|
|
38
|
+
* 用相对宽高的 0–1 比例,无论怎么缩放都能还原到同一块区域。
|
|
39
|
+
*
|
|
40
|
+
* 形状类型:
|
|
41
|
+
* rect —— 矩形框(最主要,圈出「这块不对」)
|
|
42
|
+
* arrow —— 箭头(指向具体某点)
|
|
43
|
+
* text —— 纯文字标注(钉在某位置,不带框)
|
|
44
|
+
*/
|
|
45
|
+
const ANNOTATION_SHAPES = ["rect", "arrow", "text"]
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 一条批注的数据形态:
|
|
49
|
+
* {
|
|
50
|
+
* id: string, // 稳定 id(同一次会话内唯一)
|
|
51
|
+
* shape: "rect|arrow|text",
|
|
52
|
+
* x: number, y: number, // 起点,归一化 0–1
|
|
53
|
+
* w: number, h: number, // 宽高,归一化 0–1(text/arrow 可只用 x,y)
|
|
54
|
+
* note: string, // 人写的说明(可为空)
|
|
55
|
+
* frameMs: number|null, // 视频帧时间(图片为 null)
|
|
56
|
+
* }
|
|
57
|
+
*
|
|
58
|
+
* 约束:x/y/w/h 必须落在 [0,1];越界由写入端 clamp。
|
|
59
|
+
*/
|
|
60
|
+
const ANNOTATION_LIMITS = { min: 0, max: 1, maxNoteLength: 500, maxPerAsset: 50 }
|
|
61
|
+
|
|
62
|
+
/** 把任意数值 clamp 到 [0,1](批注坐标写入前必须过一遍)。 */
|
|
63
|
+
function clamp01(v) {
|
|
64
|
+
const n = Number(v)
|
|
65
|
+
if (!Number.isFinite(n)) return 0
|
|
66
|
+
if (n < 0) return 0
|
|
67
|
+
if (n > 1) return 1
|
|
68
|
+
return n
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** 校验并规整一条批注;不合法返回 null。 */
|
|
72
|
+
function normalizeAnnotation(a) {
|
|
73
|
+
if (a === null || typeof a !== "object") return null
|
|
74
|
+
const shape = ANNOTATION_SHAPES.includes(a.shape) ? a.shape : "rect"
|
|
75
|
+
const note = typeof a.note === "string" ? a.note.slice(0, ANNOTATION_LIMITS.maxNoteLength) : ""
|
|
76
|
+
const x = clamp01(a.x)
|
|
77
|
+
const y = clamp01(a.y)
|
|
78
|
+
let w = clamp01(a.w)
|
|
79
|
+
let h = clamp01(a.h)
|
|
80
|
+
// 宽高至少留一点,且不越过右/下边界
|
|
81
|
+
if (w > 0 && x + w > 1) w = 1 - x
|
|
82
|
+
if (h > 0 && y + h > 1) h = 1 - y
|
|
83
|
+
const frameMs = Number.isFinite(a.frameMs) ? Math.max(0, Math.floor(a.frameMs)) : null
|
|
84
|
+
return {
|
|
85
|
+
id: typeof a.id === "string" && a.id !== "" ? a.id : ("a" + Math.random().toString(36).slice(2, 10)),
|
|
86
|
+
shape, x, y, w, h, note, frameMs,
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
33
90
|
|
|
34
91
|
/** tab 类型的身份;也是正文与标题在 keyed slot 里的 key。 */
|
|
35
92
|
const KIND = 'gallery'
|
|
@@ -109,6 +166,44 @@ const AUDIO_EXTS = ['.mp3', '.wav', '.m4a', '.aac', '.flac', '.ogg', '.oga', '.o
|
|
|
109
166
|
catLegendInput: '输入素材',
|
|
110
167
|
catLegendIntermediate: '中间产物',
|
|
111
168
|
catLegendUnknown: '未归类',
|
|
169
|
+
annotEnter: '标注',
|
|
170
|
+
annotExit: '退出标注',
|
|
171
|
+
annotNotePrompt: '这块要改什么?(可留空)',
|
|
172
|
+
annotNotePlaceholder: '例如:沙发位置偏了 / 色调太暖',
|
|
173
|
+
annotNoNote: '(无说明)',
|
|
174
|
+
annotHint: '拖拽画框标出要改的位置,说明会写进决策草稿',
|
|
175
|
+
annotCount: '批注 {n} 处',
|
|
176
|
+
catFilterFinalConfirmed: '最终交付·已确认',
|
|
177
|
+
catFilterFinalPending: '最终交付·待确认',
|
|
178
|
+
filterShowHint: '点击显示「{label}」',
|
|
179
|
+
filterHideHint: '点击隐藏「{label}」',
|
|
180
|
+
confirmBadgeLabel: '已确认',
|
|
181
|
+
confirmBadgeHint: '这张已定为最终版(判断已锁住,刷新/重启都保留)',
|
|
182
|
+
batchSelect: '选中以批量处理',
|
|
183
|
+
batchUnselect: '取消选中',
|
|
184
|
+
batchBarTitle: '已选 {n} 个',
|
|
185
|
+
batchConfirm: '确认',
|
|
186
|
+
batchUnconfirm: '取消确认',
|
|
187
|
+
batchClearMark: '清除标记',
|
|
188
|
+
batchClearSelection: '取消选择',
|
|
189
|
+
batchHintConfirm: '把选中卡片标为「已确认」(只改标记,不碰文件)',
|
|
190
|
+
batchHintClearMark: '清掉选中卡片的标记(只改标记,不碰文件)',
|
|
191
|
+
discardEntry: '清掉废稿({n})',
|
|
192
|
+
discardEntryHint: '删除所有标过「不要这张」的文件 —— 永久删除,不进回收站',
|
|
193
|
+
discardDialogTitle: '确认删除废稿',
|
|
194
|
+
discardDialogWarn: '以下文件将被永久删除,不进回收站,删除后无法恢复。',
|
|
195
|
+
discardDialogCount: '共 {n} 个文件',
|
|
196
|
+
discardDialogTooMany: '单批最多 10 个,当前 {n} 个。请分批处理。',
|
|
197
|
+
discardDialogConfirm: '永久删除这 {n} 个文件',
|
|
198
|
+
discardDialogCancel: '取消',
|
|
199
|
+
discardDialogDeleting: '正在删除…',
|
|
200
|
+
discardDone: '已永久删除 {n} 个文件',
|
|
201
|
+
discardFailed: '删除失败:{msg}',
|
|
202
|
+
discardDigestMismatch: '文件清单已变化,请重新确认',
|
|
203
|
+
scanModeEnter: '批量选择',
|
|
204
|
+
scanModeExit: '退出批量',
|
|
205
|
+
shownOfTotal: '已显示 {shown} / 共 {total}',
|
|
206
|
+
|
|
112
207
|
catLegendHint: '边框颜色代表资产类型;「未归类」是会话记录里查不到归属的历史文件',
|
|
113
208
|
// ===== 全局按对话分组 =====
|
|
114
209
|
groupCount: '{count} 个',
|
|
@@ -192,6 +287,7 @@ const AUDIO_EXTS = ['.mp3', '.wav', '.m4a', '.aac', '.flac', '.ogg', '.oga', '.o
|
|
|
192
287
|
ctxMarkApprove: '通过',
|
|
193
288
|
ctxMarkReject: '不要这张',
|
|
194
289
|
ctxMarkFinalize: '定为最终版',
|
|
290
|
+
ctxMarkUnconfirm: '取消确认',
|
|
195
291
|
ctxMarkRedo: '单维重做',
|
|
196
292
|
ctxMarkRegen: '选择性重生成',
|
|
197
293
|
ctxMarkReference: '设为参照',
|
|
@@ -312,6 +408,44 @@ const AUDIO_EXTS = ['.mp3', '.wav', '.m4a', '.aac', '.flac', '.ogg', '.oga', '.o
|
|
|
312
408
|
catLegendInput: 'Input material',
|
|
313
409
|
catLegendIntermediate: 'Interim product',
|
|
314
410
|
catLegendUnknown: 'Unclassified',
|
|
411
|
+
annotEnter: 'Annotate',
|
|
412
|
+
annotExit: 'Exit annotate',
|
|
413
|
+
annotNotePrompt: 'What should change here? (optional)',
|
|
414
|
+
annotNotePlaceholder: 'e.g. sofa position is off / color is too warm',
|
|
415
|
+
annotNoNote: '(no note)',
|
|
416
|
+
annotHint: 'Drag to box the area that needs changes; notes go into the decision draft',
|
|
417
|
+
annotCount: '{n} annotation(s)',
|
|
418
|
+
catFilterFinalConfirmed: 'Final · confirmed',
|
|
419
|
+
catFilterFinalPending: 'Final · pending',
|
|
420
|
+
filterShowHint: 'Click to show "{label}"',
|
|
421
|
+
filterHideHint: 'Click to hide "{label}"',
|
|
422
|
+
confirmBadgeLabel: 'Confirmed',
|
|
423
|
+
confirmBadgeHint: 'Marked as final (the decision is persisted across refresh and restart)',
|
|
424
|
+
batchSelect: 'Select for batch actions',
|
|
425
|
+
batchUnselect: 'Deselect',
|
|
426
|
+
batchBarTitle: '{n} selected',
|
|
427
|
+
batchConfirm: 'Confirm',
|
|
428
|
+
batchUnconfirm: 'Unconfirm',
|
|
429
|
+
batchClearMark: 'Clear marks',
|
|
430
|
+
batchClearSelection: 'Clear selection',
|
|
431
|
+
batchHintConfirm: 'Mark selected cards as confirmed (marks only, files untouched)',
|
|
432
|
+
batchHintClearMark: 'Clear marks on selected cards (marks only, files untouched)',
|
|
433
|
+
discardEntry: 'Delete discarded ({n})',
|
|
434
|
+
discardEntryHint: 'Permanently delete every file marked "reject" — bypasses the recycle bin',
|
|
435
|
+
discardDialogTitle: 'Confirm deleting discarded files',
|
|
436
|
+
discardDialogWarn: 'These files will be permanently deleted. They do not go to the recycle bin and cannot be restored.',
|
|
437
|
+
discardDialogCount: '{n} file(s)',
|
|
438
|
+
discardDialogTooMany: 'At most 10 per batch; you have {n}. Please process in batches.',
|
|
439
|
+
discardDialogConfirm: 'Permanently delete these {n} files',
|
|
440
|
+
discardDialogCancel: 'Cancel',
|
|
441
|
+
discardDialogDeleting: 'Deleting…',
|
|
442
|
+
discardDone: 'Permanently deleted {n} file(s)',
|
|
443
|
+
discardFailed: 'Delete failed: {msg}',
|
|
444
|
+
discardDigestMismatch: 'The file list changed; please confirm again',
|
|
445
|
+
scanModeEnter: 'Select',
|
|
446
|
+
scanModeExit: 'Exit selection',
|
|
447
|
+
shownOfTotal: '{shown} of {total} shown',
|
|
448
|
+
|
|
315
449
|
catLegendHint: 'Border color shows the asset type; “Unclassified” means the session logs have no record of it',
|
|
316
450
|
// Grouped by conversation (global view)
|
|
317
451
|
groupCount: '{count} files',
|
|
@@ -393,6 +527,7 @@ const AUDIO_EXTS = ['.mp3', '.wav', '.m4a', '.aac', '.flac', '.ogg', '.oga', '.o
|
|
|
393
527
|
ctxMarkApprove: 'Approve',
|
|
394
528
|
ctxMarkReject: 'Reject',
|
|
395
529
|
ctxMarkFinalize: 'Finalize',
|
|
530
|
+
ctxMarkUnconfirm: 'Unconfirm',
|
|
396
531
|
ctxMarkRedo: 'Redo one dimension',
|
|
397
532
|
ctxMarkRegen: 'Regenerate selection',
|
|
398
533
|
ctxMarkReference: 'Set as reference',
|
|
@@ -1764,6 +1899,116 @@ const AUDIO_EXTS = ['.mp3', '.wav', '.m4a', '.aac', '.flac', '.ogg', '.oga', '.o
|
|
|
1764
1899
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
|
|
1765
1900
|
}
|
|
1766
1901
|
.dg-basketToggle[data-gallery-basket-count="0"] { color: #a9b1bd; }
|
|
1902
|
+
|
|
1903
|
+
/* ---------- v0.13.7:分类开关 / 确认角标 / 批量 / 删除对话框 ---------- */
|
|
1904
|
+
|
|
1905
|
+
/* 分类开关(原 legend,现可点) */
|
|
1906
|
+
.dg-legendToggle {
|
|
1907
|
+
appearance: none; border: 1px solid transparent; background: transparent;
|
|
1908
|
+
cursor: pointer; padding: 2px 6px; border-radius: 5px;
|
|
1909
|
+
font: inherit; color: inherit;
|
|
1910
|
+
display: inline-flex; align-items: center; gap: 5px;
|
|
1911
|
+
}
|
|
1912
|
+
.dg-legendToggle:hover { border-color: rgba(255, 255, 255, 0.18); background: rgba(255, 255, 255, 0.06); }
|
|
1913
|
+
.dg-legendToggle.dg-legendOff { opacity: 0.42; }
|
|
1914
|
+
.dg-legendToggle.dg-legendOff .dg-legendSwatch { filter: grayscale(1); }
|
|
1915
|
+
.dg-legendCount { font-size: 11px; color: #a9b1bd; margin-left: 2px; }
|
|
1916
|
+
.dg-legendSwatchPending { opacity: 0.55; border-style: dashed !important; }
|
|
1917
|
+
|
|
1918
|
+
/* 卡片包装层 + 确认角标 + 多选框 */
|
|
1919
|
+
.dg-cardWrap { position: relative; }
|
|
1920
|
+
.dg-cardConfirmed > :first-child { outline: 2px solid #4a9d5f; outline-offset: -2px; }
|
|
1921
|
+
.dg-cardChecked > :first-child { outline: 2px solid #4a7cff; outline-offset: -2px; }
|
|
1922
|
+
.dg-confirmBadge {
|
|
1923
|
+
position: absolute; top: 6px; left: 6px; z-index: 3;
|
|
1924
|
+
display: inline-flex; align-items: center; gap: 3px;
|
|
1925
|
+
padding: 1px 6px; border-radius: 9px;
|
|
1926
|
+
background: #4a9d5f; color: #fff; font-size: 10px; font-weight: 600;
|
|
1927
|
+
pointer-events: none; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
|
|
1928
|
+
}
|
|
1929
|
+
.dg-cardCheck {
|
|
1930
|
+
position: absolute; top: 6px; right: 6px; z-index: 4;
|
|
1931
|
+
width: 20px; height: 20px; border-radius: 4px;
|
|
1932
|
+
border: 1.5px solid rgba(255, 255, 255, 0.65);
|
|
1933
|
+
background: rgba(0, 0, 0, 0.45); color: #fff;
|
|
1934
|
+
font-size: 12px; line-height: 1; cursor: pointer;
|
|
1935
|
+
display: flex; align-items: center; justify-content: center;
|
|
1936
|
+
}
|
|
1937
|
+
.dg-cardCheck:hover { border-color: #fff; background: rgba(0, 0, 0, 0.7); }
|
|
1938
|
+
.dg-cardCheckOn { background: #4a7cff; border-color: #4a7cff; }
|
|
1939
|
+
|
|
1940
|
+
/* 批量操作条 */
|
|
1941
|
+
.dg-batchBar {
|
|
1942
|
+
display: flex; align-items: center; justify-content: space-between; gap: 10px;
|
|
1943
|
+
padding: 6px 10px; margin: 0 0 6px;
|
|
1944
|
+
background: rgba(74, 124, 255, 0.14);
|
|
1945
|
+
border: 1px solid rgba(74, 124, 255, 0.35); border-radius: 6px;
|
|
1946
|
+
font-size: 12px;
|
|
1947
|
+
}
|
|
1948
|
+
.dg-batchCount { font-weight: 600; color: #a9c2ff; white-space: nowrap; }
|
|
1949
|
+
.dg-batchOps { display: flex; gap: 6px; flex-wrap: wrap; }
|
|
1950
|
+
|
|
1951
|
+
/* 危险动作按钮(清掉废稿) */
|
|
1952
|
+
.dg-dangerBtn { border-color: rgba(220, 80, 80, 0.55) !important; color: #ff9c9c !important; }
|
|
1953
|
+
.dg-dangerBtn:hover:not(:disabled) { background: rgba(220, 80, 80, 0.18) !important; border-color: #ff9c9c !important; }
|
|
1954
|
+
.dg-dangerText { color: #ff9c9c; font-size: 12px; font-weight: 600; }
|
|
1955
|
+
|
|
1956
|
+
/* 删除确认对话框 */
|
|
1957
|
+
.dg-modalLayer {
|
|
1958
|
+
position: fixed; inset: 0; z-index: 80;
|
|
1959
|
+
display: flex; align-items: center; justify-content: center;
|
|
1960
|
+
background: rgba(0, 0, 0, 0.66);
|
|
1961
|
+
}
|
|
1962
|
+
.dg-modal {
|
|
1963
|
+
width: min(560px, 92vw); max-height: 82vh; display: flex; flex-direction: column;
|
|
1964
|
+
background: #1b1e24; color: #e8eaed;
|
|
1965
|
+
border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 10px; overflow: hidden;
|
|
1966
|
+
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
|
|
1967
|
+
}
|
|
1968
|
+
.dg-modalHead { padding: 12px 14px; font-size: 14px; font-weight: 600; border-bottom: 1px solid rgba(255, 255, 255, 0.1); background: #22262e; }
|
|
1969
|
+
.dg-modalBody { padding: 12px 14px; overflow: auto; flex: 1; font-size: 12px; }
|
|
1970
|
+
.dg-modalSub { color: #a9b1bd; margin: 6px 0; }
|
|
1971
|
+
.dg-modalOps { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 14px; border-top: 1px solid rgba(255, 255, 255, 0.1); background: #22262e; }
|
|
1972
|
+
.dg-discardList { list-style: none; margin: 8px 0 0; padding: 0; max-height: 320px; overflow: auto; border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 6px; }
|
|
1973
|
+
.dg-discardList li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.06); font-family: ui-monospace, Consolas, monospace; font-size: 11px; }
|
|
1974
|
+
.dg-discardList li:last-child { border-bottom: none; }
|
|
1975
|
+
.dg-discardPath { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; }
|
|
1976
|
+
.dg-discardSize { color: #a9b1bd; white-space: nowrap; }
|
|
1977
|
+
|
|
1978
|
+
/* ---------- v0.14.0:框选批注层 ---------- */
|
|
1979
|
+
|
|
1980
|
+
.dg-annotWrap { position: absolute; inset: 0; }
|
|
1981
|
+
.dg-annotSvg { position: absolute; inset: 0; width: 100%; height: 100%; }
|
|
1982
|
+
.dg-annotSvg.dg-annotActive { background: rgba(74, 124, 255, 0.04); }
|
|
1983
|
+
.dg-btnActive { background: #4a7cff !important; color: #fff !important; border-color: #4a7cff !important; }
|
|
1984
|
+
|
|
1985
|
+
/* 批注列表 */
|
|
1986
|
+
.dg-annotList {
|
|
1987
|
+
position: absolute; left: 8px; bottom: 8px; z-index: 5;
|
|
1988
|
+
max-width: 300px; max-height: 40%; overflow: auto;
|
|
1989
|
+
background: rgba(27, 30, 36, 0.95); border: 1px solid rgba(255, 255, 255, 0.16);
|
|
1990
|
+
border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 4px;
|
|
1991
|
+
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
|
|
1992
|
+
}
|
|
1993
|
+
.dg-annotItem { display: flex; align-items: center; gap: 6px; font-size: 11px; color: #e8eaed; }
|
|
1994
|
+
.dg-annotIndex { color: #8fb6ff; font-weight: 600; }
|
|
1995
|
+
.dg-annotText { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1996
|
+
|
|
1997
|
+
/* 批注输入框 */
|
|
1998
|
+
.dg-annotEditor {
|
|
1999
|
+
position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 6;
|
|
2000
|
+
width: min(340px, 80%); background: #1b1e24; color: #e8eaed;
|
|
2001
|
+
border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 8px; padding: 10px;
|
|
2002
|
+
box-shadow: 0 8px 28px rgba(0, 0, 0, 0.6);
|
|
2003
|
+
}
|
|
2004
|
+
.dg-annotEditorHead { font-size: 12px; font-weight: 600; margin-bottom: 8px; }
|
|
2005
|
+
.dg-annotInput {
|
|
2006
|
+
width: 100%; box-sizing: border-box; padding: 6px 8px; border-radius: 5px;
|
|
2007
|
+
border: 1px solid rgba(255, 255, 255, 0.22); background: #2a2f38; color: #e8eaed;
|
|
2008
|
+
font-size: 12px; font-family: inherit;
|
|
2009
|
+
}
|
|
2010
|
+
.dg-annotInput:focus { outline: 2px solid #4a7cff; outline-offset: -1px; }
|
|
2011
|
+
.dg-annotEditorOps { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }
|
|
1767
2012
|
`
|
|
1768
2013
|
|
|
1769
2014
|
|
|
@@ -2629,6 +2874,10 @@ function serializeFeedback(feedback) {
|
|
|
2629
2874
|
actions.onMark !== undefined
|
|
2630
2875
|
? entry('mark-finalize', t('ctxMarkFinalize'), '★', () => actions.onMark('finalize'))
|
|
2631
2876
|
: null,
|
|
2877
|
+
// v0.13.7:已确认的卡片给出「取消确认」,退回待确认
|
|
2878
|
+
actions.onUnconfirm !== undefined && actions.confirmed === true
|
|
2879
|
+
? entry('mark-unconfirm', t('ctxMarkUnconfirm'), '☆', () => actions.onUnconfirm())
|
|
2880
|
+
: null,
|
|
2632
2881
|
actions.onMark !== undefined
|
|
2633
2882
|
? entry('mark-redo', t('ctxMarkRedo'), '↻', () => actions.onMark('redo-one-dim'))
|
|
2634
2883
|
: null,
|
|
@@ -3359,7 +3608,7 @@ ${absPath}
|
|
|
3359
3608
|
* - 右键预览区、按 O、点底部按钮 三种方式切换
|
|
3360
3609
|
* - 切换时**保留当前缩放与位置**,否则切过去跳回 1x 就没法对比
|
|
3361
3610
|
*/
|
|
3362
|
-
function Viewer({ items, index, onClose, onStep, t, initialOriginal }) {
|
|
3611
|
+
function Viewer({ items, index, onClose, onStep, t, initialOriginal, annotations, onAddAnnotation, onRemoveAnnotation }) {
|
|
3363
3612
|
const item = items[index]
|
|
3364
3613
|
// 文件预览已改走 DSH 原生侧栏(session 地址);此处 Viewer 仅处理图片,isText 恒 false,
|
|
3365
3614
|
// 下面的文本分支保留为死代码,供 v0.2 若需插件内预览时复用
|
|
@@ -3586,6 +3835,13 @@ ${absPath}
|
|
|
3586
3835
|
}
|
|
3587
3836
|
}
|
|
3588
3837
|
// 中键按下时阻止浏览器默认的自动滚动
|
|
3838
|
+
/** 批注模式(v0.14.0):开启后指针交给 SVG 标注层,查看器的缩放/拖拽暂停。 */
|
|
3839
|
+
const [annotActive, setAnnotActive] = React.useState(false)
|
|
3840
|
+
const annotsOfCurrent = React.useMemo(
|
|
3841
|
+
() => (typeof annotations === 'function' ? annotations(item) : []),
|
|
3842
|
+
[annotations, item],
|
|
3843
|
+
)
|
|
3844
|
+
|
|
3589
3845
|
const onMouseDown = (event) => {
|
|
3590
3846
|
if (event.button === 1) event.preventDefault()
|
|
3591
3847
|
}
|
|
@@ -3849,6 +4105,19 @@ ${absPath}
|
|
|
3849
4105
|
? format(t('viewerOriginalLoading'), { pct: original.pct })
|
|
3850
4106
|
: t('viewerOriginalLoadingIndeterminate'))
|
|
3851
4107
|
: (originalMode ? `◉ ${t('viewerToPreview')}` : `◎ ${t('viewerToOriginal')}`)),
|
|
4108
|
+
// v0.14.0:批注模式开关
|
|
4109
|
+
h('button', {
|
|
4110
|
+
type: 'button',
|
|
4111
|
+
className: `dg-btn${annotActive ? ' dg-btnActive' : ''}`,
|
|
4112
|
+
key: 'annot',
|
|
4113
|
+
'data-gallery-annot-toggle': true,
|
|
4114
|
+
'aria-pressed': annotActive,
|
|
4115
|
+
title: annotActive ? t('annotExit') : t('annotEnter'),
|
|
4116
|
+
onClick: (event) => {
|
|
4117
|
+
event.stopPropagation()
|
|
4118
|
+
setAnnotActive((v) => !v)
|
|
4119
|
+
},
|
|
4120
|
+
}, annotActive ? `✎ ${t('annotExit')}` : `✎ ${t('annotEnter')}`),
|
|
3852
4121
|
h('button', { type: 'button', className: 'dg-btn', key: 'prev', onClick: () => onStep(-1), 'aria-label': t('prev') }, '‹'),
|
|
3853
4122
|
h('button', { type: 'button', className: 'dg-btn', key: 'next', onClick: () => onStep(1), 'aria-label': t('next') }, '›'),
|
|
3854
4123
|
h('button', { type: 'button', className: 'dg-btn', key: 'close', onClick: onClose, 'aria-label': t('close') }, '✕'),
|
|
@@ -3884,20 +4153,35 @@ ${absPath}
|
|
|
3884
4153
|
state.status === 'ready'
|
|
3885
4154
|
? (isText
|
|
3886
4155
|
? h('pre', { className: 'dg-textPre', key: 'text' }, state.text)
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
4156
|
+
// v0.14.0:图片 + 框选批注层(Fragment 包住,批注层覆盖在图上)
|
|
4157
|
+
: h(React.Fragment, { key: 'imgfrag' }, [
|
|
4158
|
+
h('img', {
|
|
4159
|
+
key: 'img',
|
|
4160
|
+
// 原图模式下显示原图 URL(按需加载好后才有);
|
|
4161
|
+
// 未就绪时继续显示预览图,避免黑屏跳变
|
|
4162
|
+
src: originalMode && original.status === 'ready' ? original.url : state.url,
|
|
4163
|
+
alt: item.name,
|
|
4164
|
+
decoding: 'async',
|
|
4165
|
+
draggable: false,
|
|
4166
|
+
style: {
|
|
4167
|
+
transform: `translate(${pan.x}px, ${pan.y}px) scale(${zoom})`,
|
|
4168
|
+
transition: dragRef.current === null ? 'transform 120ms ease-out' : 'none',
|
|
4169
|
+
userSelect: 'none',
|
|
4170
|
+
pointerEvents: 'none',
|
|
4171
|
+
},
|
|
4172
|
+
}),
|
|
4173
|
+
// 批注层:只在图片(非文本)时出现,且随 zoom 一起变换
|
|
4174
|
+
h(AnnotationLayer, {
|
|
4175
|
+
key: 'annot',
|
|
4176
|
+
t,
|
|
4177
|
+
annotations: annotsOfCurrent,
|
|
4178
|
+
active: annotActive,
|
|
4179
|
+
frameMs: null,
|
|
4180
|
+
stageRef: bodyRef,
|
|
4181
|
+
onAdd: (a) => { onAddAnnotation?.(item, a) },
|
|
4182
|
+
onRemove: (id) => { onRemoveAnnotation?.(item, id) },
|
|
4183
|
+
}),
|
|
4184
|
+
]))
|
|
3901
4185
|
: state.status === 'binary'
|
|
3902
4186
|
? h('div', { className: 'dg-placeholder', key: 'bin' }, t('binaryHint'))
|
|
3903
4187
|
: h('div', { className: state.status === 'failed' ? 'dg-placeholder dg-error' : 'dg-placeholder' },
|
|
@@ -3929,6 +4213,193 @@ ${absPath}
|
|
|
3929
4213
|
* 也可以点「恢复默认」,回到自动探测的结果。
|
|
3930
4214
|
*/
|
|
3931
4215
|
|
|
4216
|
+
/**
|
|
4217
|
+
* 框选批注层(v0.14.0)—— 在查看器图片上圈出「哪儿不对」。
|
|
4218
|
+
*
|
|
4219
|
+
* 设计要点:
|
|
4220
|
+
* · 坐标全部归一化(0–1,相对图片宽高),见 shared/protocol.js 的 ANNOTATION_* 契约
|
|
4221
|
+
* · SVG 覆盖在图片之上;不干扰查看器原有的缩放/平移(只有「批注模式」下才接管指针)
|
|
4222
|
+
* · 拖拽画矩形 → 立刻弹出输入框写说明 → 存进批注列表
|
|
4223
|
+
* · 已存在的批注按归一化坐标还原绘制,缩放/换屏都不失真
|
|
4224
|
+
* · 批注不发送任何东西;出口是与决策草稿同一通道(见 05-feedback.js)
|
|
4225
|
+
*/
|
|
4226
|
+
|
|
4227
|
+
function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, stageRef }) {
|
|
4228
|
+
const [draft, setDraft] = React.useState(null)
|
|
4229
|
+
const [editing, setEditing] = React.useState(null)
|
|
4230
|
+
const svgRef = React.useRef(null)
|
|
4231
|
+
|
|
4232
|
+
/** 客户坐标 → 归一化(相对 SVG 的实际渲染盒) */
|
|
4233
|
+
const toNorm = (event) => {
|
|
4234
|
+
const el = svgRef.current
|
|
4235
|
+
if (el === null) return null
|
|
4236
|
+
const rect = el.getBoundingClientRect()
|
|
4237
|
+
if (rect.width === 0 || rect.height === 0) return null
|
|
4238
|
+
return {
|
|
4239
|
+
x: clamp01((event.clientX - rect.left) / rect.width),
|
|
4240
|
+
y: clamp01((event.clientY - rect.top) / rect.height),
|
|
4241
|
+
}
|
|
4242
|
+
}
|
|
4243
|
+
|
|
4244
|
+
const onPointerDown = (event) => {
|
|
4245
|
+
if (!active) return
|
|
4246
|
+
// 只响应主键;左键拖拽画框
|
|
4247
|
+
if (event.button !== 0) return
|
|
4248
|
+
const p = toNorm(event)
|
|
4249
|
+
if (p === null) return
|
|
4250
|
+
event.preventDefault()
|
|
4251
|
+
event.stopPropagation()
|
|
4252
|
+
try { event.currentTarget.setPointerCapture(event.pointerId) } catch { /* 忽略 */ }
|
|
4253
|
+
setDraft({ x0: p.x, y0: p.y, x1: p.x, y1: p.y })
|
|
4254
|
+
}
|
|
4255
|
+
|
|
4256
|
+
const onPointerMove = (event) => {
|
|
4257
|
+
if (draft === null) return
|
|
4258
|
+
const p = toNorm(event)
|
|
4259
|
+
if (p === null) return
|
|
4260
|
+
event.preventDefault()
|
|
4261
|
+
event.stopPropagation()
|
|
4262
|
+
setDraft((d) => (d === null ? null : { ...d, x1: p.x, y1: p.y }))
|
|
4263
|
+
}
|
|
4264
|
+
|
|
4265
|
+
const finishDraft = (event) => {
|
|
4266
|
+
if (draft === null) return
|
|
4267
|
+
event.preventDefault()
|
|
4268
|
+
event.stopPropagation()
|
|
4269
|
+
const x = Math.min(draft.x0, draft.x1)
|
|
4270
|
+
const y = Math.min(draft.y0, draft.y1)
|
|
4271
|
+
const w = Math.abs(draft.x1 - draft.x0)
|
|
4272
|
+
const h = Math.abs(draft.y1 - draft.y0)
|
|
4273
|
+
setDraft(null)
|
|
4274
|
+
// 太小当成误点,不产生批注(避免满屏碎框)
|
|
4275
|
+
if (w < 0.01 || h < 0.01) return
|
|
4276
|
+
setEditing({ shape: 'rect', x, y, w, h, note: '', frameMs: frameMs ?? null })
|
|
4277
|
+
}
|
|
4278
|
+
|
|
4279
|
+
const saveEditing = () => {
|
|
4280
|
+
if (editing === null) return
|
|
4281
|
+
const normalized = normalizeAnnotation(editing)
|
|
4282
|
+
if (normalized !== null) onAdd(normalized)
|
|
4283
|
+
setEditing(null)
|
|
4284
|
+
}
|
|
4285
|
+
|
|
4286
|
+
// ---- 绘制已有批注 ----
|
|
4287
|
+
const shapes = (annotations ?? []).map((a) => {
|
|
4288
|
+
if (a.shape === 'text') {
|
|
4289
|
+
return h('g', { key: a.id }, [
|
|
4290
|
+
h('circle', {
|
|
4291
|
+
key: 'dot', cx: (a.x * 100) + '%', cy: (a.y * 100) + '%', r: 4,
|
|
4292
|
+
fill: '#ffd166', stroke: '#000', strokeWidth: 1,
|
|
4293
|
+
}),
|
|
4294
|
+
h('text', {
|
|
4295
|
+
key: 'txt', x: (a.x * 100) + '%', y: (a.y * 100) + '%',
|
|
4296
|
+
dx: 8, dy: 4, fill: '#fff', fontSize: 12, stroke: '#000', strokeWidth: 0.6,
|
|
4297
|
+
style: { paintOrder: 'stroke' },
|
|
4298
|
+
}, a.note || ''),
|
|
4299
|
+
])
|
|
4300
|
+
}
|
|
4301
|
+
// rect / arrow 都先按矩形画(arrow 后续可细化),带说明文字
|
|
4302
|
+
return h('g', { key: a.id }, [
|
|
4303
|
+
h('rect', {
|
|
4304
|
+
key: 'r',
|
|
4305
|
+
x: (a.x * 100) + '%', y: (a.y * 100) + '%',
|
|
4306
|
+
width: (a.w * 100) + '%', height: (a.h * 100) + '%',
|
|
4307
|
+
fill: 'rgba(74, 124, 255, 0.14)', stroke: '#4a7cff', strokeWidth: 2,
|
|
4308
|
+
rx: 3,
|
|
4309
|
+
}),
|
|
4310
|
+
a.note !== ''
|
|
4311
|
+
? h('text', {
|
|
4312
|
+
key: 'n',
|
|
4313
|
+
x: (a.x * 100) + '%', y: (a.y * 100) + '%',
|
|
4314
|
+
dx: 4, dy: -6, fill: '#fff', fontSize: 12, stroke: '#000', strokeWidth: 0.6,
|
|
4315
|
+
style: { paintOrder: 'stroke' },
|
|
4316
|
+
}, a.note)
|
|
4317
|
+
: null,
|
|
4318
|
+
])
|
|
4319
|
+
})
|
|
4320
|
+
|
|
4321
|
+
// ---- 正在画的框 ----
|
|
4322
|
+
const draftShape = draft === null ? null : (() => {
|
|
4323
|
+
const x = Math.min(draft.x0, draft.x1)
|
|
4324
|
+
const y = Math.min(draft.y0, draft.y1)
|
|
4325
|
+
const w = Math.abs(draft.x1 - draft.x0)
|
|
4326
|
+
const h = Math.abs(draft.y1 - draft.y0)
|
|
4327
|
+
return h('rect', {
|
|
4328
|
+
key: 'draft',
|
|
4329
|
+
x: (x * 100) + '%', y: (y * 100) + '%',
|
|
4330
|
+
width: (w * 100) + '%', height: (h * 100) + '%',
|
|
4331
|
+
fill: 'rgba(74, 124, 255, 0.22)', stroke: '#4a7cff', strokeWidth: 2, strokeDasharray: '5 3',
|
|
4332
|
+
})
|
|
4333
|
+
})()
|
|
4334
|
+
|
|
4335
|
+
const editor = editing === null ? null : h('div', {
|
|
4336
|
+
className: 'dg-annotEditor',
|
|
4337
|
+
key: 'editor',
|
|
4338
|
+
'data-gallery-annot-editor': true,
|
|
4339
|
+
}, [
|
|
4340
|
+
h('div', { className: 'dg-annotEditorHead', key: 'h' }, t('annotNotePrompt')),
|
|
4341
|
+
h('input', {
|
|
4342
|
+
type: 'text',
|
|
4343
|
+
key: 'inp',
|
|
4344
|
+
className: 'dg-annotInput',
|
|
4345
|
+
'data-gallery-annot-input': true,
|
|
4346
|
+
autoFocus: true,
|
|
4347
|
+
placeholder: t('annotNotePlaceholder'),
|
|
4348
|
+
value: editing.note,
|
|
4349
|
+
maxLength: 500,
|
|
4350
|
+
onChange: (e) => setEditing((cur) => (cur === null ? null : { ...cur, note: e.target.value })),
|
|
4351
|
+
onKeyDown: (e) => {
|
|
4352
|
+
if (e.key === 'Enter') { e.preventDefault(); saveEditing() }
|
|
4353
|
+
if (e.key === 'Escape') { e.preventDefault(); setEditing(null) }
|
|
4354
|
+
},
|
|
4355
|
+
}),
|
|
4356
|
+
h('div', { className: 'dg-annotEditorOps', key: 'o' }, [
|
|
4357
|
+
h('button', { type: 'button', className: 'dg-btn dg-btnSmall', key: 'c', onClick: () => setEditing(null) }, t('cancel')),
|
|
4358
|
+
h('button', {
|
|
4359
|
+
type: 'button', className: 'dg-btn dg-btnSmall dg-primaryBtn', key: 's',
|
|
4360
|
+
'data-gallery-annot-save': true, onClick: saveEditing,
|
|
4361
|
+
}, t('save')),
|
|
4362
|
+
]),
|
|
4363
|
+
])
|
|
4364
|
+
|
|
4365
|
+
const list = (annotations ?? []).length === 0 ? null : h('div', {
|
|
4366
|
+
className: 'dg-annotList', key: 'list', 'data-gallery-annot-list': true,
|
|
4367
|
+
}, (annotations ?? []).map((a) => h('div', {
|
|
4368
|
+
className: 'dg-annotItem', key: a.id, 'data-gallery-annot-id': a.id,
|
|
4369
|
+
}, [
|
|
4370
|
+
h('span', { className: 'dg-annotIndex', key: 'i' }, '#'),
|
|
4371
|
+
h('span', { className: 'dg-annotText', key: 't' }, a.note || t('annotNoNote')),
|
|
4372
|
+
h('button', {
|
|
4373
|
+
type: 'button', className: 'dg-btn dg-btnSmall dg-btnIcon', key: 'x',
|
|
4374
|
+
title: t('delete'), 'data-gallery-annot-remove': a.id,
|
|
4375
|
+
onClick: () => onRemove(a.id),
|
|
4376
|
+
}, '✕'),
|
|
4377
|
+
])))
|
|
4378
|
+
|
|
4379
|
+
return h('div', { className: 'dg-annotWrap', key: 'annot', style: { position: 'absolute', inset: 0 } }, [
|
|
4380
|
+
h('svg', {
|
|
4381
|
+
key: 'svg',
|
|
4382
|
+
ref: svgRef,
|
|
4383
|
+
className: `dg-annotSvg${active ? ' dg-annotActive' : ''}`,
|
|
4384
|
+
'data-gallery-annot-svg': true,
|
|
4385
|
+
'data-gallery-annot-active': active ? '1' : '0',
|
|
4386
|
+
viewBox: '0 0 100 100',
|
|
4387
|
+
preserveAspectRatio: 'none',
|
|
4388
|
+
style: {
|
|
4389
|
+
position: 'absolute', inset: 0, width: '100%', height: '100%',
|
|
4390
|
+
pointerEvents: active ? 'auto' : 'none',
|
|
4391
|
+
cursor: active ? 'crosshair' : 'default',
|
|
4392
|
+
},
|
|
4393
|
+
onPointerDown,
|
|
4394
|
+
onPointerMove,
|
|
4395
|
+
onPointerUp: finishDraft,
|
|
4396
|
+
onPointerCancel: () => setDraft(null),
|
|
4397
|
+
}, [draftShape, ...shapes]),
|
|
4398
|
+
list,
|
|
4399
|
+
editor,
|
|
4400
|
+
])
|
|
4401
|
+
}
|
|
4402
|
+
|
|
3932
4403
|
function SettingsPanel({ t, onClose, onSaved }) {
|
|
3933
4404
|
const [loading, setLoading] = React.useState(true)
|
|
3934
4405
|
const [info, setInfo] = React.useState(null)
|
|
@@ -4219,6 +4690,40 @@ ${absPath}
|
|
|
4219
4690
|
const groupsInitRef = React.useRef(false)
|
|
4220
4691
|
// 全局分组:哪些组显示了中间产物
|
|
4221
4692
|
const [showInterim, setShowInterim] = React.useState({})
|
|
4693
|
+
/**
|
|
4694
|
+
* 分类显隐开关(v0.13.7)。
|
|
4695
|
+
*
|
|
4696
|
+
* 只记本次使用:不持久化,重开面板 / 重启回全显示。
|
|
4697
|
+
* 理由:用户若忘了自己关过哪一类,会以为文件丢了 —— 每次从全显示开始最不容易误解。
|
|
4698
|
+
*
|
|
4699
|
+
* 键:
|
|
4700
|
+
* finalConfirmed —— 最终交付·已确认(确认态,见 3.2)
|
|
4701
|
+
* finalPending —— 最终交付·待确认
|
|
4702
|
+
* input —— 输入素材
|
|
4703
|
+
* intermediate —— 中间产物(与组内开关同源)
|
|
4704
|
+
* unknown —— 未归类
|
|
4705
|
+
*/
|
|
4706
|
+
const [categoryFilter, setCategoryFilter] = React.useState({
|
|
4707
|
+
finalConfirmed: true,
|
|
4708
|
+
finalPending: true,
|
|
4709
|
+
input: true,
|
|
4710
|
+
intermediate: true,
|
|
4711
|
+
unknown: true,
|
|
4712
|
+
})
|
|
4713
|
+
/** 批量选择(v0.13.7):选中的 relPath 集合。清空条件:切 kind / 切 scope / 刷新后失效项自动剔除。 */
|
|
4714
|
+
const [selected, setSelected] = React.useState(new Set())
|
|
4715
|
+
/** 批量模式:用户显式开启,或已有选中项时自动生效(避免勾了看不见批量条)。 */
|
|
4716
|
+
const [batchMode, setBatchMode] = React.useState(false)
|
|
4717
|
+
/**
|
|
4718
|
+
* 框选批注(v0.14.0):按 relPath 存,一次查看器内可加多条。
|
|
4719
|
+
*
|
|
4720
|
+
* 只记在内存 + 走草稿通道输出,**不落盘**(批注是"这次要跟 Agent 说的话",
|
|
4721
|
+
* 不是需要长期保留的状态;确认态才落盘,两者语义不同)。
|
|
4722
|
+
*/
|
|
4723
|
+
const [annotations, setAnnotations] = React.useState({})
|
|
4724
|
+
const selectMode = batchMode || selected.size > 0
|
|
4725
|
+
/** 清废稿确认对话框:null=关闭;{ phase:'list'|'deleting', files, digest, count } */
|
|
4726
|
+
const [discardDialog, setDiscardDialog] = React.useState(null)
|
|
4222
4727
|
const toggleGroup = React.useCallback((key) => {
|
|
4223
4728
|
setOpenGroups((prev) => {
|
|
4224
4729
|
const next = new Set(prev)
|
|
@@ -4264,8 +4769,98 @@ ${absPath}
|
|
|
4264
4769
|
* 给某卡片设标记 → 进反馈篮。
|
|
4265
4770
|
* 只改本地状态 + 落盘 marks,**绝不发送任何消息**。
|
|
4266
4771
|
*/
|
|
4772
|
+
/**
|
|
4773
|
+
* 卡片的「确认态」—— 唯一真源是 marks 里的 confirmed 字段(v0.13.7)。
|
|
4774
|
+
*
|
|
4775
|
+
* **数据边界(最要紧)**:确认态只读标记文件,绝不读 / 写自动分类。
|
|
4776
|
+
* 分类是机器猜的、会随 5 秒刷新变;判断是人给的、必须留得住。
|
|
4777
|
+
*/
|
|
4778
|
+
const isConfirmed = React.useCallback((relPath) => {
|
|
4779
|
+
return marks[relPath]?.confirmed === true
|
|
4780
|
+
}, [marks])
|
|
4781
|
+
|
|
4782
|
+
/**
|
|
4783
|
+
* 卡片的分类分组(用于顶部开关筛选):
|
|
4784
|
+
* finalConfirmed / finalPending / input / intermediate / unknown
|
|
4785
|
+
*
|
|
4786
|
+
* 注意「最终交付」拆两态:靠确认态区分,不靠自动分类的 final。
|
|
4787
|
+
* 一张 final 的卡片若没确认 → finalPending;确认了 → finalConfirmed。
|
|
4788
|
+
*/
|
|
4789
|
+
const bucketOf = React.useCallback((file) => {
|
|
4790
|
+
if (isConfirmed(file.relPath)) return 'finalConfirmed'
|
|
4791
|
+
if (file.category === 'final') return 'finalPending'
|
|
4792
|
+
if (file.category === 'input') return 'input'
|
|
4793
|
+
if (file.category === 'intermediate') return 'intermediate'
|
|
4794
|
+
return 'unknown'
|
|
4795
|
+
}, [isConfirmed])
|
|
4796
|
+
|
|
4797
|
+
/** 切一个分类的显隐。 */
|
|
4798
|
+
const toggleCategory = React.useCallback((key) => {
|
|
4799
|
+
setCategoryFilter((prev) => ({ ...prev, [key]: !prev[key] }))
|
|
4800
|
+
}, [])
|
|
4801
|
+
|
|
4802
|
+
/** 批量选择切换。 */
|
|
4803
|
+
const toggleSelect = React.useCallback((relPath) => {
|
|
4804
|
+
setSelected((prev) => {
|
|
4805
|
+
const next = new Set(prev)
|
|
4806
|
+
if (next.has(relPath)) next.delete(relPath)
|
|
4807
|
+
else next.add(relPath)
|
|
4808
|
+
return next
|
|
4809
|
+
})
|
|
4810
|
+
}, [])
|
|
4811
|
+
|
|
4812
|
+
/** 批量:确认 / 取消确认 / 清除标记(只改标记,不碰磁盘)。 */
|
|
4813
|
+
const batchMark = React.useCallback(async (action) => {
|
|
4814
|
+
const paths = [...selected]
|
|
4815
|
+
if (paths.length === 0) return
|
|
4816
|
+
const updates = paths.map((p) => ({
|
|
4817
|
+
path: p,
|
|
4818
|
+
// 确认:保留原有 action,加 confirmed:true
|
|
4819
|
+
// 取消确认:去掉 confirmed
|
|
4820
|
+
// 清除:整条删掉
|
|
4821
|
+
mark: action === 'clear'
|
|
4822
|
+
? null
|
|
4823
|
+
: action === 'confirm'
|
|
4824
|
+
? { ...(marks[p] ?? { action: 'finalize' }), confirmed: true }
|
|
4825
|
+
: (() => {
|
|
4826
|
+
const cur = marks[p]
|
|
4827
|
+
if (cur === undefined) return null
|
|
4828
|
+
const next = { ...cur }
|
|
4829
|
+
delete next.confirmed
|
|
4830
|
+
// 若原来只为确认而建的 finalize 标记,取消后整条删掉
|
|
4831
|
+
if (next.action === 'finalize' && Object.keys(next).filter((k) => k !== 'action' && k !== 'markedAt').length === 0) {
|
|
4832
|
+
return null
|
|
4833
|
+
}
|
|
4834
|
+
return next
|
|
4835
|
+
})(),
|
|
4836
|
+
}))
|
|
4837
|
+
// 本地先行(乐观更新)
|
|
4838
|
+
setMarks((prev) => {
|
|
4839
|
+
const next = { ...prev }
|
|
4840
|
+
for (const u of updates) {
|
|
4841
|
+
if (u.mark === null) delete next[u.path]
|
|
4842
|
+
else next[u.path] = u.mark
|
|
4843
|
+
}
|
|
4844
|
+
return next
|
|
4845
|
+
})
|
|
4846
|
+
try {
|
|
4847
|
+
const payload = await callHost('marksBatch', { updates })
|
|
4848
|
+
if (payload?.ok === false) throw new Error(payload?.error?.message ?? t('errorTitle'))
|
|
4849
|
+
if (payload?.marks !== undefined) setMarks(payload.marks)
|
|
4850
|
+
} catch (error) {
|
|
4851
|
+
console.warn('dsh-gallery: 批量标记失败', error)
|
|
4852
|
+
}
|
|
4853
|
+
setSelected(new Set())
|
|
4854
|
+
}, [selected, marks, t])
|
|
4855
|
+
|
|
4267
4856
|
const doMark = React.useCallback(async (item, action, extra) => {
|
|
4268
|
-
|
|
4857
|
+
/**
|
|
4858
|
+
* v0.13.7:`finalize` = 「定为最终版」要写成**持久确认态**。
|
|
4859
|
+
*
|
|
4860
|
+
* confirmed 字段是唯一真源:存进 marks 文件,刷新 / 重扫 / 切会话 / 重启都在。
|
|
4861
|
+
* **绝不回写自动分类** —— 分类是机器猜的会变,判断是人给的必须留得住。
|
|
4862
|
+
*/
|
|
4863
|
+
const mark = { action, ...(extra ?? {}), ...(action === 'finalize' ? { confirmed: true } : {}) }
|
|
4269
4864
|
setMarks((prev) => ({ ...prev, [item.relPath]: mark }))
|
|
4270
4865
|
setBasketOpen(true)
|
|
4271
4866
|
try {
|
|
@@ -4297,6 +4892,57 @@ ${absPath}
|
|
|
4297
4892
|
}
|
|
4298
4893
|
}, [])
|
|
4299
4894
|
|
|
4895
|
+
/** 取消确认(v0.13.7):把 confirmed 去掉,退回「待确认」。 */
|
|
4896
|
+
const unconfirmOne = React.useCallback(async (relPath) => {
|
|
4897
|
+
const cur = marks[relPath]
|
|
4898
|
+
if (cur === undefined) return
|
|
4899
|
+
const next = { ...cur }
|
|
4900
|
+
delete next.confirmed
|
|
4901
|
+
const cleaned = (next.action === 'finalize' &&
|
|
4902
|
+
Object.keys(next).filter((k) => k !== 'action' && k !== 'markedAt').length === 0)
|
|
4903
|
+
? null
|
|
4904
|
+
: next
|
|
4905
|
+
setMarks((prev) => {
|
|
4906
|
+
const n = { ...prev }
|
|
4907
|
+
if (cleaned === null) delete n[relPath]
|
|
4908
|
+
else n[relPath] = cleaned
|
|
4909
|
+
return n
|
|
4910
|
+
})
|
|
4911
|
+
try {
|
|
4912
|
+
await callHost('marks', { path: relPath, mark: cleaned })
|
|
4913
|
+
} catch (error) {
|
|
4914
|
+
console.warn('dsh-gallery: 取消确认失败', error)
|
|
4915
|
+
}
|
|
4916
|
+
}, [marks])
|
|
4917
|
+
|
|
4918
|
+
/** 加一条批注(v0.14.0)。 */
|
|
4919
|
+
const addAnnotation = React.useCallback((item, annot) => {
|
|
4920
|
+
const relPath = item.relPath
|
|
4921
|
+
setAnnotations((prev) => {
|
|
4922
|
+
const cur = prev[relPath] ?? []
|
|
4923
|
+
if (cur.length >= 50) return prev // 与契约上限一致
|
|
4924
|
+
return { ...prev, [relPath]: [...cur, annot] }
|
|
4925
|
+
})
|
|
4926
|
+
}, [])
|
|
4927
|
+
|
|
4928
|
+
/** 删一条批注。 */
|
|
4929
|
+
const removeAnnotation = React.useCallback((item, id) => {
|
|
4930
|
+
const relPath = item.relPath
|
|
4931
|
+
setAnnotations((prev) => {
|
|
4932
|
+
const cur = prev[relPath] ?? []
|
|
4933
|
+
const next = cur.filter((a) => a.id !== id)
|
|
4934
|
+
const out = { ...prev }
|
|
4935
|
+
if (next.length === 0) delete out[relPath]
|
|
4936
|
+
else out[relPath] = next
|
|
4937
|
+
return out
|
|
4938
|
+
})
|
|
4939
|
+
}, [])
|
|
4940
|
+
|
|
4941
|
+
/** 取某文件的批注列表(给查看器用)。 */
|
|
4942
|
+
const annotationsOf = React.useCallback((item) => {
|
|
4943
|
+
return annotations[item.relPath] ?? []
|
|
4944
|
+
}, [annotations])
|
|
4945
|
+
|
|
4300
4946
|
/** 移除一条标记。 */
|
|
4301
4947
|
const removeMark = React.useCallback(async (relPath) => {
|
|
4302
4948
|
setMarks((prev) => {
|
|
@@ -4624,31 +5270,230 @@ ${absPath}
|
|
|
4624
5270
|
? format(t('feedbackBasketToggleN'), { n: markedCount })
|
|
4625
5271
|
: t('feedbackBasketToggle'))
|
|
4626
5272
|
|
|
5273
|
+
/**
|
|
5274
|
+
* 各分类的全局计数(供顶部开关显示数字 + 判断「已显示 N / 共 M」)。
|
|
5275
|
+
* v0.13.7:确认态计数来自 marks,不来自自动分类。
|
|
5276
|
+
*/
|
|
5277
|
+
const catCounts = React.useMemo(() => {
|
|
5278
|
+
const c = { finalConfirmed: 0, finalPending: 0, input: 0, intermediate: 0, unknown: 0 }
|
|
5279
|
+
for (const it of items) {
|
|
5280
|
+
const b = bucketOf(it)
|
|
5281
|
+
if (Object.prototype.hasOwnProperty.call(c, b)) c[b] += 1
|
|
5282
|
+
}
|
|
5283
|
+
return c
|
|
5284
|
+
}, [items, bucketOf])
|
|
5285
|
+
const confirmedCount = catCounts.finalConfirmed
|
|
5286
|
+
const pendingCount = catCounts.finalPending
|
|
5287
|
+
const inputCount = catCounts.input
|
|
5288
|
+
const interimCount = catCounts.intermediate
|
|
5289
|
+
const unknownCount = catCounts.unknown
|
|
5290
|
+
|
|
5291
|
+
/** 按当前开关过滤后的可见文件数(供「已显示 N / 共 M」)。 */
|
|
5292
|
+
const visibleStats = React.useMemo(() => {
|
|
5293
|
+
let shown = 0
|
|
5294
|
+
let total = 0
|
|
5295
|
+
for (const it of items) {
|
|
5296
|
+
total += 1
|
|
5297
|
+
if (categoryFilter[bucketOf(it)] !== false) shown += 1
|
|
5298
|
+
}
|
|
5299
|
+
return { shown, total }
|
|
5300
|
+
}, [items, categoryFilter, bucketOf])
|
|
5301
|
+
|
|
4627
5302
|
const hasUnknown = data !== null && Array.isArray(data.groups) &&
|
|
4628
5303
|
data.groups.some((gr) => (gr.counts?.unknown ?? 0) > 0)
|
|
5304
|
+
/**
|
|
5305
|
+
* 分类开关(v0.13.7):原来只是说明色块,现在可点。
|
|
5306
|
+
*
|
|
5307
|
+
* 规则:
|
|
5308
|
+
* · 彩色 = 显示,灰色 = 不显示
|
|
5309
|
+
* · 只有「最终交付」拆两态(已确认 / 待确认);其余五种表态不进这里
|
|
5310
|
+
* · 「未归类」只在确实存在时出现
|
|
5311
|
+
* · 只记本次使用,不持久化
|
|
5312
|
+
*/
|
|
5313
|
+
const filterToggle = (key, label, swatchClass, count, alwaysShow) => {
|
|
5314
|
+
const on = categoryFilter[key] !== false
|
|
5315
|
+
if (!on && !alwaysShow && count === 0) return null
|
|
5316
|
+
return h('button', {
|
|
5317
|
+
type: 'button',
|
|
5318
|
+
key: 'tog:' + key,
|
|
5319
|
+
className: `dg-legendItem dg-legendToggle${on ? '' : ' dg-legendOff'}`,
|
|
5320
|
+
'data-gallery-filter': key,
|
|
5321
|
+
'data-gallery-filter-on': on ? '1' : '0',
|
|
5322
|
+
title: on ? format(t('filterHideHint'), { label }) : format(t('filterShowHint'), { label }),
|
|
5323
|
+
onClick: () => toggleCategory(key),
|
|
5324
|
+
}, [
|
|
5325
|
+
h('span', { className: `dg-legendSwatch ${swatchClass}`, key: 's' }),
|
|
5326
|
+
h('span', { key: 'l' }, label),
|
|
5327
|
+
count > 0 ? h('span', { className: 'dg-legendCount', key: 'n' }, String(count)) : null,
|
|
5328
|
+
])
|
|
5329
|
+
}
|
|
5330
|
+
|
|
4629
5331
|
const legend = data !== null && items.length > 0
|
|
4630
|
-
? h('div', { className: 'dg-legend', key: 'legend',
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
h('span', { className: 'dg-legendItem', key: 'm' }, [
|
|
4640
|
-
h('span', { className: 'dg-legendSwatch dg-legendSwatch-intermediate', key: 's' }),
|
|
4641
|
-
h('span', { key: 'l' }, t('catLegendIntermediate')),
|
|
4642
|
-
]),
|
|
5332
|
+
? h('div', { className: 'dg-legend', key: 'legend', 'data-gallery-filterbar': true }, [
|
|
5333
|
+
// 最终交付 · 已确认
|
|
5334
|
+
filterToggle('finalConfirmed', t('catFilterFinalConfirmed'),
|
|
5335
|
+
'dg-legendSwatch-final', confirmedCount, true),
|
|
5336
|
+
// 最终交付 · 待确认
|
|
5337
|
+
filterToggle('finalPending', t('catFilterFinalPending'),
|
|
5338
|
+
'dg-legendSwatch-final dg-legendSwatchPending', pendingCount, true),
|
|
5339
|
+
filterToggle('input', t('catLegendInput'), 'dg-legendSwatch-input', inputCount, true),
|
|
5340
|
+
filterToggle('intermediate', t('catLegendIntermediate'), 'dg-legendSwatch-intermediate', interimCount, true),
|
|
4643
5341
|
hasUnknown
|
|
4644
|
-
?
|
|
4645
|
-
h('span', { className: 'dg-legendSwatch dg-legendSwatch-unknown', key: 's' }),
|
|
4646
|
-
h('span', { key: 'l' }, t('catLegendUnknown')),
|
|
4647
|
-
])
|
|
5342
|
+
? filterToggle('unknown', t('catLegendUnknown'), 'dg-legendSwatch-unknown', unknownCount, true)
|
|
4648
5343
|
: null,
|
|
4649
5344
|
])
|
|
4650
5345
|
: null
|
|
4651
5346
|
|
|
5347
|
+
/**
|
|
5348
|
+
* 批量操作条(v0.13.7)—— 有选中项时出现。
|
|
5349
|
+
* 三个动作:确认 / 取消确认 / 清除标记,**全部只改标记、不碰磁盘**。
|
|
5350
|
+
*/
|
|
5351
|
+
const selectedCount = selected.size
|
|
5352
|
+
const batchBar = selectedCount > 0
|
|
5353
|
+
? h('div', { className: 'dg-batchBar', key: 'batchBar', 'data-gallery-batch-bar': true }, [
|
|
5354
|
+
h('span', { className: 'dg-batchCount', key: 'n' }, format(t('batchBarTitle'), { n: selectedCount })),
|
|
5355
|
+
h('div', { className: 'dg-batchOps', key: 'ops' }, [
|
|
5356
|
+
h('button', {
|
|
5357
|
+
type: 'button', className: 'dg-btn dg-btnSmall', key: 'confirm',
|
|
5358
|
+
'data-gallery-batch-confirm': true,
|
|
5359
|
+
title: t('batchHintConfirm'),
|
|
5360
|
+
onClick: () => { void batchMark('confirm') },
|
|
5361
|
+
}, t('batchConfirm')),
|
|
5362
|
+
h('button', {
|
|
5363
|
+
type: 'button', className: 'dg-btn dg-btnSmall', key: 'unconfirm',
|
|
5364
|
+
'data-gallery-batch-unconfirm': true,
|
|
5365
|
+
onClick: () => { void batchMark('unconfirm') },
|
|
5366
|
+
}, t('batchUnconfirm')),
|
|
5367
|
+
h('button', {
|
|
5368
|
+
type: 'button', className: 'dg-btn dg-btnSmall', key: 'clearmark',
|
|
5369
|
+
'data-gallery-batch-clear': true,
|
|
5370
|
+
title: t('batchHintClearMark'),
|
|
5371
|
+
onClick: () => { void batchMark('clear') },
|
|
5372
|
+
}, t('batchClearMark')),
|
|
5373
|
+
h('button', {
|
|
5374
|
+
type: 'button', className: 'dg-btn dg-btnSmall', key: 'clearSel',
|
|
5375
|
+
'data-gallery-batch-clearsel': true,
|
|
5376
|
+
onClick: () => { setSelected(new Set()); setBatchMode(false) },
|
|
5377
|
+
}, t('batchClearSelection')),
|
|
5378
|
+
]),
|
|
5379
|
+
])
|
|
5380
|
+
: null
|
|
5381
|
+
|
|
5382
|
+
/**
|
|
5383
|
+
* 「清掉废稿」入口(v0.13.7)—— 只在确实有 reject 标记时出现。
|
|
5384
|
+
* 这是**唯一会碰磁盘**的批量动作,走独立两阶段确认。
|
|
5385
|
+
*/
|
|
5386
|
+
const discardPaths = React.useMemo(
|
|
5387
|
+
() => Object.keys(marks).filter((rp) => marks[rp]?.action === 'reject'),
|
|
5388
|
+
[marks],
|
|
5389
|
+
)
|
|
5390
|
+
const discardEntry = discardPaths.length > 0
|
|
5391
|
+
? h('button', {
|
|
5392
|
+
type: 'button',
|
|
5393
|
+
className: 'dg-btn dg-btnSmall dg-dangerBtn',
|
|
5394
|
+
key: 'discardEntry',
|
|
5395
|
+
'data-gallery-discard-entry': true,
|
|
5396
|
+
'data-gallery-discard-count': discardPaths.length,
|
|
5397
|
+
title: t('discardEntryHint'),
|
|
5398
|
+
onClick: () => { void openDiscardDialog() },
|
|
5399
|
+
}, format(t('discardEntry'), { n: discardPaths.length }))
|
|
5400
|
+
: null
|
|
5401
|
+
|
|
5402
|
+
/** 打开删除确认:先向 Host 要清单(dryRun,不动磁盘)。 */
|
|
5403
|
+
const openDiscardDialog = React.useCallback(async () => {
|
|
5404
|
+
try {
|
|
5405
|
+
const payload = await callHost('deleteDiscarded', { paths: discardPaths, dryRun: true })
|
|
5406
|
+
if (payload?.ok === false) throw new Error(payload?.error?.message ?? t('errorTitle'))
|
|
5407
|
+
setDiscardDialog({
|
|
5408
|
+
phase: 'list',
|
|
5409
|
+
files: payload?.files ?? [],
|
|
5410
|
+
digest: payload?.digest ?? '',
|
|
5411
|
+
count: payload?.count ?? 0,
|
|
5412
|
+
rejected: payload?.rejected ?? [],
|
|
5413
|
+
})
|
|
5414
|
+
} catch (error) {
|
|
5415
|
+
console.error('dsh-gallery: 取删除清单失败', error)
|
|
5416
|
+
}
|
|
5417
|
+
}, [discardPaths, t])
|
|
5418
|
+
|
|
5419
|
+
/** 真正执行删除(两阶段第二段)。 */
|
|
5420
|
+
const runDiscard = React.useCallback(async () => {
|
|
5421
|
+
if (discardDialog === null) return
|
|
5422
|
+
if (discardDialog.count > 10) return
|
|
5423
|
+
setDiscardDialog((prev) => (prev === null ? null : { ...prev, phase: 'deleting' }))
|
|
5424
|
+
try {
|
|
5425
|
+
const payload = await callHost('deleteDiscarded', {
|
|
5426
|
+
paths: discardPaths,
|
|
5427
|
+
confirm: true,
|
|
5428
|
+
digest: discardDialog.digest,
|
|
5429
|
+
})
|
|
5430
|
+
if (payload?.ok === false) {
|
|
5431
|
+
const code = payload?.error?.code
|
|
5432
|
+
throw new Error(
|
|
5433
|
+
code === 'digest-mismatch' ? t('discardDigestMismatch')
|
|
5434
|
+
: code === 'batch-too-large' ? format(t('discardDialogTooMany'), { n: discardPaths.length })
|
|
5435
|
+
: (payload?.error?.message ?? t('errorTitle')))
|
|
5436
|
+
}
|
|
5437
|
+
const deleted = payload?.deleted ?? []
|
|
5438
|
+
// 同步清本地状态:marks + 反馈篮(先拿被删路径,再剔)
|
|
5439
|
+
if (payload?.marks !== undefined) setMarks(payload.marks)
|
|
5440
|
+
// 反馈篮条目由 setMarks + 篮内渲染源自动同步,无需单独删
|
|
5441
|
+
setSelected(new Set())
|
|
5442
|
+
setDiscardDialog(null)
|
|
5443
|
+
console.info('dsh-gallery:', format(t('discardDone'), { n: deleted.length }))
|
|
5444
|
+
void refresh()
|
|
5445
|
+
} catch (error) {
|
|
5446
|
+
console.error('dsh-gallery: 删除失败', error)
|
|
5447
|
+
setDiscardDialog((prev) => (prev === null ? null : { ...prev, phase: 'list', error: String(error?.message ?? error) }))
|
|
5448
|
+
}
|
|
5449
|
+
}, [discardDialog, discardPaths, t])
|
|
5450
|
+
|
|
5451
|
+
/** 删除确认对话框(两阶段:清单 → 真删)。 */
|
|
5452
|
+
const discardDialogNode = discardDialog !== null
|
|
5453
|
+
? h('div', { className: 'dg-modalLayer', key: 'discardModal', 'data-gallery-discard-dialog': true }, [
|
|
5454
|
+
h('div', { className: 'dg-modal', role: 'dialog', 'aria-modal': 'true' }, [
|
|
5455
|
+
h('div', { className: 'dg-modalHead', key: 'h' }, t('discardDialogTitle')),
|
|
5456
|
+
h('div', { className: 'dg-modalBody', key: 'b' }, [
|
|
5457
|
+
h('p', { className: 'dg-dangerText', key: 'warn' }, t('discardDialogWarn')),
|
|
5458
|
+
discardDialog.count > 10
|
|
5459
|
+
? h('p', { className: 'dg-dangerText', key: 'tooMany' },
|
|
5460
|
+
format(t('discardDialogTooMany'), { n: discardDialog.count }))
|
|
5461
|
+
: null,
|
|
5462
|
+
h('p', { className: 'dg-modalSub', key: 'cnt' }, format(t('discardDialogCount'), { n: discardDialog.count })),
|
|
5463
|
+
// **完整路径逐条列出**(安全闸门要求,不许「已选 N 个」一句带过)
|
|
5464
|
+
h('ul', { className: 'dg-discardList', key: 'list', 'data-gallery-discard-files': true },
|
|
5465
|
+
(discardDialog.files ?? []).map((f) => h('li', {
|
|
5466
|
+
key: f.absolute,
|
|
5467
|
+
title: f.absolute,
|
|
5468
|
+
'data-gallery-discard-file': f.absolute,
|
|
5469
|
+
}, [
|
|
5470
|
+
h('span', { className: 'dg-discardPath', key: 'p' }, f.path),
|
|
5471
|
+
h('span', { className: 'dg-discardSize', key: 's' }, formatBytes(f.size)),
|
|
5472
|
+
]))),
|
|
5473
|
+
discardDialog.error !== undefined
|
|
5474
|
+
? h('p', { className: 'dg-dangerText', key: 'err' },
|
|
5475
|
+
format(t('discardFailed'), { msg: discardDialog.error }))
|
|
5476
|
+
: null,
|
|
5477
|
+
]),
|
|
5478
|
+
h('div', { className: 'dg-modalOps', key: 'o' }, [
|
|
5479
|
+
h('button', {
|
|
5480
|
+
type: 'button', className: 'dg-btn', key: 'cancel',
|
|
5481
|
+
disabled: discardDialog.phase === 'deleting',
|
|
5482
|
+
onClick: () => setDiscardDialog(null),
|
|
5483
|
+
}, t('discardDialogCancel')),
|
|
5484
|
+
h('button', {
|
|
5485
|
+
type: 'button', className: 'dg-btn dg-dangerBtn', key: 'ok',
|
|
5486
|
+
'data-gallery-discard-confirm': true,
|
|
5487
|
+
disabled: discardDialog.phase === 'deleting' || discardDialog.count > 10 || discardDialog.count === 0,
|
|
5488
|
+
onClick: () => { void runDiscard() },
|
|
5489
|
+
}, discardDialog.phase === 'deleting'
|
|
5490
|
+
? t('discardDialogDeleting')
|
|
5491
|
+
: format(t('discardDialogConfirm'), { n: discardDialog.count })),
|
|
5492
|
+
]),
|
|
5493
|
+
]),
|
|
5494
|
+
])
|
|
5495
|
+
: null
|
|
5496
|
+
|
|
4652
5497
|
let body
|
|
4653
5498
|
if (view.status === 'loading') {
|
|
4654
5499
|
body = h('div', { className: 'dg-body', key: 'body' }, h('p', { className: 'dg-status' }, t('loading')))
|
|
@@ -4694,6 +5539,51 @@ ${absPath}
|
|
|
4694
5539
|
const useGroups = scope === 'global' && Array.isArray(data.groups) && data.groups.length > 0
|
|
4695
5540
|
|
|
4696
5541
|
if (useGroups) {
|
|
5542
|
+
/**
|
|
5543
|
+
* 卡片包装层(v0.13.7):给任意卡片加「确认角标」+「批量多选框」。
|
|
5544
|
+
*
|
|
5545
|
+
* 为什么不改三个卡片组件:Card / FileCard / MediaCard 各自有复杂的内部结构,
|
|
5546
|
+
* 在它们外面套一层 absolute 定位的 overlay 最省事,也不会影响既有交互
|
|
5547
|
+
* (右键、点击预览、拖拽都不受影响,因为我们只加 pointer-events 可控的子元素)。
|
|
5548
|
+
*/
|
|
5549
|
+
const wrapCard = (node, item, key) => {
|
|
5550
|
+
const confirmed = isConfirmed(item.relPath)
|
|
5551
|
+
const checked = selected.has(item.relPath)
|
|
5552
|
+
const showCheckbox = selectMode || checked
|
|
5553
|
+
return h('div', {
|
|
5554
|
+
className: `dg-cardWrap${confirmed ? ' dg-cardConfirmed' : ''}${checked ? ' dg-cardChecked' : ''}`,
|
|
5555
|
+
key: key + ':wrap',
|
|
5556
|
+
'data-gallery-card-wrap': item.relPath,
|
|
5557
|
+
'data-gallery-confirmed': confirmed ? '1' : '0',
|
|
5558
|
+
}, [
|
|
5559
|
+
node,
|
|
5560
|
+
// 确认角标(只在确认态出现,与自动分色边框区分开)
|
|
5561
|
+
confirmed
|
|
5562
|
+
? h('div', {
|
|
5563
|
+
className: 'dg-confirmBadge',
|
|
5564
|
+
key: 'badge',
|
|
5565
|
+
'data-gallery-confirm-badge': true,
|
|
5566
|
+
title: t('confirmBadgeHint'),
|
|
5567
|
+
}, [h('span', { key: 'i' }, '✓'), h('span', { key: 'l' }, t('confirmBadgeLabel'))])
|
|
5568
|
+
: null,
|
|
5569
|
+
// 多选框(批量模式下常显,或已选中时显示)
|
|
5570
|
+
showCheckbox
|
|
5571
|
+
? h('button', {
|
|
5572
|
+
type: 'button',
|
|
5573
|
+
className: `dg-cardCheck${checked ? ' dg-cardCheckOn' : ''}`,
|
|
5574
|
+
key: 'check',
|
|
5575
|
+
'data-gallery-card-check': item.relPath,
|
|
5576
|
+
title: checked ? t('batchUnselect') : t('batchSelect'),
|
|
5577
|
+
onClick: (e) => {
|
|
5578
|
+
e.stopPropagation()
|
|
5579
|
+
e.preventDefault()
|
|
5580
|
+
toggleSelect(item.relPath)
|
|
5581
|
+
},
|
|
5582
|
+
}, checked ? '✓' : '')
|
|
5583
|
+
: null,
|
|
5584
|
+
])
|
|
5585
|
+
}
|
|
5586
|
+
|
|
4697
5587
|
const cardFor = (item, groupKey, listForViewer) => {
|
|
4698
5588
|
// 分组里的文件也走同一套卡片组件
|
|
4699
5589
|
const enriched = {
|
|
@@ -4703,7 +5593,7 @@ ${absPath}
|
|
|
4703
5593
|
}
|
|
4704
5594
|
// 音视频分组视图:必须走 MediaCard,否则会被当成图片卡片渲染(v0.10.1)
|
|
4705
5595
|
if (kind === 'media') {
|
|
4706
|
-
return h(MediaCard, {
|
|
5596
|
+
return wrapCard(h(MediaCard, {
|
|
4707
5597
|
key: `${groupKey}:${item.relPath}`,
|
|
4708
5598
|
item: {
|
|
4709
5599
|
...enriched,
|
|
@@ -4715,10 +5605,10 @@ ${absPath}
|
|
|
4715
5605
|
absPath: buildAbsPath(data.root, item.relPath),
|
|
4716
5606
|
onPlay: (target) => setMediaPlaying(target),
|
|
4717
5607
|
onContextMenu: openContextMenu,
|
|
4718
|
-
})
|
|
5608
|
+
}), item, `${groupKey}:${item.relPath}`)
|
|
4719
5609
|
}
|
|
4720
5610
|
if (kind === 'file') {
|
|
4721
|
-
return h(FileCard, {
|
|
5611
|
+
return wrapCard(h(FileCard, {
|
|
4722
5612
|
key: `${groupKey}:${item.relPath}`,
|
|
4723
5613
|
item: enriched,
|
|
4724
5614
|
t,
|
|
@@ -4735,9 +5625,9 @@ ${absPath}
|
|
|
4735
5625
|
}
|
|
4736
5626
|
},
|
|
4737
5627
|
onCopy: (abs) => { void copyText(abs) },
|
|
4738
|
-
})
|
|
5628
|
+
}), item, `${groupKey}:${item.relPath}`)
|
|
4739
5629
|
}
|
|
4740
|
-
return h(Card, {
|
|
5630
|
+
return wrapCard(h(Card, {
|
|
4741
5631
|
key: `${groupKey}:${item.relPath}`,
|
|
4742
5632
|
item: enriched,
|
|
4743
5633
|
t,
|
|
@@ -4755,7 +5645,7 @@ ${absPath}
|
|
|
4755
5645
|
if (pos < 0) return
|
|
4756
5646
|
openViewer(pos, anchorEl ?? null, list)
|
|
4757
5647
|
},
|
|
4758
|
-
})
|
|
5648
|
+
}), item, `${groupKey}:${item.relPath}`)
|
|
4759
5649
|
}
|
|
4760
5650
|
|
|
4761
5651
|
const groupNodes = data.groups.map((group, gi) => {
|
|
@@ -4765,12 +5655,24 @@ ${absPath}
|
|
|
4765
5655
|
// - 当前对话:**默认显示**(用户刚做完的就是要看过程,可选收起)
|
|
4766
5656
|
// - 其他对话 / 历史资产:**默认隐藏**(避免别人调试图淹没列表)
|
|
4767
5657
|
// 用户手动切换后,以 showInterim 里记录的为准(true=显示 / false=隐藏)。
|
|
5658
|
+
// 组内「显示中间产物」与顶部「中间产物」开关**同源**(v0.13.7):
|
|
5659
|
+
// 顶部开关关掉 → 全局都不显示中间产物;
|
|
5660
|
+
// 顶部开着 + 组内开关 → 由组内决定(默认当前对话显示、历史隐藏)。
|
|
5661
|
+
// 不搞两套打架的开关。
|
|
4768
5662
|
const interimDefault = group.isCurrent === true
|
|
4769
5663
|
const stored = showInterim[groupKey]
|
|
4770
|
-
const
|
|
4771
|
-
const
|
|
4772
|
-
|
|
4773
|
-
|
|
5664
|
+
const groupWantsIntermediate = stored === undefined ? interimDefault : stored
|
|
5665
|
+
const globalAllowsIntermediate = categoryFilter.intermediate !== false
|
|
5666
|
+
const showIntermediate = groupWantsIntermediate && globalAllowsIntermediate
|
|
5667
|
+
|
|
5668
|
+
// 分类开关过滤:按 bucketOf 判断该文件属哪一类,再查开关
|
|
5669
|
+
const visibleFiles = group.files.filter((f) => {
|
|
5670
|
+
const bucket = bucketOf(f)
|
|
5671
|
+
if (categoryFilter[bucket] === false) return false
|
|
5672
|
+
// 中间产物额外受组内开关控制(上面已算好)
|
|
5673
|
+
if (f.category === 'intermediate' && !showIntermediate) return false
|
|
5674
|
+
return true
|
|
5675
|
+
})
|
|
4774
5676
|
const hiddenCount = group.files.length - visibleFiles.length
|
|
4775
5677
|
|
|
4776
5678
|
const chips = []
|
|
@@ -4957,6 +5859,9 @@ ${absPath}
|
|
|
4957
5859
|
const viewerLayer = viewer !== null && Array.isArray(viewer.list) && viewer.list.length > 0
|
|
4958
5860
|
? h('div', { className: 'dg-viewerLayer', key: 'viewerLayer' },
|
|
4959
5861
|
h(Viewer, {
|
|
5862
|
+
annotations: annotationsOf,
|
|
5863
|
+
onAddAnnotation: addAnnotation,
|
|
5864
|
+
onRemoveAnnotation: removeAnnotation,
|
|
4960
5865
|
items: viewer.list,
|
|
4961
5866
|
index: Math.min(viewer.index, viewer.list.length - 1),
|
|
4962
5867
|
t,
|
|
@@ -5040,6 +5945,8 @@ ${absPath}
|
|
|
5040
5945
|
onCopy: () => { void copyText(ctxMenu.absPath) },
|
|
5041
5946
|
onDelete: () => setDeleteTarget({ item: ctxMenu.item, busy: false }),
|
|
5042
5947
|
// 6 个反馈动作(S3-a):选中即进反馈篮,不发送
|
|
5948
|
+
confirmed: marks[ctxMenu.item.relPath]?.confirmed === true,
|
|
5949
|
+
onUnconfirm: () => { void unconfirmOne(ctxMenu.item.relPath) },
|
|
5043
5950
|
onMark: (action) => {
|
|
5044
5951
|
const target = ctxMenu.item
|
|
5045
5952
|
closeContextMenu()
|
|
@@ -5064,6 +5971,9 @@ ${absPath}
|
|
|
5064
5971
|
return h('div', { className: 'dg-root', 'data-gallery-root': true }, [
|
|
5065
5972
|
header,
|
|
5066
5973
|
basketToggle,
|
|
5974
|
+
batchBar,
|
|
5975
|
+
discardEntry,
|
|
5976
|
+
discardDialogNode,
|
|
5067
5977
|
legend,
|
|
5068
5978
|
body,
|
|
5069
5979
|
pager,
|