dsh-gallery 0.16.6 → 1.0.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 +180 -30
- package/README.md +48 -17
- package/client.js +577 -164
- package/host/context.js +87 -0
- package/host/feedback-text.js +81 -1
- package/host/frames.js +34 -0
- package/host/groups.js +5 -0
- package/host/http.js +246 -20
- package/host/protocol.js +403 -1
- package/host/scan.js +90 -23
- package/host/tools.js +344 -0
- package/index.js +6 -2
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// __DSH_BUILD_FINGERPRINT__ {"v":1,"fragments":{"src/client/00-head.js":"c62f6d728d1cfdb5d64db41764171d5d6314d6cc","src/client/01-i18n.js":"5edcfb18abac018ead28772972035b66fcb73562","src/client/02-util.js":"af7867f3cd7313b4d54ff17b727516eca315313e","src/client/03-theme.js":"fe8a1ed10f3ee8ab59bdbdb3038f5bb95e01f0be","src/client/04-paths.js":"d2f85774e5d0888ce512c0fe35755978b6986b52","src/client/05-feedback.js":"a9a21378ff499e482ce52c3d45041eda86d2e39d","src/client/06-ctxmenu.js":"82c4d1ccff0312453a68ae63630e4514eb11b70f","src/client/07-media.js":"e2690a07c9735856e03aaaa901e8007da005da7a","src/client/08-cards.js":"bbff076268c827f846229d97064c972ae34f7740","src/client/09-viewer.js":"4a909e1ea1fa2380062c69013ede1ba794c4535d","src/client/10-annotate.js":"0dd07c4a4929b512739df62e91ed6eb201201fb9","src/client/11-settings.js":"c02bc78edf896050dee3bc4b26d311433cc33ade","src/client/12-body.js":"656b068d26229df902eaa5a436ddd8aa0921af49","src/client/13-chrome.js":"de082de1a9d1ffbaeb600fbf659dba059cca7973","src/client/14-entry.js":"5ce848d53bef377c53b97b6411614bd571ff775b"},"shared":{"src/shared/feedback-text.js":"1e7454d368685c938b970db7b1fe297fd4e60f68"},"styles":"c5e27291a1416843ce3ae8379e40dbc80bd561bf","builtAt":"2026-11-14T14:35:40.643Z","artifactSha1":"e1f883e2f40c5f925b047d31cc21d335da835a84"}
|
|
1
2
|
window.__ModuleLoader__.load({
|
|
2
3
|
id: 'dsh-gallery',
|
|
3
4
|
factory(require) {
|
|
@@ -57,6 +58,9 @@ const ANNOTATION_SHAPES = ["rect", "arrow", "text"]
|
|
|
57
58
|
*
|
|
58
59
|
* 约束:x/y/w/h 必须落在 [0,1];越界由写入端 clamp。
|
|
59
60
|
*/
|
|
61
|
+
/** 全局分组视图:每组一次画多少张卡,点「再显示」按这个步长追加。 */
|
|
62
|
+
const GROUP_PAGE = 60
|
|
63
|
+
|
|
60
64
|
const ANNOTATION_LIMITS = { min: 0, max: 1, maxNoteLength: 500, maxPerAsset: 50 }
|
|
61
65
|
|
|
62
66
|
/** 把任意数值 clamp 到 [0,1](批注坐标写入前必须过一遍)。 */
|
|
@@ -102,7 +106,11 @@ function trimPlaybackDecision(now, inPoint, outPoint, opts) {
|
|
|
102
106
|
/** 校验并规整一条批注;不合法返回 null。 */
|
|
103
107
|
function normalizeAnnotation(a) {
|
|
104
108
|
if (a === null || typeof a !== "object") return null
|
|
105
|
-
|
|
109
|
+
// v0.17.x:'polygon' 是前端「不规则区域标记」专用形状,不进 Host 的动作契约,
|
|
110
|
+
// 因此只在这里特判放行,host/protocol.js 的 ANNOTATION_SHAPES 无需跟着改。
|
|
111
|
+
const shape = a.shape === "polygon"
|
|
112
|
+
? "polygon"
|
|
113
|
+
: (ANNOTATION_SHAPES.includes(a.shape) ? a.shape : "rect")
|
|
106
114
|
const note = typeof a.note === "string" ? a.note.slice(0, ANNOTATION_LIMITS.maxNoteLength) : ""
|
|
107
115
|
const x = clamp01(a.x)
|
|
108
116
|
const y = clamp01(a.y)
|
|
@@ -112,9 +120,19 @@ function normalizeAnnotation(a) {
|
|
|
112
120
|
if (w > 0 && x + w > 1) w = 1 - x
|
|
113
121
|
if (h > 0 && y + h > 1) h = 1 - y
|
|
114
122
|
const frameMs = Number.isFinite(a.frameMs) ? Math.max(0, Math.floor(a.frameMs)) : null
|
|
123
|
+
// 顶点数写死 4–20,与 POLYGON_LIMITS 一致;这里不引用后面的常量,
|
|
124
|
+
// 免得离线把本函数单独抽出来跑时踩到暂时性死区。
|
|
125
|
+
const polygon = shape === "polygon" && Array.isArray(a.polygon)
|
|
126
|
+
&& a.polygon.length >= 4 && a.polygon.length <= 20
|
|
127
|
+
&& a.polygon.every((p) => Array.isArray(p) && p.length === 2
|
|
128
|
+
&& Number.isFinite(p[0]) && Number.isFinite(p[1]))
|
|
129
|
+
? a.polygon.map((p) => [clamp01(p[0]), clamp01(p[1])])
|
|
130
|
+
: null
|
|
131
|
+
const fillColor = typeof a.fillColor === "string" && a.fillColor !== "" ? a.fillColor : "green"
|
|
115
132
|
return {
|
|
116
133
|
id: typeof a.id === "string" && a.id !== "" ? a.id : ("a" + Math.random().toString(36).slice(2, 10)),
|
|
117
134
|
shape, x, y, w, h, note, frameMs,
|
|
135
|
+
...(polygon !== null ? { polygon, fillColor } : {}),
|
|
118
136
|
}
|
|
119
137
|
}
|
|
120
138
|
|
|
@@ -195,12 +213,16 @@ function maskAlphaAt(px, py, rect) {
|
|
|
195
213
|
}
|
|
196
214
|
|
|
197
215
|
/* ------------------------------------------------------------------ *
|
|
198
|
-
* v0.14.6
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
216
|
+
* 多边形选区(v0.14.6 起;老板 2026-11-15 再定版):
|
|
217
|
+
* · 左键按住拖动 = 矩形批注(老行为,保留)
|
|
218
|
+
* · 左键**单击**逐点 = 不规则区域标记,闭合后直接进反馈篮(不生成遮罩文件)
|
|
219
|
+
* · 右键逐点 = 实心多边形填充选区,闭合后导出遮罩 + 彩色预览(老行为,保留)
|
|
220
|
+
* 两套多边形共用一组顶点,模式互斥;4–20 点,点回起点 / Enter / 面板按钮闭合。
|
|
221
|
+
* 实测口径(见验证报告第九节):遮罩必须实心贴合目标外接框,线框 / 椭圆会出白底。
|
|
202
222
|
* ------------------------------------------------------------------ */
|
|
203
223
|
const POLYGON_LIMITS = { min: 4, max: 20, closeRadius: 0.02, minArea: 0.0001 }
|
|
224
|
+
/** 左键按下后移动超过这个归一化距离才算「拖框」,否则算一次点击(区域顶点)。 */
|
|
225
|
+
const ANNOT_DRAG_THRESHOLD = 0.008
|
|
204
226
|
|
|
205
227
|
/* ------------------------------------------------------------------ *
|
|
206
228
|
* 选区纯色半透明填充(v0.14.7 引入;老板 2026-11-12 20:22 再定版):
|
|
@@ -558,6 +580,7 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
558
580
|
scopeNotFound: '找不到本对话的会话记录',
|
|
559
581
|
scopeLogEmpty: '本对话的会话记录为空',
|
|
560
582
|
subCount: '{shown} / {total} 条',
|
|
583
|
+
subCountGroups: '共 {total} 条 · {groups} 个对话',
|
|
561
584
|
// ===== 资产分类(三色边框)=====
|
|
562
585
|
catFinal: '成稿',
|
|
563
586
|
catInput: '素材',
|
|
@@ -597,7 +620,7 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
597
620
|
annotNotePrompt: '这块要改什么?(可留空)',
|
|
598
621
|
annotNotePlaceholder: '例如:沙发位置偏了 / 色调太暖',
|
|
599
622
|
annotNoNote: '(无说明)',
|
|
600
|
-
annotHint: '
|
|
623
|
+
annotHint: '左键按住拖动=矩形框选(可写说明);左键单击逐点圈不规则区域,闭合后=标记进反馈篮;右键逐点圈选=生成实心填充遮罩',
|
|
601
624
|
annotCount: '批注 {n} 处',
|
|
602
625
|
annotPendingTag: '待保存',
|
|
603
626
|
annotPendingHint: '黄色亮框就是刚圈的位置;写完点「保存并生效」,也可以直接在图上继续圈下一处(这处会先自动存档)',
|
|
@@ -667,6 +690,7 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
667
690
|
groupIntermediate: '过程稿 {n}',
|
|
668
691
|
groupUnknown: '未归类 {n}',
|
|
669
692
|
groupTruncated: '仅显示最近 {shown} 个,共 {total} 个',
|
|
693
|
+
groupShowMore: '再显示 {step} 张 · 已显示 {shown} / 共 {total}',
|
|
670
694
|
groupHistoryTitle: '历史资产',
|
|
671
695
|
groupCurrentBadge: '当前对话',
|
|
672
696
|
// 资产 → 会话(01)与归档/删除标注(02)
|
|
@@ -736,7 +760,7 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
736
760
|
ctxHide: '隐藏(不再列出)',
|
|
737
761
|
ctxUnhide: '取消隐藏',
|
|
738
762
|
ctxReveal: '打开所在文件夹',
|
|
739
|
-
ctxCopy: '
|
|
763
|
+
ctxCopy: '写进输入框',
|
|
740
764
|
ctxDelete: '删除文件',
|
|
741
765
|
ctxDeleteConfirm: '确认删除?此操作不可恢复',
|
|
742
766
|
ctxDeleteYes: '确认删除',
|
|
@@ -798,8 +822,15 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
798
822
|
polyClear: '清空',
|
|
799
823
|
polyTooFew: '至少 4 个点才能闭合',
|
|
800
824
|
polyDegenerate: '选区面积太小(点几乎连成一条线),请重新围一圈',
|
|
825
|
+
// v0.17.x 左键单击逐点 → 不规则区域标记,闭合只进反馈篮、不生成文件
|
|
826
|
+
polyNoteTitle: '不规则区域标记',
|
|
827
|
+
polyNoteHint: '左键逐点点出要标的位置;点回起点、按 Enter 或点「闭合并加入反馈篮」即收工。说明可填可不填,顶点可左键拖动微调,Backspace 撤销一点,Escape 清空。',
|
|
828
|
+
polyNotePlaceholder: '这块要说什么?(可留空)',
|
|
829
|
+
polyNoteClose: '闭合并加入反馈篮',
|
|
830
|
+
polyNoteSaved: '已把这块区域加进反馈篮(没有生成遮罩文件)',
|
|
801
831
|
feedbackMaskFrom: '已有遮罩:{name}',
|
|
802
832
|
feedbackAnnotHint: '{n} 条框选批注会随反馈一起发出,序号与草稿里的 Annotation N 一一对应',
|
|
833
|
+
feedbackAnnotPolygonTag: '不规则区域 · {n} 点',
|
|
803
834
|
feedbackEditTitle: '编辑:{name}',
|
|
804
835
|
feedbackReasonLabel: '理由(可选)',
|
|
805
836
|
feedbackChangeOnlyLabel: '只改(逗号分隔,可选)',
|
|
@@ -810,6 +841,8 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
810
841
|
feedbackGenerating: '正在生成…',
|
|
811
842
|
feedbackGenerateHint: '生成草稿并写入输入框,由你确认后手动发送',
|
|
812
843
|
feedbackDraftReady: '草稿已写入输入框(未发送)。确认无误请自行发送。',
|
|
844
|
+
feedbackDraftAlreadyThere: '这张图已经在输入框里了,没有重复添加。',
|
|
845
|
+
dblClickHint: '双击 = 把带路径信息写进输入框(不自动发送)',
|
|
813
846
|
feedbackDraftInClipboard: '草稿已复制到剪贴板(输入框通道不可用),请手动粘贴。',
|
|
814
847
|
feedbackDraftFailed: '生成草稿失败',
|
|
815
848
|
feedbackChangeOnly: '只改',
|
|
@@ -942,6 +975,7 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
942
975
|
scopeNotFound: 'Cannot find this chat’s session log',
|
|
943
976
|
scopeLogEmpty: 'This chat’s session log is empty',
|
|
944
977
|
subCount: '{shown} of {total}',
|
|
978
|
+
subCountGroups: '{total} items · {groups} chats',
|
|
945
979
|
// Asset categories (colored borders)
|
|
946
980
|
catFinal: 'Draft',
|
|
947
981
|
catInput: 'Source',
|
|
@@ -981,7 +1015,7 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
981
1015
|
annotNotePrompt: 'What should change here? (optional)',
|
|
982
1016
|
annotNotePlaceholder: 'e.g. sofa position is off / color is too warm',
|
|
983
1017
|
annotNoNote: '(no note)',
|
|
984
|
-
annotHint: 'Left-drag
|
|
1018
|
+
annotHint: 'Left-drag = boxed note (optional text); left-click vertices = irregular area mark, close it to add to the feedback basket; right-click vertices = solid filled mask',
|
|
985
1019
|
annotCount: '{n} annotation(s)',
|
|
986
1020
|
annotPendingTag: 'Pending',
|
|
987
1021
|
annotPendingHint: 'The yellow box is the area you just marked. Add a note and click Save, or keep boxing more areas (this one is stored first).',
|
|
@@ -1051,6 +1085,7 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
1051
1085
|
groupIntermediate: 'WIP {n}',
|
|
1052
1086
|
groupUnknown: 'Unclassified {n}',
|
|
1053
1087
|
groupTruncated: 'Showing latest {shown} of {total}',
|
|
1088
|
+
groupShowMore: 'Show {step} more · {shown} of {total}',
|
|
1054
1089
|
groupHistoryTitle: 'Older assets',
|
|
1055
1090
|
groupCurrentBadge: 'This chat',
|
|
1056
1091
|
// Assets to chat (01) and archived / deleted badges (02)
|
|
@@ -1119,7 +1154,7 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
1119
1154
|
ctxHide: 'Hide (stop listing)',
|
|
1120
1155
|
ctxUnhide: 'Unhide',
|
|
1121
1156
|
ctxReveal: 'Open containing folder',
|
|
1122
|
-
ctxCopy: '
|
|
1157
|
+
ctxCopy: 'Write into chat input',
|
|
1123
1158
|
ctxDelete: 'Delete file',
|
|
1124
1159
|
ctxDeleteConfirm: 'Delete permanently? This cannot be undone',
|
|
1125
1160
|
ctxDeleteYes: 'Delete',
|
|
@@ -1179,8 +1214,15 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
1179
1214
|
polyClear: 'Clear',
|
|
1180
1215
|
polyTooFew: 'At least 4 points are needed',
|
|
1181
1216
|
polyDegenerate: 'Selection area is too small — the points are nearly a line',
|
|
1217
|
+
// v0.17.x left-click vertices -> irregular area mark, goes to the feedback basket only
|
|
1218
|
+
polyNoteTitle: 'Irregular area mark',
|
|
1219
|
+
polyNoteHint: 'Left-click to add vertices; click the first point, press Enter, or use Close & add to basket. A note is optional; drag vertices to adjust, Backspace undoes one point, Escape clears.',
|
|
1220
|
+
polyNotePlaceholder: 'What should be said about this area? (optional)',
|
|
1221
|
+
polyNoteClose: 'Close & add to basket',
|
|
1222
|
+
polyNoteSaved: 'Area added to the feedback basket (no mask file created)',
|
|
1182
1223
|
feedbackMaskFrom: 'Mask ready: {name}',
|
|
1183
1224
|
feedbackAnnotHint: '{n} boxed note(s) will be sent with this feedback, numbered to match `Annotation N` in the draft',
|
|
1225
|
+
feedbackAnnotPolygonTag: 'Irregular area · {n} points',
|
|
1184
1226
|
feedbackEditTitle: 'Edit: {name}',
|
|
1185
1227
|
feedbackReasonLabel: 'Reason (optional)',
|
|
1186
1228
|
feedbackChangeOnlyLabel: 'Only change (comma separated, optional)',
|
|
@@ -1191,6 +1233,8 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
1191
1233
|
feedbackGenerating: 'Generating…',
|
|
1192
1234
|
feedbackGenerateHint: 'Writes the draft into the composer; you confirm and send it yourself',
|
|
1193
1235
|
feedbackDraftReady: 'Draft written into the composer (not sent). Review it and send when ready.',
|
|
1236
|
+
feedbackDraftAlreadyThere: 'This image is already in the composer; nothing was added twice.',
|
|
1237
|
+
dblClickHint: 'Double-click = write the asset path into the chat input (never auto-sends)',
|
|
1194
1238
|
feedbackDraftInClipboard: 'Draft copied to clipboard (composer channel unavailable) — paste it manually.',
|
|
1195
1239
|
feedbackDraftFailed: 'Could not generate the draft',
|
|
1196
1240
|
feedbackChangeOnly: 'changeOnly',
|
|
@@ -1939,7 +1983,9 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
1939
1983
|
border-radius: 8px;
|
|
1940
1984
|
box-sizing: border-box;
|
|
1941
1985
|
pointer-events: none;
|
|
1942
|
-
|
|
1986
|
+
/* v0.17.0:从 6 降到 5 —— 分类边框不能盖住吸顶的会话标题
|
|
1987
|
+
(组头 z-index 是 10,压低真凶是双保险)。 */
|
|
1988
|
+
z-index: 5;
|
|
1943
1989
|
}
|
|
1944
1990
|
.dg-cardWrap[data-gallery-bucket="final"]::after { border-color: #4a9d5f; }
|
|
1945
1991
|
/* v0.14.2:表态层下线,「已确认 / 待确认」两态合并为单一「定稿」 */
|
|
@@ -2001,7 +2047,11 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
2001
2047
|
.dg-group {
|
|
2002
2048
|
border: 1px solid var(--dsw-alias-border-l1);
|
|
2003
2049
|
border-radius: 8px;
|
|
2004
|
-
|
|
2050
|
+
/* v0.17.0:会话标题吸顶。
|
|
2051
|
+
overflow 必须是 visible —— overflow:hidden 会让 position:sticky 完全失效。
|
|
2052
|
+
圆角改用 clip-path 保住(clip-path 不创建滚动容器,sticky 仍可用)。 */
|
|
2053
|
+
overflow: visible;
|
|
2054
|
+
clip-path: inset(0 round 8px);
|
|
2005
2055
|
background: var(--dsw-alias-bg-layer-1);
|
|
2006
2056
|
}
|
|
2007
2057
|
.dg-groupHead {
|
|
@@ -2012,15 +2062,23 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
2012
2062
|
padding: 9px 11px;
|
|
2013
2063
|
background: var(--dsw-alias-bg-layer-2);
|
|
2014
2064
|
border: none;
|
|
2015
|
-
border-bottom: 1px solid
|
|
2065
|
+
border-bottom: 1px solid var(--dsw-alias-border-l1);
|
|
2016
2066
|
cursor: pointer;
|
|
2017
2067
|
font: inherit;
|
|
2018
2068
|
color: inherit;
|
|
2019
2069
|
text-align: left;
|
|
2020
2070
|
appearance: none;
|
|
2071
|
+
/* v0.17.0:滚动时把当前会话标题钉在面板顶部,方便随时点它折叠。
|
|
2072
|
+
top:-10px 抵消 .dg-body 的 padding:10px(sticky 相对 padding box 定位)。
|
|
2073
|
+
z-index 让它盖住下方内容。 */
|
|
2074
|
+
position: sticky;
|
|
2075
|
+
top: -10px;
|
|
2076
|
+
/* v0.17.0:z-index 必须高于 .dg-cardWrap::after 的 6 ——
|
|
2077
|
+
分类边框(绿/橙/灰)画在伪元素上,z 比组头高就会「穿透」到标题上。
|
|
2078
|
+
取 10:高于卡片内所有元素(组内上限是 .dg-maskNotice 的 7)。 */
|
|
2079
|
+
z-index: 10;
|
|
2021
2080
|
}
|
|
2022
2081
|
.dg-groupHead:hover { background: var(--dsw-alias-bg-layer-3, var(--dsw-alias-bg-layer-2)); }
|
|
2023
|
-
.dg-groupHeadOpen { border-bottom-color: var(--dsw-alias-border-l1); }
|
|
2024
2082
|
.dg-groupArrow {
|
|
2025
2083
|
flex: 0 0 auto;
|
|
2026
2084
|
font-size: 10px;
|
|
@@ -2187,7 +2245,12 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
2187
2245
|
border: 1px solid var(--dsw-alias-border-l1);
|
|
2188
2246
|
font-weight: 500;
|
|
2189
2247
|
}
|
|
2190
|
-
.dg-groupBody {
|
|
2248
|
+
.dg-groupBody {
|
|
2249
|
+
padding: 10px;
|
|
2250
|
+
/* v0.17.0:组内容整体排在吸顶组头之下(跨组时也稳) */
|
|
2251
|
+
position: relative;
|
|
2252
|
+
z-index: 0;
|
|
2253
|
+
}
|
|
2191
2254
|
.dg-groupEmpty {
|
|
2192
2255
|
padding: 14px 10px;
|
|
2193
2256
|
font-size: 12px;
|
|
@@ -2494,6 +2557,29 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
2494
2557
|
.dg-viewerBody { position: relative; flex: 1 1 auto; min-height: 0; min-width: 0; display: flex; align-items: center; justify-content: center; padding: 10px 42px 10px 10px; }
|
|
2495
2558
|
.dg-viewerBody img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
|
|
2496
2559
|
.dg-viewerLayer { position: absolute; inset: 0; z-index: 30; background: var(--dsw-specific-sidebar-fill, #111); display: flex; flex-direction: column; }
|
|
2560
|
+
|
|
2561
|
+
/* ===== v0.17.0 轻提示:写进输入框的结果反馈 =====
|
|
2562
|
+
不打断操作,2.6 秒自动消失;贴在面板底部居中,不遮挡卡片。 */
|
|
2563
|
+
.dg-toast {
|
|
2564
|
+
position: absolute;
|
|
2565
|
+
left: 50%;
|
|
2566
|
+
bottom: 16px;
|
|
2567
|
+
transform: translateX(-50%);
|
|
2568
|
+
z-index: 45;
|
|
2569
|
+
max-width: calc(100% - 32px);
|
|
2570
|
+
padding: 8px 14px;
|
|
2571
|
+
border-radius: 8px;
|
|
2572
|
+
font-size: 12px;
|
|
2573
|
+
line-height: 1.5;
|
|
2574
|
+
text-align: center;
|
|
2575
|
+
pointer-events: none;
|
|
2576
|
+
box-shadow: 0 4px 16px rgba(0, 0, 0, .22);
|
|
2577
|
+
border: 1px solid var(--dsw-alias-border-l1, rgba(255, 255, 255, .12));
|
|
2578
|
+
background: var(--dsw-alias-bg-layer-3, rgba(28, 26, 24, .96));
|
|
2579
|
+
color: var(--dsw-alias-label-primary, #f2efe9);
|
|
2580
|
+
}
|
|
2581
|
+
.dg-toast-ok { border-color: var(--dsw-alias-brand-primary, #4f9d69); }
|
|
2582
|
+
.dg-toast-failed { border-color: var(--dsw-alias-state-error-primary, #d9534f); }
|
|
2497
2583
|
.dg-viewerLayer .dg-viewer { flex: 1 1 auto; min-height: 0; }
|
|
2498
2584
|
.dg-viewerBody { touch-action: none; }
|
|
2499
2585
|
.dg-textBody { display: block; overflow: auto; padding: 12px 14px; user-select: text; touch-action: auto; }
|
|
@@ -3115,6 +3201,15 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
3115
3201
|
border-color: #1d9e75 !important; font-weight: 600;
|
|
3116
3202
|
}
|
|
3117
3203
|
.dg-polyPanelOps .dg-polyClose:disabled { opacity: 0.45; }
|
|
3204
|
+
.dg-polyPanel[data-gallery-poly-mode='note'] { border-color: rgba(255, 209, 102, 0.65); }
|
|
3205
|
+
.dg-polyPanel[data-gallery-poly-mode='note'] .dg-polyPanelHead { color: #ffe08a; }
|
|
3206
|
+
.dg-polyPanelNote { margin-top: 8px; }
|
|
3207
|
+
.dg-polyNoteInput {
|
|
3208
|
+
width: 100%; box-sizing: border-box; background: #10141b; color: #e8eaed;
|
|
3209
|
+
border: 1px solid rgba(255,255,255,0.22); border-radius: 4px;
|
|
3210
|
+
padding: 5px 7px; font-size: 11px; outline: none;
|
|
3211
|
+
}
|
|
3212
|
+
.dg-polyNoteInput:focus { border-color: #5ed696; }
|
|
3118
3213
|
|
|
3119
3214
|
/* v0.16.0 粘贴结果提示 */
|
|
3120
3215
|
.dg-pasteNotice {
|
|
@@ -3556,6 +3651,14 @@ const dragAssetIndex = new Map()
|
|
|
3556
3651
|
const dragMaskByOverlay = new Map()
|
|
3557
3652
|
const dragMaskBySource = new Map()
|
|
3558
3653
|
|
|
3654
|
+
/**
|
|
3655
|
+
* 双击卡片:同一张图「正在处理中」的登记本(模块级,界面重绘也不丢)。
|
|
3656
|
+
* 只用来挡连点 —— 上一次双击的文字/附图还没走完又来一次,两次会同时读到
|
|
3657
|
+
* 「输入框里还没有草稿」,于是文字和缩略图各写两份。处理完立刻摘掉;
|
|
3658
|
+
* 万一某次异常没走到收尾,超过 5 秒自动失效,绝不把这张图永久挡死。
|
|
3659
|
+
*/
|
|
3660
|
+
const doubleClickInFlight = new Map()
|
|
3661
|
+
|
|
3559
3662
|
/**
|
|
3560
3663
|
* 生成拖出 File 的名字(纯函数,测试跑真身)。
|
|
3561
3664
|
* 全角「|」分隔,控制字符清掉,长度夹在 240 以内,避免 DSH 卡片显示被截到看不懂。
|
|
@@ -3884,9 +3987,16 @@ function serializeFeedback(feedback) {
|
|
|
3884
3987
|
await waitFlush()
|
|
3885
3988
|
const before = stateText(ed)
|
|
3886
3989
|
|
|
3887
|
-
//
|
|
3888
|
-
//
|
|
3889
|
-
|
|
3990
|
+
// 双击卡片生成的草稿是「产出台·文件名 | 路径=…」,用整段首段(最长 120 字)判断;
|
|
3991
|
+
// 固定前 24 字会把同一组图(原图 / 主遮罩 / 蓝填充预览)误判成同一份草稿:
|
|
3992
|
+
// 它们的文件名共享很长的前缀,前 24 字完全相同,双击第二张会连文字都不写。
|
|
3993
|
+
// 其它草稿(反馈篮那一大段)不带这个开头,仍用原来的 24 字探针,行为一点不变。
|
|
3994
|
+
// 也不用全串匹配:草稿后面跟了用户自己打的字时会失效。
|
|
3995
|
+
const trimmed = text.trim()
|
|
3996
|
+
const firstSegment = trimmed.split(/[||]/)[0].trim()
|
|
3997
|
+
const headProbe = (firstSegment.startsWith('产出台·') && firstSegment.length >= 8)
|
|
3998
|
+
? firstSegment.slice(0, 120)
|
|
3999
|
+
: trimmed.slice(0, Math.min(24, trimmed.length))
|
|
3890
4000
|
if (before.ok && headProbe !== '' && before.text.includes(headProbe)) {
|
|
3891
4001
|
draftRef.current = text
|
|
3892
4002
|
return { ok: true, via: 'composer', detail: 'already-present' }
|
|
@@ -3907,8 +4017,8 @@ function serializeFeedback(feedback) {
|
|
|
3907
4017
|
return { ok: grew && contains, size: after.size }
|
|
3908
4018
|
}
|
|
3909
4019
|
|
|
3910
|
-
//
|
|
3911
|
-
const probe =
|
|
4020
|
+
// 用于确认「确实插入了本次文本」的探针片段(复用上面的首段,能区分同组图片)
|
|
4021
|
+
const probe = headProbe
|
|
3912
4022
|
|
|
3913
4023
|
// ---- 路径 1:**只发 beforeinput**(不跟 input)----
|
|
3914
4024
|
// ⚠️ 真机实证:beforeinput 与 input 在同一同步块连发时,Lexical 在 flush 前
|
|
@@ -4036,7 +4146,11 @@ function serializeFeedback(feedback) {
|
|
|
4036
4146
|
// 卡已被判「不要这张」时,批注也沿用打回;否则是「只改这个框」
|
|
4037
4147
|
action: mark?.action === 'reject' ? 'reject' : 'redo-one-dim',
|
|
4038
4148
|
reason: note === '' ? undefined : note,
|
|
4039
|
-
region: {
|
|
4149
|
+
region: {
|
|
4150
|
+
x: a.x, y: a.y, w: a.w, h: a.h,
|
|
4151
|
+
// 不规则区域顶点随 region 一起走;草稿仍按外接框说人话
|
|
4152
|
+
...(Array.isArray(a.polygon) ? { polygon: a.polygon } : {}),
|
|
4153
|
+
},
|
|
4040
4154
|
frameOf: it.frameOf,
|
|
4041
4155
|
// 遮罩来源随草稿带出(v0.14.5):由本图框选区域生成的 RGBA 遮罩资产
|
|
4042
4156
|
maskOf: it.maskOf,
|
|
@@ -4175,7 +4289,7 @@ function serializeFeedback(feedback) {
|
|
|
4175
4289
|
}, [
|
|
4176
4290
|
h('div', { className: 'dg-feedbackHead', key: 'head' }, [
|
|
4177
4291
|
h('span', { className: 'dg-feedbackTitle', key: 'title' },
|
|
4178
|
-
|
|
4292
|
+
t('feedbackBasketTitle'),
|
|
4179
4293
|
),
|
|
4180
4294
|
h('button', {
|
|
4181
4295
|
type: 'button', className: 'dg-btn', key: 'close',
|
|
@@ -4239,6 +4353,12 @@ function serializeFeedback(feedback) {
|
|
|
4239
4353
|
: null,
|
|
4240
4354
|
h('span', { className: 'dg-feedbackDim dg-feedbackRegion', key: 'r' },
|
|
4241
4355
|
format(t('feedbackAnnotRegion'), { x: pct(a.x), y: pct(a.y), w: pct(a.w), h: pct(a.h) })),
|
|
4356
|
+
Array.isArray(a.polygon) && a.polygon.length >= 4
|
|
4357
|
+
? h('span', {
|
|
4358
|
+
className: 'dg-feedbackDim', key: 'poly',
|
|
4359
|
+
'data-gallery-feedback-poly': a.polygon.length,
|
|
4360
|
+
}, format(t('feedbackAnnotPolygonTag'), { n: String(a.polygon.length) }))
|
|
4361
|
+
: null,
|
|
4242
4362
|
h('span', { className: 'dg-feedbackNote', key: 'note' },
|
|
4243
4363
|
(typeof a.note === 'string' && a.note.trim() !== '') ? a.note : t('feedbackAnnotNoNote')),
|
|
4244
4364
|
h('span', { className: 'dg-feedbackOps', key: 'ops' }, [
|
|
@@ -4638,7 +4758,7 @@ function serializeFeedback(feedback) {
|
|
|
4638
4758
|
* 音频没有画面,只显示音符图标。
|
|
4639
4759
|
*/
|
|
4640
4760
|
|
|
4641
|
-
function MediaCard({ item, t, absPath, onPlay, onContextMenu }) {
|
|
4761
|
+
function MediaCard({ item, t, absPath, onPlay, onContextMenu, onDoubleClick }) {
|
|
4642
4762
|
const isVideo = item.mediaType === 'video'
|
|
4643
4763
|
const [thumb, setThumb] = React.useState(null)
|
|
4644
4764
|
const nodeRef = React.useRef(null)
|
|
@@ -4741,6 +4861,10 @@ function serializeFeedback(feedback) {
|
|
|
4741
4861
|
'data-gallery-relpath': item.relPath,
|
|
4742
4862
|
'data-gallery-media-type': item.mediaType ?? '',
|
|
4743
4863
|
onClick: () => onPlay(item),
|
|
4864
|
+
// v0.17.0:双击 → 写进输入框
|
|
4865
|
+
onDoubleClick: typeof onDoubleClick === 'function'
|
|
4866
|
+
? (event) => { event.preventDefault(); onDoubleClick(item, event) }
|
|
4867
|
+
: undefined,
|
|
4744
4868
|
onContextMenu: (event) => {
|
|
4745
4869
|
event.preventDefault()
|
|
4746
4870
|
event.stopPropagation()
|
|
@@ -5373,7 +5497,7 @@ function serializeFeedback(feedback) {
|
|
|
5373
5497
|
return MEDIA_ROUTE + '?path=' + encodeURIComponent(relPath) + '&v=' + stamp
|
|
5374
5498
|
}
|
|
5375
5499
|
|
|
5376
|
-
function FileCard({ item, t, absPath, onOpenFolder, onPreview, onContextMenu }) {
|
|
5500
|
+
function FileCard({ item, t, absPath, onOpenFolder, onPreview, onContextMenu, onDoubleClick }) {
|
|
5377
5501
|
const ext = (item.extension ?? '').replace(/^\./, '').toLowerCase()
|
|
5378
5502
|
const badge = (ext === '' ? 'FILE' : ext).slice(0, 4).toUpperCase()
|
|
5379
5503
|
const [copied, setCopied] = React.useState(false)
|
|
@@ -5388,7 +5512,7 @@ function serializeFeedback(feedback) {
|
|
|
5388
5512
|
event.stopPropagation()
|
|
5389
5513
|
// v0.17.0:复制【结构化信息】而不是裸路径 —— 与拖图带的信息同格式,
|
|
5390
5514
|
// 粘到对话框里,Agent 一次就拿到 文件名 / 绝对路径 / 主遮罩。
|
|
5391
|
-
const name = dragNameOf(item, absPath)
|
|
5515
|
+
const name = dragNameOf(item, absPath)
|
|
5392
5516
|
const ok = await copyText(name)
|
|
5393
5517
|
setCopied(ok)
|
|
5394
5518
|
}
|
|
@@ -5409,6 +5533,10 @@ function serializeFeedback(feedback) {
|
|
|
5409
5533
|
${absPath}
|
|
5410
5534
|
点击在 DSH 右侧栏预览`,
|
|
5411
5535
|
onClick: () => onPreview(absPath),
|
|
5536
|
+
// v0.17.0:双击 → 写进输入框
|
|
5537
|
+
onDoubleClick: typeof onDoubleClick === 'function'
|
|
5538
|
+
? (event) => { event.preventDefault(); onDoubleClick(item, event) }
|
|
5539
|
+
: undefined,
|
|
5412
5540
|
onContextMenu: (event) => {
|
|
5413
5541
|
event.preventDefault()
|
|
5414
5542
|
event.stopPropagation()
|
|
@@ -5458,9 +5586,14 @@ ${absPath}
|
|
|
5458
5586
|
}
|
|
5459
5587
|
|
|
5460
5588
|
/** 单张缩略图卡片:独立加载、独立失败,互不影响。 */
|
|
5461
|
-
function Card({ item, t, onOpen, limiter, onContextMenu }) {
|
|
5589
|
+
function Card({ item, t, onOpen, limiter, onContextMenu, onDoubleClick }) {
|
|
5462
5590
|
const [state, setState] = React.useState({ status: 'pending' })
|
|
5463
5591
|
const [node, setNode] = React.useState(null)
|
|
5592
|
+
// v0.17.0:单击延迟计时器(双击时取消,避免「闪一下大图」)
|
|
5593
|
+
const clickTimer = React.useRef(null)
|
|
5594
|
+
React.useEffect(() => () => {
|
|
5595
|
+
if (clickTimer.current !== null) clearTimeout(clickTimer.current)
|
|
5596
|
+
}, [])
|
|
5464
5597
|
|
|
5465
5598
|
React.useEffect(() => {
|
|
5466
5599
|
if (node === null) return undefined
|
|
@@ -5527,7 +5660,27 @@ ${absPath}
|
|
|
5527
5660
|
'data-gallery-card': item.relPath,
|
|
5528
5661
|
'data-gallery-relpath': item.relPath,
|
|
5529
5662
|
'data-gallery-category': item.category || '',
|
|
5530
|
-
|
|
5663
|
+
// v0.17.0:单击延迟 220ms 才开查看器。
|
|
5664
|
+
// 双击 = 写进输入框;浏览器会先发两次 click 再发 dblclick,
|
|
5665
|
+
// 若立即开查看器,用户会看到「闪一下大图又被关掉」。
|
|
5666
|
+
// 第二次 click(event.detail > 1)取消计时器 → 查看器从未打开。
|
|
5667
|
+
onClick: (event) => {
|
|
5668
|
+
if (typeof onDoubleClick !== 'function') { onOpen(item, event.currentTarget); return }
|
|
5669
|
+
if (event.detail > 1) {
|
|
5670
|
+
if (clickTimer.current !== null) { clearTimeout(clickTimer.current); clickTimer.current = null }
|
|
5671
|
+
return
|
|
5672
|
+
}
|
|
5673
|
+
if (clickTimer.current !== null) clearTimeout(clickTimer.current)
|
|
5674
|
+
const anchor = event.currentTarget
|
|
5675
|
+
clickTimer.current = setTimeout(() => {
|
|
5676
|
+
clickTimer.current = null
|
|
5677
|
+
onOpen(item, anchor)
|
|
5678
|
+
}, 220)
|
|
5679
|
+
},
|
|
5680
|
+
// v0.17.0:双击 → 把「文件名 + 绝对路径 + 主遮罩」写进输入框草稿
|
|
5681
|
+
onDoubleClick: typeof onDoubleClick === 'function'
|
|
5682
|
+
? (event) => { event.preventDefault(); onDoubleClick(item, event) }
|
|
5683
|
+
: undefined,
|
|
5531
5684
|
onContextMenu: (event) => {
|
|
5532
5685
|
event.preventDefault()
|
|
5533
5686
|
event.stopPropagation()
|
|
@@ -6436,6 +6589,8 @@ ${absPath}
|
|
|
6436
6589
|
},
|
|
6437
6590
|
}, cropActive ? `✂ ${t('cropExit')}` : `✂ ${t('cropEnter')}`)
|
|
6438
6591
|
: null,
|
|
6592
|
+
// 「拖到对话」确定性入口:Viewer 大图本身 draggable:false + pointerEvents:none
|
|
6593
|
+
// (标注态的中键平移 / 右键多边形都依赖它),所以不改大图,另给一个可拖按钮。
|
|
6439
6594
|
// v0.17.0:删掉查看器顶部的「⇥ 拖到对话」按钮。
|
|
6440
6595
|
// 原来它存在是因为 Viewer 大图本身 draggable:false + pointerEvents:none
|
|
6441
6596
|
// (标注态的中键平移 / 右键多边形都依赖它),需要一个可拖的把手。
|
|
@@ -6580,7 +6735,9 @@ ${absPath}
|
|
|
6580
6735
|
* 设计要点:
|
|
6581
6736
|
* · 坐标全部归一化(0–1,相对图片宽高),见 shared/protocol.js 的 ANNOTATION_* 契约
|
|
6582
6737
|
* · SVG 覆盖在图片之上;不干扰查看器原有的缩放/平移(只有「批注模式」下才接管指针)
|
|
6583
|
-
* ·
|
|
6738
|
+
* · 左键按住拖拽画矩形 → 亮框**一直留着**直到保存/取消 → 输入框写说明 → 存进批注列表
|
|
6739
|
+
* · 左键单击逐点圈不规则区域 → 闭合后直接进反馈篮(不生成遮罩文件),可顺手写一句说明
|
|
6740
|
+
* · 右键单击逐点圈选区 → 闭合成实心多边形 → 导出遮罩 + 彩色填充预览
|
|
6584
6741
|
* · 已存在的批注按归一化坐标还原绘制,带编号,缩放/换屏都不失真
|
|
6585
6742
|
* · 批注不发送任何东西;出口是与决策草稿同一通道(见 05-feedback.js)
|
|
6586
6743
|
*
|
|
@@ -6592,7 +6749,8 @@ ${absPath}
|
|
|
6592
6749
|
*
|
|
6593
6750
|
* v0.14.2 修:
|
|
6594
6751
|
* ⑤ 弹窗开着时第二处按不下:改为一按下就先把当前草稿存档,可连续圈多处
|
|
6595
|
-
* ⑥
|
|
6752
|
+
* ⑥ 「点两下成矩形」已于 2026-11-15 作废:左键单击改为「逐点闭合区域标记」。
|
|
6753
|
+
* 现在左键只有按住拖动才画矩形;单击是给不规则区域加一个顶点。
|
|
6596
6754
|
*
|
|
6597
6755
|
* v0.14.4 本地热修:
|
|
6598
6756
|
* ⑦ SVG 原先覆盖整个预览容器且不带 transform,图片却是 contain 居中后单独
|
|
@@ -6605,14 +6763,17 @@ ${absPath}
|
|
|
6605
6763
|
function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, frameMs, zoom, pan, imgBox, transformTransition, onExportMask }) {
|
|
6606
6764
|
const [draft, setDraft] = React.useState(null)
|
|
6607
6765
|
const [editing, setEditing] = React.useState(null)
|
|
6608
|
-
/** 已点下第一下、等第二下定终点时的起点(归一化坐标)。 */
|
|
6609
|
-
const [pendingStart, setPendingStart] = React.useState(null)
|
|
6610
6766
|
const svgRef = React.useRef(null)
|
|
6767
|
+
/** 左键按下时记起点与「有没有真拖动」:拖动=矩形,没拖动=一个区域顶点。 */
|
|
6768
|
+
const dragStartRef = React.useRef(null)
|
|
6611
6769
|
/** 遮罩导出提示(成功/失败),2.5 秒自动消失。 */
|
|
6612
6770
|
const [maskNotice, setMaskNotice] = React.useState(null)
|
|
6613
6771
|
const [maskBusy, setMaskBusy] = React.useState(false)
|
|
6614
|
-
/**
|
|
6772
|
+
/** 多边形选区:mask(右键→填充遮罩) / note(左键单击→区域标记进反馈篮),互斥共用一组顶点。 */
|
|
6615
6773
|
const [poly, setPoly] = React.useState([])
|
|
6774
|
+
const [polyMode, setPolyMode] = React.useState('mask')
|
|
6775
|
+
/** 不规则区域可以顺手写一句说明(可留空),只随反馈走,不生成任何文件。 */
|
|
6776
|
+
const [polyNote, setPolyNote] = React.useState('')
|
|
6616
6777
|
const [polyHover, setPolyHover] = React.useState(null)
|
|
6617
6778
|
const [polyDrag, setPolyDrag] = React.useState(null)
|
|
6618
6779
|
/** v0.14.7 选区填充色(红 / 绿 / 蓝),同时决定导出的彩色预览图颜色。 */
|
|
@@ -6642,12 +6803,22 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
6642
6803
|
.finally(() => setMaskBusy(false))
|
|
6643
6804
|
}
|
|
6644
6805
|
|
|
6806
|
+
/** 清掉没闭合的多边形草稿,模式复位到右键(填充遮罩)。 */
|
|
6807
|
+
const resetPoly = () => {
|
|
6808
|
+
setPoly([])
|
|
6809
|
+
setPolyHover(null)
|
|
6810
|
+
setPolyDrag(null)
|
|
6811
|
+
setPolyNote('')
|
|
6812
|
+
setPolyMode('mask')
|
|
6813
|
+
}
|
|
6814
|
+
|
|
6645
6815
|
/**
|
|
6646
|
-
* 闭合多边形 →
|
|
6647
|
-
*
|
|
6648
|
-
*
|
|
6816
|
+
* 闭合多边形 → 分两条路,绝不混:
|
|
6817
|
+
* · mask(右键):立刻生成遮罩资产 + 彩色填充预览(老行为,零自动发送)
|
|
6818
|
+
* · note(左键单击):只加一条「不规则区域」批注,直接进反馈篮,不落盘任何图片
|
|
6819
|
+
* 老板 2026-11-15 拍板:左键圈出来的区域是「给人 / 给助手看的标记」,不是遮罩文件。
|
|
6649
6820
|
*/
|
|
6650
|
-
const commitPolygon = (points) => {
|
|
6821
|
+
const commitPolygon = (points, mode = polyMode) => {
|
|
6651
6822
|
if (points.length < POLYGON_LIMITS.min) {
|
|
6652
6823
|
setMaskNotice({ kind: 'failed', text: t('polyTooFew') })
|
|
6653
6824
|
return
|
|
@@ -6657,13 +6828,21 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
6657
6828
|
return
|
|
6658
6829
|
}
|
|
6659
6830
|
const box = polygonBBox(points)
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6831
|
+
const verts = points.map((p) => [clamp01(p.x), clamp01(p.y)])
|
|
6832
|
+
resetPoly()
|
|
6833
|
+
if (mode === 'note') {
|
|
6834
|
+
const normalized = normalizeAnnotation({
|
|
6835
|
+
shape: 'polygon', ...box, polygon: verts,
|
|
6836
|
+
fillColor, note: polyNote, frameMs: frameMs ?? null,
|
|
6837
|
+
})
|
|
6838
|
+
if (normalized !== null && typeof onAdd === 'function') onAdd(normalized)
|
|
6839
|
+
setMaskNotice({ kind: 'ok', text: t('polyNoteSaved') })
|
|
6840
|
+
return
|
|
6841
|
+
}
|
|
6663
6842
|
runExportMask({
|
|
6664
6843
|
shape: 'polygon',
|
|
6665
6844
|
...box,
|
|
6666
|
-
polygon:
|
|
6845
|
+
polygon: verts,
|
|
6667
6846
|
fillColor,
|
|
6668
6847
|
note: '',
|
|
6669
6848
|
})
|
|
@@ -6678,30 +6857,27 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
6678
6857
|
|| (typeof el.closest === 'function' && el.closest('[data-gallery-annot-editor]') !== null))) return
|
|
6679
6858
|
if (e.key === 'Enter' && poly.length >= POLYGON_LIMITS.min) {
|
|
6680
6859
|
e.preventDefault()
|
|
6681
|
-
commitPolygon(poly)
|
|
6860
|
+
commitPolygon(poly, polyMode)
|
|
6682
6861
|
} else if (e.key === 'Backspace') {
|
|
6683
6862
|
e.preventDefault()
|
|
6684
6863
|
setPoly((cur) => cur.slice(0, -1))
|
|
6685
6864
|
setPolyHover(null)
|
|
6686
6865
|
} else if (e.key === 'Escape') {
|
|
6687
6866
|
e.preventDefault()
|
|
6688
|
-
|
|
6689
|
-
setPolyHover(null)
|
|
6867
|
+
resetPoly()
|
|
6690
6868
|
}
|
|
6691
6869
|
}
|
|
6692
6870
|
window.addEventListener('keydown', onKey)
|
|
6693
6871
|
return () => window.removeEventListener('keydown', onKey)
|
|
6694
|
-
}, [active, poly, editing])
|
|
6872
|
+
}, [active, poly, editing, polyMode])
|
|
6695
6873
|
|
|
6696
6874
|
/** 退出标注模式时清掉未保存的草稿,避免输入框/虚线框/顶点残留。 */
|
|
6697
6875
|
React.useEffect(() => {
|
|
6698
6876
|
if (active) return undefined
|
|
6699
6877
|
setDraft(null)
|
|
6700
6878
|
setEditing(null)
|
|
6701
|
-
|
|
6702
|
-
|
|
6703
|
-
setPolyHover(null)
|
|
6704
|
-
setPolyDrag(null)
|
|
6879
|
+
dragStartRef.current = null
|
|
6880
|
+
resetPoly()
|
|
6705
6881
|
return undefined
|
|
6706
6882
|
}, [active])
|
|
6707
6883
|
|
|
@@ -6730,7 +6906,6 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
6730
6906
|
const clearPending = () => {
|
|
6731
6907
|
setDraft(null)
|
|
6732
6908
|
setEditing(null)
|
|
6733
|
-
setPendingStart(null)
|
|
6734
6909
|
}
|
|
6735
6910
|
|
|
6736
6911
|
/**
|
|
@@ -6749,70 +6924,76 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
6749
6924
|
// 不能直接塞 {x,y,w,h},否则 Math.min(undefined) → NaN%,框画不出来。
|
|
6750
6925
|
setDraft({ x0: box.x, y0: box.y, x1: box.x + box.w, y1: box.y + box.h })
|
|
6751
6926
|
setEditing({ shape: 'rect', ...box, note: '', frameMs: frameMs ?? null })
|
|
6752
|
-
|
|
6927
|
+
}
|
|
6928
|
+
|
|
6929
|
+
/** 逐点采集一个多边形;mode 决定闭合后去哪儿,两套选区互斥、切换时清空旧点。 */
|
|
6930
|
+
const addPolygonPoint = (p, mode) => {
|
|
6931
|
+
const switching = polyMode !== mode || poly.length === 0
|
|
6932
|
+
const cur = switching ? [] : poly
|
|
6933
|
+
if (switching) {
|
|
6934
|
+
setPolyMode(mode)
|
|
6935
|
+
setPolyNote('')
|
|
6936
|
+
setPolyHover(null)
|
|
6937
|
+
setPolyDrag(null)
|
|
6938
|
+
}
|
|
6939
|
+
const first = cur[0]
|
|
6940
|
+
const nearFirst = cur.length >= POLYGON_LIMITS.min && first !== undefined
|
|
6941
|
+
&& Math.hypot(p.x - first.x, p.y - first.y) <= POLYGON_LIMITS.closeRadius
|
|
6942
|
+
if (nearFirst || cur.length >= POLYGON_LIMITS.max) {
|
|
6943
|
+
commitPolygon(cur, mode)
|
|
6944
|
+
return
|
|
6945
|
+
}
|
|
6946
|
+
const next = [...cur, p]
|
|
6947
|
+
setPoly(next)
|
|
6948
|
+
setPolyHover(null)
|
|
6949
|
+
if (next.length >= POLYGON_LIMITS.max) commitPolygon(next, mode)
|
|
6753
6950
|
}
|
|
6754
6951
|
|
|
6755
6952
|
const onPointerDown = (event) => {
|
|
6756
|
-
// 中键(1)
|
|
6757
|
-
// 若继续对所有按键 stopPropagation,中键会被吞、标注时挪不动图。
|
|
6953
|
+
// 中键(1)放行给查看器原生拖拽平移;左键(0)/右键(2)才由标注层接管。
|
|
6758
6954
|
if (annotationPointerRouting(active, event.button) !== 'draw') return
|
|
6759
6955
|
// 放大状态下查看器会在 pointerdown 里 setPointerCapture;这里必须拦住冒泡,
|
|
6760
6956
|
// 否则弹窗内的输入框/按钮会被「拖图」逻辑抢走,表现为点击无反应。
|
|
6761
6957
|
event.stopPropagation()
|
|
6762
|
-
// 右键(2)
|
|
6763
|
-
// 左键矩形批注与右键多边形互斥,避免两套草稿同时活着互相打架。
|
|
6958
|
+
// 右键(2):填充遮罩选区逐点采集(4–20 点)。点回首点 / 满 20 点 / Enter / 面板按钮都可闭合。
|
|
6764
6959
|
if (event.button === 2) {
|
|
6765
6960
|
event.preventDefault()
|
|
6766
6961
|
const p = toNorm(event)
|
|
6767
6962
|
if (p === null) return
|
|
6768
6963
|
clearPending()
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
&& Math.hypot(p.x - first.x, p.y - first.y) <= POLYGON_LIMITS.closeRadius
|
|
6772
|
-
if (nearFirst || poly.length >= POLYGON_LIMITS.max) {
|
|
6773
|
-
commitPolygon(poly)
|
|
6774
|
-
return
|
|
6775
|
-
}
|
|
6776
|
-
const next = [...poly, p]
|
|
6777
|
-
setPoly(next)
|
|
6778
|
-
setPolyHover(null)
|
|
6779
|
-
if (next.length >= POLYGON_LIMITS.max) commitPolygon(next)
|
|
6964
|
+
dragStartRef.current = null
|
|
6965
|
+
addPolygonPoint(p, 'mask')
|
|
6780
6966
|
return
|
|
6781
6967
|
}
|
|
6782
6968
|
if (event.button !== 0) return
|
|
6783
6969
|
const p = toNorm(event)
|
|
6784
6970
|
if (p === null) return
|
|
6785
6971
|
event.preventDefault()
|
|
6786
|
-
if (poly.length > 0) {
|
|
6787
|
-
setPoly([])
|
|
6788
|
-
setPolyHover(null)
|
|
6789
|
-
setPolyDrag(null)
|
|
6790
|
-
}
|
|
6791
6972
|
try { event.currentTarget.setPointerCapture(event.pointerId) } catch { /* 忽略 */ }
|
|
6792
|
-
|
|
6793
|
-
// 上一处还在输入 → 先存档,第二处才按得下去(v0.14.2 ⑤)
|
|
6973
|
+
// 上一处还在输入 → 先存档,下一处才按得下去(v0.14.2 ⑤)
|
|
6794
6974
|
if (editing !== null) commitEditing()
|
|
6795
|
-
|
|
6796
|
-
//
|
|
6797
|
-
|
|
6798
|
-
const box = rectFrom(pendingStart, p)
|
|
6799
|
-
if (isValidBox(box)) {
|
|
6800
|
-
beginEdit(box)
|
|
6801
|
-
} else {
|
|
6802
|
-
// 两次点到同一处:把起点挪到新位置,继续等第二下
|
|
6803
|
-
setPendingStart(p)
|
|
6804
|
-
setDraft({ x0: p.x, y0: p.y, x1: p.x, y1: p.y })
|
|
6805
|
-
}
|
|
6806
|
-
return
|
|
6807
|
-
}
|
|
6808
|
-
|
|
6809
|
-
setPendingStart(p)
|
|
6810
|
-
setDraft({ x0: p.x, y0: p.y, x1: p.x, y1: p.y })
|
|
6975
|
+
// 先只记起点:松手时才判定「拖过=矩形」还是「没拖=一个区域顶点」。
|
|
6976
|
+
// 这样单纯点一下不会闪出虚线框,也不会再出现「点两下成矩形」。
|
|
6977
|
+
dragStartRef.current = { start: p, moved: false }
|
|
6811
6978
|
}
|
|
6812
6979
|
|
|
6813
6980
|
const onPointerMove = (event) => {
|
|
6814
|
-
//
|
|
6981
|
+
// 中键平移进行中:标注层一律不插手,让查看器独占指针
|
|
6815
6982
|
if (dragging) return
|
|
6983
|
+
const gesture = dragStartRef.current
|
|
6984
|
+
// 左键按下还没判定:移动超过阈值才算「拖框」,此刻才建立矩形草稿
|
|
6985
|
+
if (gesture !== null && !gesture.moved) {
|
|
6986
|
+
const p = toNorm(event)
|
|
6987
|
+
if (p === null) return
|
|
6988
|
+
if (Math.hypot(p.x - gesture.start.x, p.y - gesture.start.y) < ANNOT_DRAG_THRESHOLD) return
|
|
6989
|
+
gesture.moved = true
|
|
6990
|
+
// 真拖动=矩形批注,先撤掉没闭合的多边形草稿,两套选区不混着画
|
|
6991
|
+
resetPoly()
|
|
6992
|
+
setDraft({ x0: gesture.start.x, y0: gesture.start.y, x1: p.x, y1: p.y })
|
|
6993
|
+
event.stopPropagation()
|
|
6994
|
+
event.preventDefault()
|
|
6995
|
+
return
|
|
6996
|
+
}
|
|
6816
6997
|
// 多边形橡皮筋:只在没有矩形草稿、没有说明弹窗时跟随指针
|
|
6817
6998
|
if (active && poly.length > 0 && draft === null && editing === null) {
|
|
6818
6999
|
event.stopPropagation()
|
|
@@ -6830,17 +7011,22 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
6830
7011
|
|
|
6831
7012
|
const finishDraft = (event) => {
|
|
6832
7013
|
if (dragging) return
|
|
6833
|
-
|
|
7014
|
+
const gesture = dragStartRef.current
|
|
7015
|
+
if (gesture === null) return
|
|
7016
|
+
dragStartRef.current = null
|
|
6834
7017
|
event.preventDefault()
|
|
6835
7018
|
event.stopPropagation()
|
|
6836
|
-
const
|
|
6837
|
-
if (!
|
|
6838
|
-
//
|
|
6839
|
-
setPendingStart({ x: draft.x0, y: draft.y0 })
|
|
7019
|
+
const p = toNorm(event) ?? gesture.start
|
|
7020
|
+
if (!gesture.moved) {
|
|
7021
|
+
// 单纯点一下 = 不规则区域的一个顶点;点回起点 / 满 20 点即闭合进反馈篮
|
|
6840
7022
|
setDraft(null)
|
|
7023
|
+
addPolygonPoint(p, 'note')
|
|
6841
7024
|
return
|
|
6842
7025
|
}
|
|
6843
|
-
//
|
|
7026
|
+
// 拖出来的矩形:亮框不清,输入框弹出期间图上必须仍看得见刚圈的位置
|
|
7027
|
+
const box = rectFrom(gesture.start, p)
|
|
7028
|
+
setDraft(null)
|
|
7029
|
+
if (!isValidBox(box)) return
|
|
6844
7030
|
beginEdit(box)
|
|
6845
7031
|
}
|
|
6846
7032
|
|
|
@@ -6918,7 +7104,7 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
6918
7104
|
])
|
|
6919
7105
|
})
|
|
6920
7106
|
|
|
6921
|
-
// ----
|
|
7107
|
+
// ---- 正在拖的矩形(保存前一直可见);单击加顶点不画虚线框 ----
|
|
6922
7108
|
const draftShape = draft !== null
|
|
6923
7109
|
? (() => {
|
|
6924
7110
|
const x = Math.min(draft.x0, draft.x1)
|
|
@@ -6934,21 +7120,9 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
6934
7120
|
}, t('annotPendingTag')),
|
|
6935
7121
|
])
|
|
6936
7122
|
})()
|
|
6937
|
-
:
|
|
6938
|
-
? h('g', { key: 'startPoint' }, [
|
|
6939
|
-
h('circle', {
|
|
6940
|
-
cx: (pendingStart.x * 100) + '%', cy: (pendingStart.y * 100) + '%', r: 5,
|
|
6941
|
-
fill: '#ffd166', stroke: '#000', strokeWidth: 1.5,
|
|
6942
|
-
}),
|
|
6943
|
-
h('text', {
|
|
6944
|
-
x: (pendingStart.x * 100) + '%', y: (pendingStart.y * 100) + '%',
|
|
6945
|
-
dx: 9, dy: 4, fill: '#ffe08a', fontSize: 12, stroke: '#000', strokeWidth: 0.6,
|
|
6946
|
-
style: { paintOrder: 'stroke' },
|
|
6947
|
-
}, t('annotStartTag')),
|
|
6948
|
-
])
|
|
6949
|
-
: null)
|
|
7123
|
+
: null
|
|
6950
7124
|
|
|
6951
|
-
/**
|
|
7125
|
+
/** 多边形预览:实心半透明填充 + 可拖顶点 + 橡皮筋(点回首点即闭合),两种模式共用。 */
|
|
6952
7126
|
const polyShape = poly.length === 0 ? null : (() => {
|
|
6953
7127
|
const toPx = (p) => [p.x * boxW, p.y * boxH]
|
|
6954
7128
|
const pts = poly.map(toPx)
|
|
@@ -6978,6 +7152,9 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
6978
7152
|
'data-gallery-poly-vertex': String(idx),
|
|
6979
7153
|
onPointerDown: (e) => {
|
|
6980
7154
|
if (e.button !== 0) return
|
|
7155
|
+
// 点回起点=闭合选区,别被「拖顶点」抢走:首点在够点数时放行,
|
|
7156
|
+
// 事件冒泡到 SVG 的 pointerdown/pointerup,由 addPolygonPoint 判闭合。
|
|
7157
|
+
if (idx === 0 && poly.length >= POLYGON_LIMITS.min) return
|
|
6981
7158
|
e.stopPropagation()
|
|
6982
7159
|
e.preventDefault()
|
|
6983
7160
|
setPolyDrag(idx)
|
|
@@ -7014,11 +7191,14 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
7014
7191
|
|
|
7015
7192
|
/** 多边形选区操作条:点数 / 外接框 / 面积实时可见,闭合前可撤销、可清空。 */
|
|
7016
7193
|
const polyBox = poly.length > 0 ? polygonBBox(poly) : null
|
|
7194
|
+
const isNoteMode = polyMode === 'note'
|
|
7017
7195
|
const polyPanel = poly.length === 0 ? null : h('div', {
|
|
7018
|
-
className: 'dg-polyPanel', key: 'polyPanel',
|
|
7196
|
+
className: 'dg-polyPanel', key: 'polyPanel',
|
|
7197
|
+
'data-gallery-poly-panel': true,
|
|
7198
|
+
'data-gallery-poly-mode': polyMode,
|
|
7019
7199
|
...blockViewer,
|
|
7020
7200
|
}, [
|
|
7021
|
-
h('div', { className: 'dg-polyPanelHead', key: 'h' }, t('polyTitle')),
|
|
7201
|
+
h('div', { className: 'dg-polyPanelHead', key: 'h' }, t(isNoteMode ? 'polyNoteTitle' : 'polyTitle')),
|
|
7022
7202
|
h('div', { className: 'dg-polyPanelInfo', key: 'i', 'data-gallery-poly-info': true },
|
|
7023
7203
|
format(t('polyInfo'), {
|
|
7024
7204
|
n: String(poly.length), max: String(POLYGON_LIMITS.max),
|
|
@@ -7026,7 +7206,18 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
7026
7206
|
w: Math.round(polyBox.w * 100), h: Math.round(polyBox.h * 100),
|
|
7027
7207
|
area: (polygonArea(poly) * 100).toFixed(2),
|
|
7028
7208
|
})),
|
|
7029
|
-
h('div', { className: 'dg-polyPanelHint', key: 'p' }, t('polyHint')),
|
|
7209
|
+
h('div', { className: 'dg-polyPanelHint', key: 'p' }, t(isNoteMode ? 'polyNoteHint' : 'polyHint')),
|
|
7210
|
+
// 只有「区域标记」模式才给说明框:遮罩导出不需要文字,也别把说明塞进文件名
|
|
7211
|
+
isNoteMode ? h('div', { className: 'dg-polyPanelNote', key: 'note' },
|
|
7212
|
+
h('input', {
|
|
7213
|
+
type: 'text', className: 'dg-polyNoteInput',
|
|
7214
|
+
'data-gallery-poly-note': true,
|
|
7215
|
+
placeholder: t('polyNotePlaceholder'),
|
|
7216
|
+
value: polyNote, maxLength: 500,
|
|
7217
|
+
// 字母 / 退格 / 回车都归输入框,别被查看器全局快捷键与闭合监听抢走
|
|
7218
|
+
onKeyDown: (e) => e.stopPropagation(),
|
|
7219
|
+
onChange: (e) => setPolyNote(e.target.value),
|
|
7220
|
+
})) : null,
|
|
7030
7221
|
h('div', { className: 'dg-polyColors', key: 'colors', 'data-gallery-poly-colors': true }, [
|
|
7031
7222
|
h('span', { className: 'dg-polyColorsLabel', key: 'l' }, t('polyFillColor')),
|
|
7032
7223
|
...MASK_FILL_KEYS.map((k) => h('button', {
|
|
@@ -7052,15 +7243,15 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
7052
7243
|
type: 'button', className: 'dg-btn dg-btnSmall', key: 'c',
|
|
7053
7244
|
onClick: (e) => {
|
|
7054
7245
|
e.stopPropagation(); e.preventDefault()
|
|
7055
|
-
|
|
7246
|
+
resetPoly()
|
|
7056
7247
|
},
|
|
7057
7248
|
}, t('polyClear')),
|
|
7058
7249
|
h('button', {
|
|
7059
7250
|
type: 'button', className: 'dg-btn dg-btnSmall dg-polyClose', key: 's',
|
|
7060
7251
|
'data-gallery-poly-close': true,
|
|
7061
|
-
disabled: maskBusy || poly.length < POLYGON_LIMITS.min,
|
|
7062
|
-
onClick: (e) => { e.stopPropagation(); e.preventDefault(); commitPolygon(poly) },
|
|
7063
|
-
}, t('polyClose')),
|
|
7252
|
+
disabled: (isNoteMode ? false : maskBusy) || poly.length < POLYGON_LIMITS.min,
|
|
7253
|
+
onClick: (e) => { e.stopPropagation(); e.preventDefault(); commitPolygon(poly, polyMode) },
|
|
7254
|
+
}, t(isNoteMode ? 'polyNoteClose' : 'polyClose')),
|
|
7064
7255
|
]),
|
|
7065
7256
|
])
|
|
7066
7257
|
|
|
@@ -7155,7 +7346,7 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
7155
7346
|
onPointerDown,
|
|
7156
7347
|
onPointerMove,
|
|
7157
7348
|
onPointerUp: finishDraft,
|
|
7158
|
-
onPointerCancel: () => { setDraft(null);
|
|
7349
|
+
onPointerCancel: () => { setDraft(null); dragStartRef.current = null },
|
|
7159
7350
|
onClick: active ? (event) => { event.preventDefault(); event.stopPropagation() } : undefined,
|
|
7160
7351
|
onContextMenu: active ? (event) => { event.preventDefault(); event.stopPropagation() } : undefined,
|
|
7161
7352
|
}, [draftShape, polyShape, ...shapes]),
|
|
@@ -7584,6 +7775,114 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
7584
7775
|
function GalleryBody(props) {
|
|
7585
7776
|
const { t, sessionId } = props
|
|
7586
7777
|
const [view, setView] = React.useState({ status: 'loading' })
|
|
7778
|
+
// v0.17.0:本面板自己的轻提示(写进输入框的结果反馈)。
|
|
7779
|
+
// 不能用 FeedbackBasket 的 setNotice —— 那是另一个组件的局部 state。
|
|
7780
|
+
const [toast, setToast] = React.useState(null)
|
|
7781
|
+
const toastTimer = React.useRef(null)
|
|
7782
|
+
const showToast = React.useCallback((kind, text) => {
|
|
7783
|
+
setToast({ kind, text })
|
|
7784
|
+
if (toastTimer.current !== null) clearTimeout(toastTimer.current)
|
|
7785
|
+
toastTimer.current = setTimeout(() => {
|
|
7786
|
+
toastTimer.current = null
|
|
7787
|
+
setToast(null)
|
|
7788
|
+
}, 2600)
|
|
7789
|
+
}, [])
|
|
7790
|
+
React.useEffect(() => () => {
|
|
7791
|
+
if (toastTimer.current !== null) clearTimeout(toastTimer.current)
|
|
7792
|
+
}, [])
|
|
7793
|
+
|
|
7794
|
+
/**
|
|
7795
|
+
* v0.17.0:把「文件名 + 绝对路径 + 主遮罩」写进输入框草稿。
|
|
7796
|
+
*
|
|
7797
|
+
* 为什么用输入框而不是剪贴板:DSH 的拖放通道会把 : \ | 等字符洗成 _,
|
|
7798
|
+
* Windows 绝对路径传过去必然残缺;双击 / 右键走 composer 纯文本,路径原样送达。
|
|
7799
|
+
*
|
|
7800
|
+
* 绝不自动发送:只写草稿,发送由人自己按。
|
|
7801
|
+
*/
|
|
7802
|
+
/**
|
|
7803
|
+
* 阶段 3 / C2:双击时把图片本体也放进输入框(尽力而为)。
|
|
7804
|
+
*
|
|
7805
|
+
* 宿主对话输入框的粘贴处理会同时读「文件」和「纯文本」;这里只放文件,
|
|
7806
|
+
* 不带 text/plain,所以不会把上面那段文字重复插一遍。
|
|
7807
|
+
* 合成事件有三处没经过真机实证(宿主内部实现、Electron 对合成 File 取路径、
|
|
7808
|
+
* 覆盖 clipboardData),因此全程 try/catch:失败就只是「没附图」,
|
|
7809
|
+
* 文字草稿、发送按钮、既有双击行为一律不受影响。
|
|
7810
|
+
*
|
|
7811
|
+
* 红线:绝不调用发送,也不写任何业务数据。
|
|
7812
|
+
*/
|
|
7813
|
+
const isImageRel = (rel) => /\.(png|jpe?g|webp|bmp|gif|avif|tiff?)$/i.test(String(rel ?? ''))
|
|
7814
|
+
|
|
7815
|
+
async function attachAssetImageToComposer(target) {
|
|
7816
|
+
const relPath = String(target?.relPath ?? '')
|
|
7817
|
+
if (!isImageRel(relPath)) return { ok: false, reason: 'not-image' }
|
|
7818
|
+
const composer = document.querySelector('[data-composer-input][data-lexical-editor="true"]')
|
|
7819
|
+
?? document.querySelector('[data-lexical-editor="true"]')
|
|
7820
|
+
if (composer === null) return { ok: false, reason: 'no-composer' }
|
|
7821
|
+
try {
|
|
7822
|
+
const response = await fetch(mediaUrlOf(relPath, target?.mtime), { credentials: 'same-origin' })
|
|
7823
|
+
if (!response.ok) return { ok: false, reason: 'fetch-' + response.status }
|
|
7824
|
+
const blob = await response.blob()
|
|
7825
|
+
if (!(blob.size > 0) || blob.size > 20 * 1024 * 1024) {
|
|
7826
|
+
return { ok: false, reason: 'size' }
|
|
7827
|
+
}
|
|
7828
|
+
const name = String(target?.name ?? relPath.split('/').pop() ?? 'image.png')
|
|
7829
|
+
const file = new File([blob], name, { type: blob.type || 'image/png' })
|
|
7830
|
+
const dt = new DataTransfer()
|
|
7831
|
+
dt.items.add(file)
|
|
7832
|
+
const ev = new ClipboardEvent('paste', { bubbles: true, cancelable: true })
|
|
7833
|
+
Object.defineProperty(ev, 'clipboardData', { value: dt, configurable: true })
|
|
7834
|
+
ev.__dshGallerySynthetic = true
|
|
7835
|
+
// 焦点先进输入框:插件自己的 document 级粘贴监听有「焦点在编辑区就放行」的门控。
|
|
7836
|
+
composer.focus()
|
|
7837
|
+
composer.dispatchEvent(ev)
|
|
7838
|
+
return { ok: true, name, size: blob.size }
|
|
7839
|
+
} catch (error) {
|
|
7840
|
+
console.warn('dsh-gallery: 图片附件未自动加入输入框(文字草稿不受影响)', error)
|
|
7841
|
+
return { ok: false, reason: String(error?.message ?? error) }
|
|
7842
|
+
}
|
|
7843
|
+
}
|
|
7844
|
+
const writeAssetToComposer = (target, abs) => {
|
|
7845
|
+
const info = target ?? {}
|
|
7846
|
+
const key = String(info.relPath ?? '')
|
|
7847
|
+
// 连点保护:上一次还没处理完就直接忽略,避免文字和缩略图各写两份。
|
|
7848
|
+
// 5 秒兜底 + finally 摘除,处理完(含失败)绝不长期占着。
|
|
7849
|
+
const now = Date.now()
|
|
7850
|
+
const busyAt = key === '' ? undefined : doubleClickInFlight.get(key)
|
|
7851
|
+
if (busyAt !== undefined && now - busyAt < 5000) return
|
|
7852
|
+
if (key !== '') doubleClickInFlight.set(key, now)
|
|
7853
|
+
// 预览图 / 原图没有自己的 maskOf,按 overlayRelPath / sourceRelPath 反查主遮罩
|
|
7854
|
+
const linked = dragMaskByOverlay.get(info.relPath) ?? dragMaskBySource.get(info.relPath) ?? null
|
|
7855
|
+
const hasMask = info?.maskOf !== null && info?.maskOf !== undefined
|
|
7856
|
+
const enriched = (!hasMask && linked !== null)
|
|
7857
|
+
? { ...info, maskOf: { ...linked, linkedMask: true } }
|
|
7858
|
+
: info
|
|
7859
|
+
const text = dragNameOf(enriched, abs)
|
|
7860
|
+
void writeDraftToComposer(text, sessionId).then((result) => {
|
|
7861
|
+
// 写不进 composer 就放剪贴板,人自己粘
|
|
7862
|
+
if (!result.ok) void copyText(text)
|
|
7863
|
+
// 文字那步有幂等:草稿已在输入框时返回 already-present,本次并没有真的插入文字。
|
|
7864
|
+
// 附图必须跟着同一把尺子走,否则重复双击会一次次往输入框塞同一张缩略图。
|
|
7865
|
+
const alreadyPresent = result.ok && result.detail === 'already-present'
|
|
7866
|
+
if (result.ok && !alreadyPresent) void attachAssetImageToComposer(info)
|
|
7867
|
+
showToast(result.ok ? 'ok' : 'failed',
|
|
7868
|
+
alreadyPresent ? t('feedbackDraftAlreadyThere')
|
|
7869
|
+
: (result.ok ? t('feedbackDraftReady') : t('feedbackDraftInClipboard')))
|
|
7870
|
+
}).catch((error) => {
|
|
7871
|
+
console.warn('dsh-gallery: 写输入框失败,已退回剪贴板', error)
|
|
7872
|
+
void copyText(text)
|
|
7873
|
+
showToast('failed', t('feedbackDraftInClipboard'))
|
|
7874
|
+
}).finally(() => {
|
|
7875
|
+
if (key !== '') doubleClickInFlight.delete(key)
|
|
7876
|
+
})
|
|
7877
|
+
}
|
|
7878
|
+
|
|
7879
|
+
const handleCardDoubleClick = (target, event) => {
|
|
7880
|
+
const abs = (typeof target?.absPath === 'string' && target.absPath !== ''
|
|
7881
|
+
? target.absPath
|
|
7882
|
+
: buildAbsPath(data.root, target.relPath))
|
|
7883
|
+
writeAssetToComposer(target, abs)
|
|
7884
|
+
}
|
|
7885
|
+
|
|
7587
7886
|
const [refreshing, setRefreshing] = React.useState(false)
|
|
7588
7887
|
const [viewer, setViewer] = React.useState(null)
|
|
7589
7888
|
// 音视频播放器(v0.10.1):独立于图片查看器,因为交互与 DOM 完全不同
|
|
@@ -7591,6 +7890,36 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
7591
7890
|
// 让回调(如右键菜单)读到最新值而不必重建依赖
|
|
7592
7891
|
const viewerRef = React.useRef(null)
|
|
7593
7892
|
React.useEffect(() => { viewerRef.current = viewer }, [viewer])
|
|
7893
|
+
|
|
7894
|
+
/**
|
|
7895
|
+
* 阶段 3 / C1:把「人此刻正在看哪张图」告诉后台。
|
|
7896
|
+
* 关闭查看器时不清空 —— 保留最后一次,人回头问「我刚看的那张」仍然答得上来。
|
|
7897
|
+
* 纯状态同步:不发送任何消息,失败只记日志,绝不影响看图本身。
|
|
7898
|
+
*/
|
|
7899
|
+
React.useEffect(() => {
|
|
7900
|
+
if (viewer === null || !Array.isArray(viewer.list)) return
|
|
7901
|
+
const current = viewer.list[viewer.index]
|
|
7902
|
+
if (current === null || current === undefined || String(current.relPath ?? '') === '') return
|
|
7903
|
+
// 原图 / 彩色填充预览图自己没有 maskOf;用列表刷新时建好的反查表补上,
|
|
7904
|
+
// 让「助手查刚看的图」与双击、拖图写进输入框拿到同一张主遮罩。
|
|
7905
|
+
const linkedMask = dragMaskByOverlay.get(String(current.relPath))
|
|
7906
|
+
?? dragMaskBySource.get(String(current.relPath)) ?? null
|
|
7907
|
+
void callHost('setContext', {
|
|
7908
|
+
item: {
|
|
7909
|
+
relPath: String(current.relPath),
|
|
7910
|
+
name: String(current.name ?? ''),
|
|
7911
|
+
absPath: String(current.absPath ?? ''),
|
|
7912
|
+
category: String(current.category ?? 'unknown'),
|
|
7913
|
+
categoryManual: current.categoryManual === true,
|
|
7914
|
+
maskOf: current.maskOf ?? (linkedMask !== null
|
|
7915
|
+
? { relPath: String(linkedMask.relPath ?? '') } : null),
|
|
7916
|
+
sessionId: String(current.sessionId ?? viewer.originSid ?? ''),
|
|
7917
|
+
sessionTitle: String(current.sessionTitle ?? viewer.originTitle ?? ''),
|
|
7918
|
+
},
|
|
7919
|
+
}).catch((error) => {
|
|
7920
|
+
console.warn('dsh-gallery: 同步「正在看的图」失败(不影响看图)', error)
|
|
7921
|
+
})
|
|
7922
|
+
}, [viewer])
|
|
7594
7923
|
/**
|
|
7595
7924
|
* v0.16.2 粘贴落点:全局视图下「鼠标所在的对话组」。
|
|
7596
7925
|
*
|
|
@@ -7622,6 +7951,10 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
7622
7951
|
const [settingsOpen, setSettingsOpen] = React.useState(false)
|
|
7623
7952
|
// 全局分组:哪些组是展开的(键是 sessionId 或 '__history__')
|
|
7624
7953
|
const [openGroups, setOpenGroups] = React.useState(new Set())
|
|
7954
|
+
// 每组额外取回来的明细(首次只有 60 张,点「再显示」再追加 60 张)。
|
|
7955
|
+
// 全量明细留在后台内存,界面一次只画一小批:加载轻、也不卡。
|
|
7956
|
+
const [groupExtras, setGroupExtras] = React.useState(() => new Map())
|
|
7957
|
+
const [groupBusy, setGroupBusy] = React.useState(() => new Set())
|
|
7625
7958
|
/**
|
|
7626
7959
|
* 「打开对话」的实测结论:sid → 'ok' | 'failed'。
|
|
7627
7960
|
* 它比 Host 的归档字段优先级更高:点得开就撤掉一切标注,点不开才标无法重建。
|
|
@@ -7705,6 +8038,9 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
7705
8038
|
y: Number(a?.y) || 0,
|
|
7706
8039
|
w: Number(a?.w) || 0,
|
|
7707
8040
|
h: Number(a?.h) || 0,
|
|
8041
|
+
// 不规则区域:顶点挂在 region 里原样透传,Host 展开与草稿都认这个对象
|
|
8042
|
+
...(a?.shape === 'polygon' && Array.isArray(a?.polygon)
|
|
8043
|
+
? { polygon: a.polygon, shape: 'polygon' } : {}),
|
|
7708
8044
|
},
|
|
7709
8045
|
markedAt: Number(a?.createdAt) || Date.now(),
|
|
7710
8046
|
}), [])
|
|
@@ -8224,8 +8560,8 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
8224
8560
|
lastContextRelPath.current = item.relPath
|
|
8225
8561
|
setCtxMenu({
|
|
8226
8562
|
item,
|
|
8227
|
-
absPath: absPath ?? (typeof item?.absPath === 'string' && item.absPath !== ''
|
|
8228
|
-
? item.absPath
|
|
8563
|
+
absPath: absPath ?? (typeof item?.absPath === 'string' && item.absPath !== ''
|
|
8564
|
+
? item.absPath
|
|
8229
8565
|
: buildAbsPath(view.status === 'ready' ? view.data.root : '', item.relPath)),
|
|
8230
8566
|
x: event.clientX,
|
|
8231
8567
|
y: event.clientY,
|
|
@@ -8270,6 +8606,12 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
8270
8606
|
// v0.16.4:分类(素材 / 过程稿 / 定稿),批注落盘与草稿都要用
|
|
8271
8607
|
category: it.category ?? 'unknown',
|
|
8272
8608
|
categoryManual: it.categoryManual === true,
|
|
8609
|
+
// 阶段 3 / C1:同步「正在看哪张」要用的字段。
|
|
8610
|
+
// maskOf 只留 relPath,避免把整个关联对象塞进 viewer state。
|
|
8611
|
+
absPath: it.absPath ?? '',
|
|
8612
|
+
maskOf: it.maskOf ? { relPath: String(it.maskOf.relPath ?? '') } : null,
|
|
8613
|
+
sessionId: it.sessionId ?? '',
|
|
8614
|
+
sessionTitle: it.sessionTitle ?? '',
|
|
8273
8615
|
}))
|
|
8274
8616
|
// v0.16.2:记住这张图属于哪个对话组 —— 裁剪产物要跟着来源组落盘,
|
|
8275
8617
|
// 不能一律塞进当前对话(否则在历史对话的图上裁剪,产物跑到别的对话)。
|
|
@@ -8571,6 +8913,8 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
8571
8913
|
React.useEffect(() => {
|
|
8572
8914
|
const onDocPaste = (event) => {
|
|
8573
8915
|
if (hoveringRef.current !== true) return
|
|
8916
|
+
// 阶段 3 / C2:我们自己在输入框合成的图片粘贴事件,不是往面板里粘图。
|
|
8917
|
+
if (event?.__dshGallerySynthetic === true) return
|
|
8574
8918
|
if (event?.defaultPrevented === true) return
|
|
8575
8919
|
const ae = document.activeElement
|
|
8576
8920
|
const tag = (ae?.tagName ?? '').toLowerCase()
|
|
@@ -8695,12 +9039,12 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
8695
9039
|
}
|
|
8696
9040
|
const rel = String(it?.relPath ?? '')
|
|
8697
9041
|
if (rel !== '' && !dragAssetIndex.has(rel)) {
|
|
8698
|
-
// v0.17.0:优先用 Host 下发的 absPath —— Host 用 rootOfAbs 按文件真实落盘位置
|
|
8699
|
-
// 算,是权威值。原来用 buildAbsPath(root, rel) 拿【第一个 root】去拼,
|
|
8700
|
-
// 文件在别的 root 下时拼出的是不存在的路径(实测三次都踩)。
|
|
8701
|
-
const realAbs = (typeof it?.absPath === 'string' && it.absPath !== '')
|
|
8702
|
-
? it.absPath
|
|
8703
|
-
: buildAbsPath(root, rel)
|
|
9042
|
+
// v0.17.0:优先用 Host 下发的 absPath —— Host 用 rootOfAbs 按文件真实落盘位置
|
|
9043
|
+
// 算,是权威值。原来用 buildAbsPath(root, rel) 拿【第一个 root】去拼,
|
|
9044
|
+
// 文件在别的 root 下时拼出的是不存在的路径(实测三次都踩)。
|
|
9045
|
+
const realAbs = (typeof it?.absPath === 'string' && it.absPath !== '')
|
|
9046
|
+
? it.absPath
|
|
9047
|
+
: buildAbsPath(root, rel)
|
|
8704
9048
|
dragAssetIndex.set(rel, { item: it, absPath: realAbs })
|
|
8705
9049
|
}
|
|
8706
9050
|
}
|
|
@@ -8784,7 +9128,9 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
8784
9128
|
h('span', { className: 'dg-sub', key: 'sub' },
|
|
8785
9129
|
data === null
|
|
8786
9130
|
? (view.status === 'failed' ? t('errorTitle') : t('loading'))
|
|
8787
|
-
:
|
|
9131
|
+
: (scope === 'global' && Array.isArray(data.groups) && data.groups.length > 0
|
|
9132
|
+
? format(t('subCountGroups'), { total: data.total, groups: data.groups.length })
|
|
9133
|
+
: format(t('subCount'), { shown: visibleItems.length, total: data.total }))),
|
|
8788
9134
|
]),
|
|
8789
9135
|
scopeSwitch,
|
|
8790
9136
|
// 图片 / 文件 / 音视频 三画廊切换(v0.10.1)
|
|
@@ -8839,6 +9185,8 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
8839
9185
|
// 反馈篮独立入口(S3-a):关闭后能重新打开,不必再标记一张卡
|
|
8840
9186
|
// 计数取「表态 ∪ 批注」并集:只有框选批注、没表态的卡也算一条待发反馈
|
|
8841
9187
|
const markedCount = new Set([...Object.keys(marks), ...Object.keys(annotations)]).size
|
|
9188
|
+
// 2026-11-15:按钮上不再显示「· N 条」,恒显「反馈篮」。
|
|
9189
|
+
// 条数数据属性保留(不是可见数字),反馈的读写与生命周期一点不动。
|
|
8842
9190
|
const basketToggle = h('button', {
|
|
8843
9191
|
type: 'button',
|
|
8844
9192
|
className: 'dg-btn dg-basketToggle',
|
|
@@ -8848,30 +9196,18 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
8848
9196
|
title: t('feedbackBasketToggleHint'),
|
|
8849
9197
|
'aria-label': t('feedbackBasketToggleHint'),
|
|
8850
9198
|
onClick: () => setBasketOpen((v) => !v),
|
|
8851
|
-
},
|
|
8852
|
-
? format(t('feedbackBasketToggleN'), { n: markedCount })
|
|
8853
|
-
: t('feedbackBasketToggle'))
|
|
9199
|
+
}, t('feedbackBasketToggle'))
|
|
8854
9200
|
|
|
8855
9201
|
/**
|
|
8856
|
-
*
|
|
9202
|
+
* 2026-11-15:待处理数字角标已下线(老板拍板「留篮子、去掉数字」)。
|
|
8857
9203
|
*
|
|
8858
|
-
*
|
|
8859
|
-
*
|
|
8860
|
-
*
|
|
8861
|
-
*
|
|
8862
|
-
*
|
|
9204
|
+
* 今天助手已能自己查资产、记住刚打开的那张、双击卡片直接带图进输入框,
|
|
9205
|
+
* 「攒意见 → 角标提醒 → 等助手来拉」这条老链路不再走;反馈文件自 12:24 起为空。
|
|
9206
|
+
* 但反馈篮本体保留:多条意见打包成草稿、框选批注、编辑 / 清空仍只有它做得到。
|
|
9207
|
+
* 数据层一律不动(pendingCount 的读写与 ack 照旧),避免碰反馈生命周期。
|
|
9208
|
+
* 恒为 null:渲染数组里仍引用 pendingBadge,留个空位比删变量安全。
|
|
8863
9209
|
*/
|
|
8864
|
-
const pendingBadge =
|
|
8865
|
-
? h('button', {
|
|
8866
|
-
type: 'button',
|
|
8867
|
-
className: 'dg-pendingBadge',
|
|
8868
|
-
key: 'pendingBadge',
|
|
8869
|
-
'data-gallery-pending-count': pendingCount,
|
|
8870
|
-
title: format(t('pendingFeedbackBadgeHint'), { n: pendingCount }),
|
|
8871
|
-
'aria-label': format(t('pendingFeedbackBadgeHint'), { n: pendingCount }),
|
|
8872
|
-
onClick: () => setBasketOpen(true),
|
|
8873
|
-
}, format(t('pendingFeedbackBadge'), { n: pendingCount }))
|
|
8874
|
-
: null
|
|
9210
|
+
const pendingBadge = null
|
|
8875
9211
|
|
|
8876
9212
|
/**
|
|
8877
9213
|
* 各分类的全局计数(供顶部开关显示数字 + 判断「已显示 N / 共 M」)。
|
|
@@ -8880,12 +9216,27 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
8880
9216
|
const catCounts = React.useMemo(() => {
|
|
8881
9217
|
// v0.14.2:只数 4 个原生标签,表态层已下线
|
|
8882
9218
|
const c = { final: 0, input: 0, intermediate: 0, unknown: 0 }
|
|
9219
|
+
// 🔴 全局分组视图下,下面渲染的是 data.groups(全库按对话分组),
|
|
9220
|
+
// 而 items 只是最新一页的 60 条。还按 items 统计,顶部数字会与
|
|
9221
|
+
// 各组小标签加总差几十倍 —— 直接汇总各组全量 counts,口径才一致。
|
|
9222
|
+
if (scope === 'global' && Array.isArray(data?.groups) && data.groups.length > 0) {
|
|
9223
|
+
for (const g of data.groups) {
|
|
9224
|
+
for (const k of Object.keys(c)) c[k] += Number(g.counts?.[k] ?? 0)
|
|
9225
|
+
}
|
|
9226
|
+
return c
|
|
9227
|
+
}
|
|
9228
|
+
// 2026-11-15:当前对话视图也按「本对话全部」算。后台 list 会带回 counts,
|
|
9229
|
+
// 直接用;items 只是第一页 60 张,数它会和全局「当前对话」组的小标签对不上。
|
|
9230
|
+
if (data?.counts !== null && typeof data?.counts === 'object') {
|
|
9231
|
+
for (const k of Object.keys(c)) c[k] = Number(data.counts[k] ?? 0)
|
|
9232
|
+
return c
|
|
9233
|
+
}
|
|
8883
9234
|
for (const it of items) {
|
|
8884
9235
|
const b = bucketOf(it)
|
|
8885
9236
|
if (Object.prototype.hasOwnProperty.call(c, b)) c[b] += 1
|
|
8886
9237
|
}
|
|
8887
9238
|
return c
|
|
8888
|
-
}, [items, bucketOf])
|
|
9239
|
+
}, [items, bucketOf, scope, data])
|
|
8889
9240
|
const finalCount = catCounts.final
|
|
8890
9241
|
const inputCount = catCounts.input
|
|
8891
9242
|
const interimCount = catCounts.intermediate
|
|
@@ -9197,6 +9548,7 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
9197
9548
|
}
|
|
9198
9549
|
|
|
9199
9550
|
if (useGroups) {
|
|
9551
|
+
|
|
9200
9552
|
const cardFor = (item, groupKey, listForViewer, groupMeta) => {
|
|
9201
9553
|
// 分组里的文件也走同一套卡片组件
|
|
9202
9554
|
const enriched = {
|
|
@@ -9215,12 +9567,14 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
9215
9567
|
?? (VIDEO_EXTS.includes(String(enriched.extension ?? '').toLowerCase()) ? 'video' : 'audio'),
|
|
9216
9568
|
},
|
|
9217
9569
|
t,
|
|
9218
|
-
absPath: (typeof item?.absPath === 'string' && item.absPath !== ''
|
|
9219
|
-
? item.absPath
|
|
9570
|
+
absPath: (typeof item?.absPath === 'string' && item.absPath !== ''
|
|
9571
|
+
? item.absPath
|
|
9220
9572
|
: buildAbsPath(data.root, item.relPath)),
|
|
9221
9573
|
// v0.16.2:选段产物跟来源组走(groupKey 就是该组 sessionId)
|
|
9222
9574
|
onPlay: (target) => setMediaPlaying({ ...target, originSessionId: groupKey }),
|
|
9223
9575
|
onContextMenu: openContextMenu,
|
|
9576
|
+
// v0.17.0:双击写进输入框
|
|
9577
|
+
onDoubleClick: (target, event) => { handleCardDoubleClick(target, event) },
|
|
9224
9578
|
}), item, `${groupKey}:${item.relPath}`)
|
|
9225
9579
|
}
|
|
9226
9580
|
if (kind === 'file') {
|
|
@@ -9228,11 +9582,13 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
9228
9582
|
key: `${groupKey}:${item.relPath}`,
|
|
9229
9583
|
item: enriched,
|
|
9230
9584
|
t,
|
|
9231
|
-
absPath: (typeof item?.absPath === 'string' && item.absPath !== ''
|
|
9232
|
-
? item.absPath
|
|
9585
|
+
absPath: (typeof item?.absPath === 'string' && item.absPath !== ''
|
|
9586
|
+
? item.absPath
|
|
9233
9587
|
: buildAbsPath(data.root, item.relPath)),
|
|
9234
9588
|
onOpenFolder: () => { void callHost('reveal', { path: item.relPath }).catch((e) => console.error('dsh-gallery: reveal 失败', e)) },
|
|
9235
9589
|
onContextMenu: openContextMenu,
|
|
9590
|
+
// v0.17.0:双击写进输入框
|
|
9591
|
+
onDoubleClick: (target, event) => { handleCardDoubleClick(target, event) },
|
|
9236
9592
|
onPreview: (abs) => {
|
|
9237
9593
|
const address = sessionFileAddressOf(sessionId, abs)
|
|
9238
9594
|
try {
|
|
@@ -9242,7 +9598,7 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
9242
9598
|
void copyText(abs)
|
|
9243
9599
|
}
|
|
9244
9600
|
},
|
|
9245
|
-
// v0.17.0:同右键菜单,复制结构化信息(文件名 + 绝对路径 + 关联遮罩)
|
|
9601
|
+
// v0.17.0:同右键菜单,复制结构化信息(文件名 + 绝对路径 + 关联遮罩)
|
|
9246
9602
|
onCopy: (abs) => { void copyText(dragNameOf(item, abs)) },
|
|
9247
9603
|
}), item, `${groupKey}:${item.relPath}`)
|
|
9248
9604
|
}
|
|
@@ -9252,6 +9608,8 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
9252
9608
|
t,
|
|
9253
9609
|
limiter: limiter.current,
|
|
9254
9610
|
onContextMenu: openContextMenu,
|
|
9611
|
+
// v0.17.0:双击写进输入框
|
|
9612
|
+
onDoubleClick: (target, event) => { handleCardDoubleClick(target, event) },
|
|
9255
9613
|
onOpen: (opened, anchorEl) => {
|
|
9256
9614
|
// 用**该组当前可见的文件**作为查看器列表:
|
|
9257
9615
|
// 左右切图应在本组内循环,而不是跳到别的对话的图。
|
|
@@ -9277,7 +9635,10 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
9277
9635
|
// v0.14.3:过程稿显隐只认顶部「过程稿」开关,组内不再第二套开关。
|
|
9278
9636
|
// 顶部开 → 所有组的过程稿都显示;顶部关 → 全部隐藏。
|
|
9279
9637
|
// 分类开关过滤:按 bucketOf 判断该文件属哪一类,再查开关。
|
|
9280
|
-
|
|
9638
|
+
// 后端首次只给每组前 60 张,点「再显示」再追加 60 张。
|
|
9639
|
+
const extra = groupExtras.get(groupKey) ?? []
|
|
9640
|
+
const allFiles = [...(Array.isArray(group.files) ? group.files : []), ...extra]
|
|
9641
|
+
const visibleFiles = allFiles.filter(
|
|
9281
9642
|
(f) => categoryFilter[bucketOf(f)] !== false)
|
|
9282
9643
|
|
|
9283
9644
|
const chips = []
|
|
@@ -9364,6 +9725,42 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
9364
9725
|
? h('div', { className: `dg-grid${kind === 'file' ? ' dg-fileGrid' : ''}`, key: 'grid' },
|
|
9365
9726
|
visibleFiles.map((f) => cardFor(f, headKey, visibleFiles, group)))
|
|
9366
9727
|
: h('div', { className: 'dg-groupEmpty', key: 'empty' }, t('groupEmpty')),
|
|
9728
|
+
allFiles.length < Number(group.fileCount ?? 0)
|
|
9729
|
+
? h('button', {
|
|
9730
|
+
type: 'button',
|
|
9731
|
+
className: 'dg-btn dg-groupMore',
|
|
9732
|
+
key: 'more',
|
|
9733
|
+
'data-gallery-group-more': groupKey,
|
|
9734
|
+
disabled: groupBusy.has(groupKey),
|
|
9735
|
+
onClick: () => {
|
|
9736
|
+
if (groupBusy.has(groupKey)) return
|
|
9737
|
+
setGroupBusy((prev) => new Set(prev).add(groupKey))
|
|
9738
|
+
void callHost('groupMore', {
|
|
9739
|
+
kind, scope: 'global', sessionId, groupKey,
|
|
9740
|
+
offset: allFiles.length, limit: GROUP_PAGE,
|
|
9741
|
+
}).then((r) => {
|
|
9742
|
+
if (r?.ok !== true || !Array.isArray(r.files)) return
|
|
9743
|
+
setGroupExtras((prev) => {
|
|
9744
|
+
const next = new Map(prev)
|
|
9745
|
+
next.set(groupKey, [...(prev.get(groupKey) ?? []), ...r.files])
|
|
9746
|
+
return next
|
|
9747
|
+
})
|
|
9748
|
+
}).catch((error) => {
|
|
9749
|
+
console.warn('dsh-gallery: 再显示失败(不影响已显示的图)', error)
|
|
9750
|
+
}).finally(() => {
|
|
9751
|
+
setGroupBusy((prev) => {
|
|
9752
|
+
const next = new Set(prev)
|
|
9753
|
+
next.delete(groupKey)
|
|
9754
|
+
return next
|
|
9755
|
+
})
|
|
9756
|
+
})
|
|
9757
|
+
},
|
|
9758
|
+
}, format(t('groupShowMore'), {
|
|
9759
|
+
step: Math.min(GROUP_PAGE, Number(group.fileCount ?? 0) - allFiles.length),
|
|
9760
|
+
shown: allFiles.length,
|
|
9761
|
+
total: Number(group.fileCount ?? 0),
|
|
9762
|
+
}))
|
|
9763
|
+
: null,
|
|
9367
9764
|
group.truncated
|
|
9368
9765
|
? h('div', { className: 'dg-groupEmpty', key: 'trunc', style: { marginTop: '8px' } },
|
|
9369
9766
|
format(t('groupTruncated'), { shown: group.returnedCount, total: group.fileCount }))
|
|
@@ -9409,10 +9806,12 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
9409
9806
|
item,
|
|
9410
9807
|
t,
|
|
9411
9808
|
limiter: limiter.current,
|
|
9412
|
-
absPath: (typeof item?.absPath === 'string' && item.absPath !== ''
|
|
9413
|
-
? item.absPath
|
|
9809
|
+
absPath: (typeof item?.absPath === 'string' && item.absPath !== ''
|
|
9810
|
+
? item.absPath
|
|
9414
9811
|
: buildAbsPath(data === null ? '' : data.root, item.relPath)),
|
|
9415
9812
|
onPlay: (target) => setMediaPlaying(target),
|
|
9813
|
+
// v0.17.0:双击写进输入框(当前对话的媒体卡)
|
|
9814
|
+
onDoubleClick: (target, event) => { handleCardDoubleClick(target, event) },
|
|
9416
9815
|
onContextMenu: openContextMenu,
|
|
9417
9816
|
}), item, item.relPath))
|
|
9418
9817
|
|
|
@@ -9421,11 +9820,13 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
9421
9820
|
key: item.relPath,
|
|
9422
9821
|
item,
|
|
9423
9822
|
t,
|
|
9424
|
-
absPath: (typeof item?.absPath === 'string' && item.absPath !== ''
|
|
9425
|
-
? item.absPath
|
|
9823
|
+
absPath: (typeof item?.absPath === 'string' && item.absPath !== ''
|
|
9824
|
+
? item.absPath
|
|
9426
9825
|
: buildAbsPath(data.root, item.relPath)),
|
|
9427
9826
|
onOpenFolder: (abs) => { void callHost('reveal', { path: item.relPath }).catch((e) => console.error('dsh-gallery: reveal 失败', e)) },
|
|
9428
9827
|
onContextMenu: openContextMenu,
|
|
9828
|
+
// v0.17.0:双击写进输入框(当前对话的文件卡)
|
|
9829
|
+
onDoubleClick: (target, event) => { handleCardDoubleClick(target, event) },
|
|
9429
9830
|
onPreview: (abs) => {
|
|
9430
9831
|
const address = sessionFileAddressOf(sessionId, abs)
|
|
9431
9832
|
try {
|
|
@@ -9443,6 +9844,8 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
9443
9844
|
t,
|
|
9444
9845
|
limiter: limiter.current,
|
|
9445
9846
|
onContextMenu: openContextMenu,
|
|
9847
|
+
// v0.17.0:双击写进输入框(扁平视图)
|
|
9848
|
+
onDoubleClick: (target, event) => { handleCardDoubleClick(target, event) },
|
|
9446
9849
|
onOpen: (opened, anchorEl) => openViewer(visibleItems.indexOf(opened), anchorEl, visibleItems),
|
|
9447
9850
|
}), item, item.relPath))
|
|
9448
9851
|
// 网格区外面包一层定位容器,右侧放滚动辅助列(无滚轮场景用)
|
|
@@ -9739,9 +10142,9 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
9739
10142
|
: undefined,
|
|
9740
10143
|
onHide: () => { void doHide(ctxMenu.item) },
|
|
9741
10144
|
onReveal: () => { void doReveal(ctxMenu.item) },
|
|
9742
|
-
// v0.17.0
|
|
9743
|
-
//
|
|
9744
|
-
onCopy: () => {
|
|
10145
|
+
// v0.17.0:【写进输入框】而不是复制到剪贴板 —— 少一步粘贴。
|
|
10146
|
+
// 写不进 composer 时自动退回剪贴板(见 writeAssetToComposer)。
|
|
10147
|
+
onCopy: () => { writeAssetToComposer(ctxMenu.item, ctxMenu.absPath) },
|
|
9745
10148
|
// v0.16.0 单文件复制:写系统剪贴板文件列表,可在别的对话粘贴
|
|
9746
10149
|
onCopyFile: () => { void doCopyAssets([ctxMenu.item.relPath]) },
|
|
9747
10150
|
onDelete: () => setDeleteTarget({ item: ctxMenu.item, busy: false }),
|
|
@@ -9800,6 +10203,15 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
9800
10203
|
: null
|
|
9801
10204
|
|
|
9802
10205
|
return h('div', { className: 'dg-root', 'data-gallery-root': true }, [
|
|
10206
|
+
// v0.17.0:写进输入框的结果提示(轻量浮层,不打断操作)
|
|
10207
|
+
toast === null
|
|
10208
|
+
? null
|
|
10209
|
+
: h('div', {
|
|
10210
|
+
className: `dg-toast dg-toast-${toast.kind}`,
|
|
10211
|
+
key: 'toast',
|
|
10212
|
+
role: 'status',
|
|
10213
|
+
'data-gallery-toast': toast.kind,
|
|
10214
|
+
}, toast.text),
|
|
9803
10215
|
header,
|
|
9804
10216
|
basketToggle,
|
|
9805
10217
|
pendingBadge,
|
|
@@ -10183,7 +10595,7 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
10183
10595
|
* @param filter - {
|
|
10184
10596
|
* kind?: 'image'|'file'|'media', scope?: 'global'|'session', sessionId?: string,
|
|
10185
10597
|
* label?: 'input'|'intermediate'|'final', // 与 category 同义,取生效值(手动标签优先)
|
|
10186
|
-
* category?: 同上,
|
|
10598
|
+
* category?: 同上, action?: string,
|
|
10187
10599
|
* ext?: '.png', q?: string, limit?: number, page?: number
|
|
10188
10600
|
* }
|
|
10189
10601
|
* @returns { schema, items, count, total, error? }
|
|
@@ -10223,7 +10635,6 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
10223
10635
|
name: String(it.name ?? relPath.split('/').pop() ?? relPath),
|
|
10224
10636
|
category: String(it.category ?? 'unknown'),
|
|
10225
10637
|
categoryManual: it.categoryManual === true,
|
|
10226
|
-
confirmed: it.confirmed === true,
|
|
10227
10638
|
action: String(it.markAction ?? ''),
|
|
10228
10639
|
ext: String(it.extension ?? ''),
|
|
10229
10640
|
size: Number(it.size) || 0,
|
|
@@ -10250,7 +10661,7 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
10250
10661
|
* 否则 Agent 看一眼就把用户的意见吞了。
|
|
10251
10662
|
*
|
|
10252
10663
|
* @returns { schema, items, count, draft }
|
|
10253
|
-
* items[i] = { relPath, absolute, action, reason, changeOnly, keep, region, markedAt, category, sessionId
|
|
10664
|
+
* items[i] = { relPath, absolute, action, reason, changeOnly, keep, region, markedAt, category, sessionId }
|
|
10254
10665
|
* draft = 已渲染好的成稿文本(可直接用,省得自己拼)
|
|
10255
10666
|
*/
|
|
10256
10667
|
async getPendingFeedback() {
|
|
@@ -10338,6 +10749,8 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
10338
10749
|
// 拖完在输入框 Ctrl+V 能粘出「产出台·…」= 新代码确实执行过、dragstart 命中;
|
|
10339
10750
|
// 粘不出 = 面板仍加载旧模块,需重载窗口。编码 / 写入失败时它就是唯一可用通道。
|
|
10340
10751
|
void copyText(name)
|
|
10752
|
+
// 从 Viewer「拖到对话」按钮拖出时,取预览大图而不是按钮内的节点;
|
|
10753
|
+
// 列表卡片则仍用自己那张缩略图。两者都是同源 blob URL,canvas 不会被污染。
|
|
10341
10754
|
const img = card.hasAttribute('data-gallery-dragviewer')
|
|
10342
10755
|
? document.querySelector('.dg-viewerBody img')
|
|
10343
10756
|
: (target.matches('img') ? target : target.querySelector('img'))
|
|
@@ -10417,4 +10830,4 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
10417
10830
|
},
|
|
10418
10831
|
}
|
|
10419
10832
|
},
|
|
10420
|
-
})
|
|
10833
|
+
})
|