@yuwenovo/ocr-result-view 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/README.md +312 -0
- package/dist/ocr-result-view.css +2 -0
- package/dist/ocr-result-view.d.ts +1 -0
- package/dist/ocr-result-view.js +1068 -0
- package/dist/style.d.ts +2 -0
- package/dist/types/components/DiffCards.vue.d.ts +36 -0
- package/dist/types/components/OcrDiffViewer.vue.d.ts +71 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/types.d.ts +100 -0
- package/dist/types/utils/diff-items.d.ts +18 -0
- package/examples/Basic.vue +26 -0
- package/package.json +48 -0
|
@@ -0,0 +1,1068 @@
|
|
|
1
|
+
import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createSlots as o, createTextVNode as s, createVNode as c, defineComponent as l, guardReactiveProps as u, markRaw as d, nextTick as f, normalizeClass as p, normalizeProps as m, normalizeStyle as h, onBeforeUnmount as ee, onMounted as te, openBlock as g, ref as _, renderList as v, renderSlot as y, toDisplayString as b, unref as x, watch as S, withCtx as C } from "vue";
|
|
2
|
+
//#region src/utils/diff-items.ts
|
|
3
|
+
function ne(e, t = "all", n = "all") {
|
|
4
|
+
return e.flatMap((e, r) => t !== "all" && t !== e.type || n === "pending" && e.ignored || n === "ignored" && !e.ignored ? [] : (e.type === "delete" || e.type, [{
|
|
5
|
+
type: e.type,
|
|
6
|
+
data: e,
|
|
7
|
+
idx: r
|
|
8
|
+
}]));
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region ~icons/lucide/eye-off
|
|
12
|
+
var w = {
|
|
13
|
+
viewBox: "0 0 24 24",
|
|
14
|
+
width: "1.2em",
|
|
15
|
+
height: "1.2em"
|
|
16
|
+
};
|
|
17
|
+
function T(e, t) {
|
|
18
|
+
return g(), i("svg", w, [...t[0] ||= [a("g", {
|
|
19
|
+
fill: "none",
|
|
20
|
+
stroke: "currentColor",
|
|
21
|
+
"stroke-linecap": "round",
|
|
22
|
+
"stroke-linejoin": "round",
|
|
23
|
+
"stroke-width": "2"
|
|
24
|
+
}, [a("path", { d: "M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575a1 1 0 0 1 0 .696a10.8 10.8 0 0 1-1.444 2.49m-6.41-.679a3 3 0 0 1-4.242-4.242" }), a("path", { d: "M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 4.446-5.143M2 2l20 20" })], -1)]]);
|
|
25
|
+
}
|
|
26
|
+
var re = d({
|
|
27
|
+
name: "lucide-eye-off",
|
|
28
|
+
render: T
|
|
29
|
+
}), E = {
|
|
30
|
+
viewBox: "0 0 24 24",
|
|
31
|
+
width: "1.2em",
|
|
32
|
+
height: "1.2em"
|
|
33
|
+
};
|
|
34
|
+
function D(e, t) {
|
|
35
|
+
return g(), i("svg", E, [...t[0] ||= [a("g", {
|
|
36
|
+
fill: "none",
|
|
37
|
+
stroke: "currentColor",
|
|
38
|
+
"stroke-linecap": "round",
|
|
39
|
+
"stroke-linejoin": "round",
|
|
40
|
+
"stroke-width": "2"
|
|
41
|
+
}, [a("path", { d: "M9 14L4 9l5-5" }), a("path", { d: "M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11" })], -1)]]);
|
|
42
|
+
}
|
|
43
|
+
var ie = d({
|
|
44
|
+
name: "lucide-undo-2",
|
|
45
|
+
render: D
|
|
46
|
+
}), O = {
|
|
47
|
+
viewBox: "0 0 24 24",
|
|
48
|
+
width: "1.2em",
|
|
49
|
+
height: "1.2em"
|
|
50
|
+
};
|
|
51
|
+
function ae(e, t) {
|
|
52
|
+
return g(), i("svg", O, [...t[0] ||= [a("path", {
|
|
53
|
+
fill: "none",
|
|
54
|
+
stroke: "currentColor",
|
|
55
|
+
"stroke-linecap": "round",
|
|
56
|
+
"stroke-linejoin": "round",
|
|
57
|
+
"stroke-width": "2",
|
|
58
|
+
d: "M5 12h14m-7-7v14"
|
|
59
|
+
}, null, -1)]]);
|
|
60
|
+
}
|
|
61
|
+
var k = d({
|
|
62
|
+
name: "lucide-plus",
|
|
63
|
+
render: ae
|
|
64
|
+
}), A = {
|
|
65
|
+
viewBox: "0 0 24 24",
|
|
66
|
+
width: "1.2em",
|
|
67
|
+
height: "1.2em"
|
|
68
|
+
};
|
|
69
|
+
function j(e, t) {
|
|
70
|
+
return g(), i("svg", A, [...t[0] ||= [a("path", {
|
|
71
|
+
fill: "none",
|
|
72
|
+
stroke: "currentColor",
|
|
73
|
+
"stroke-linecap": "round",
|
|
74
|
+
"stroke-linejoin": "round",
|
|
75
|
+
"stroke-width": "2",
|
|
76
|
+
d: "M5 12h14"
|
|
77
|
+
}, null, -1)]]);
|
|
78
|
+
}
|
|
79
|
+
var oe = d({
|
|
80
|
+
name: "lucide-minus",
|
|
81
|
+
render: j
|
|
82
|
+
}), M = {
|
|
83
|
+
viewBox: "0 0 24 24",
|
|
84
|
+
width: "1.2em",
|
|
85
|
+
height: "1.2em"
|
|
86
|
+
};
|
|
87
|
+
function N(e, t) {
|
|
88
|
+
return g(), i("svg", M, [...t[0] ||= [a("path", {
|
|
89
|
+
fill: "none",
|
|
90
|
+
stroke: "currentColor",
|
|
91
|
+
"stroke-linecap": "round",
|
|
92
|
+
"stroke-linejoin": "round",
|
|
93
|
+
"stroke-width": "2",
|
|
94
|
+
d: "M8 3L4 7l4 4M4 7h16m-4 14l4-4l-4-4m4 4H4"
|
|
95
|
+
}, null, -1)]]);
|
|
96
|
+
}
|
|
97
|
+
var se = d({
|
|
98
|
+
name: "lucide-arrow-left-right",
|
|
99
|
+
render: N
|
|
100
|
+
}), ce = { class: "diff-cards" }, le = { class: "card-heading" }, ue = [
|
|
101
|
+
"aria-label",
|
|
102
|
+
"aria-pressed",
|
|
103
|
+
"onClick"
|
|
104
|
+
], de = {
|
|
105
|
+
class: "type-icon",
|
|
106
|
+
"aria-hidden": "true"
|
|
107
|
+
}, P = { class: "card-type" }, F = { class: "card-number" }, fe = {
|
|
108
|
+
key: 0,
|
|
109
|
+
class: "ignored-label"
|
|
110
|
+
}, I = [
|
|
111
|
+
"disabled",
|
|
112
|
+
"title",
|
|
113
|
+
"aria-label",
|
|
114
|
+
"onClick"
|
|
115
|
+
], L = ["onClick"], pe = { class: "text-row" }, me = { class: "card-text" }, he = { class: "text-row" }, ge = { class: "card-text" }, _e = {
|
|
116
|
+
key: 1,
|
|
117
|
+
class: "text-row text-row--single"
|
|
118
|
+
}, ve = { class: "card-text" }, R = { class: "card-location" }, ye = /*@__PURE__*/ l({
|
|
119
|
+
__name: "DiffCards",
|
|
120
|
+
props: {
|
|
121
|
+
diffDetail: {},
|
|
122
|
+
activeIndex: {},
|
|
123
|
+
reviewFilter: {},
|
|
124
|
+
busy: { type: Boolean },
|
|
125
|
+
readonly: { type: Boolean },
|
|
126
|
+
activeTab: {}
|
|
127
|
+
},
|
|
128
|
+
emits: ["select", "ignore"],
|
|
129
|
+
setup(o, { emit: s }) {
|
|
130
|
+
let c = o, l = s, u = {
|
|
131
|
+
table_insert: "新增表格",
|
|
132
|
+
table_delete: "删除表格",
|
|
133
|
+
row_insert: "新增表格行",
|
|
134
|
+
row_delete: "删除表格行",
|
|
135
|
+
column_insert: "新增表格列",
|
|
136
|
+
column_delete: "删除表格列",
|
|
137
|
+
cell_insert: "新增单元格",
|
|
138
|
+
cell_delete: "删除单元格",
|
|
139
|
+
cell_content_modify: "单元格内容修改",
|
|
140
|
+
cell_merge: "合并单元格",
|
|
141
|
+
cell_split: "拆分单元格",
|
|
142
|
+
cell_span_modify: "单元格跨度修改"
|
|
143
|
+
};
|
|
144
|
+
function d(e, t) {
|
|
145
|
+
return e.domain === "table" && e.tableChange ? u[e.tableChange] : t;
|
|
146
|
+
}
|
|
147
|
+
let f = t(() => ne(c.diffDetail, c.activeTab ?? "all", c.reviewFilter));
|
|
148
|
+
function m(e) {
|
|
149
|
+
let t = e.type !== "insert", n = (t ? e.srcPage : e.tgtPage) + 1, r = t ? e.sourceLine : e.targetLine;
|
|
150
|
+
return `第 ${n} 页${e.domain === "table" || r < 0 ? "" : ` · ${t ? "标准" : "比对"}第 ${r + 1} 行`}`;
|
|
151
|
+
}
|
|
152
|
+
function h(e, t) {
|
|
153
|
+
let n = [...e];
|
|
154
|
+
if (t === void 0) return [{
|
|
155
|
+
text: e,
|
|
156
|
+
changed: !0
|
|
157
|
+
}];
|
|
158
|
+
let r = t.map(({ start: e, end: t }) => ({
|
|
159
|
+
start: Math.max(0, Math.min(e, n.length)),
|
|
160
|
+
end: Math.max(0, Math.min(t, n.length))
|
|
161
|
+
})).filter(({ start: e, end: t }) => t > e).sort((e, t) => e.start - t.start), i = [], a = 0;
|
|
162
|
+
for (let e of r) {
|
|
163
|
+
let t = Math.max(a, e.start);
|
|
164
|
+
t > a && i.push({
|
|
165
|
+
text: n.slice(a, t).join(""),
|
|
166
|
+
changed: !1
|
|
167
|
+
}), e.end > t && i.push({
|
|
168
|
+
text: n.slice(t, e.end).join(""),
|
|
169
|
+
changed: !0
|
|
170
|
+
}), a = Math.max(a, e.end);
|
|
171
|
+
}
|
|
172
|
+
return a < n.length && i.push({
|
|
173
|
+
text: n.slice(a).join(""),
|
|
174
|
+
changed: !1
|
|
175
|
+
}), i;
|
|
176
|
+
}
|
|
177
|
+
return (t, s) => (g(), i("div", ce, [(g(!0), i(e, null, v(f.value, (u) => (g(), i("article", {
|
|
178
|
+
key: u.data.diffId,
|
|
179
|
+
class: p(["diff-card", [`diff-card--${u.type}`, {
|
|
180
|
+
"is-active": o.activeIndex === u.idx,
|
|
181
|
+
"is-ignored": u.data.ignored
|
|
182
|
+
}]])
|
|
183
|
+
}, [y(t.$slots, "default", {
|
|
184
|
+
item: u.data,
|
|
185
|
+
index: u.idx,
|
|
186
|
+
active: o.activeIndex === u.idx,
|
|
187
|
+
select: () => l("select", u.idx),
|
|
188
|
+
ignore: (e) => {
|
|
189
|
+
!c.readonly && !o.busy && l("ignore", u.data.diffId, e);
|
|
190
|
+
}
|
|
191
|
+
}, () => [a("div", le, [
|
|
192
|
+
a("button", {
|
|
193
|
+
class: "card-select",
|
|
194
|
+
"aria-label": `定位第 ${u.idx + 1} 处差异,${m(u.data)}`,
|
|
195
|
+
"aria-pressed": o.activeIndex === u.idx,
|
|
196
|
+
onClick: (e) => l("select", u.idx)
|
|
197
|
+
}, [
|
|
198
|
+
a("span", de, [u.type === "insert" ? (g(), n(x(k), { key: 0 })) : u.type === "delete" ? (g(), n(x(oe), { key: 1 })) : (g(), n(x(se), { key: 2 }))]),
|
|
199
|
+
a("span", P, b(d(u.data, u.type === "modify" ? "修改" : u.type === "delete" ? "删除" : "新增")), 1),
|
|
200
|
+
a("span", F, b(String(u.idx + 1).padStart(2, "0")), 1)
|
|
201
|
+
], 8, ue),
|
|
202
|
+
u.data.ignored ? (g(), i("span", fe, "已忽略")) : r("", !0),
|
|
203
|
+
c.readonly ? r("", !0) : (g(), i("button", {
|
|
204
|
+
key: 1,
|
|
205
|
+
class: "card-action",
|
|
206
|
+
disabled: o.busy,
|
|
207
|
+
title: u.data.ignored ? "撤销忽略" : "忽略此差异",
|
|
208
|
+
"aria-label": `${u.data.ignored ? "撤销忽略" : "忽略"}第 ${u.idx + 1} 处差异`,
|
|
209
|
+
onClick: (e) => l("ignore", u.data.diffId, !u.data.ignored)
|
|
210
|
+
}, [u.data.ignored ? (g(), n(x(ie), {
|
|
211
|
+
key: 0,
|
|
212
|
+
"aria-hidden": "true"
|
|
213
|
+
})) : (g(), n(x(re), {
|
|
214
|
+
key: 1,
|
|
215
|
+
"aria-hidden": "true"
|
|
216
|
+
}))], 8, I))
|
|
217
|
+
]), a("div", {
|
|
218
|
+
class: "card-content",
|
|
219
|
+
onClick: (e) => l("select", u.idx)
|
|
220
|
+
}, [u.data.type === "modify" ? (g(), i(e, { key: 0 }, [a("div", pe, [s[0] ||= a("span", { class: "text-label" }, "标准", -1), a("span", me, [(g(!0), i(e, null, v(h(u.data.delChars, u.data.sourceChangeRanges), (e, t) => (g(), i("span", {
|
|
221
|
+
key: t,
|
|
222
|
+
class: p({ "change-mark": e.changed })
|
|
223
|
+
}, b(e.text), 3))), 128))])]), a("div", he, [s[1] ||= a("span", { class: "text-label" }, "比对", -1), a("span", ge, [(g(!0), i(e, null, v(h(u.data.insChars, u.data.targetChangeRanges), (e, t) => (g(), i("span", {
|
|
224
|
+
key: t,
|
|
225
|
+
class: p({ "change-mark": e.changed })
|
|
226
|
+
}, b(e.text), 3))), 128))])])], 64)) : (g(), i("div", _e, [a("span", ve, b(u.data.chars || "表格结构变更"), 1)])), a("p", R, b(m(u.data)), 1)], 8, L)], !0)], 2))), 128))]));
|
|
227
|
+
}
|
|
228
|
+
}), z = (e, t) => {
|
|
229
|
+
let n = e.__vccOpts || e;
|
|
230
|
+
for (let [e, r] of t) n[e] = r;
|
|
231
|
+
return n;
|
|
232
|
+
}, be = /*#__PURE__*/ z(ye, [["__scopeId", "data-v-61738111"]]), xe = {
|
|
233
|
+
viewBox: "0 0 24 24",
|
|
234
|
+
width: "1.2em",
|
|
235
|
+
height: "1.2em"
|
|
236
|
+
};
|
|
237
|
+
function Se(e, t) {
|
|
238
|
+
return g(), i("svg", xe, [...t[0] ||= [a("path", {
|
|
239
|
+
fill: "none",
|
|
240
|
+
stroke: "currentColor",
|
|
241
|
+
"stroke-linecap": "round",
|
|
242
|
+
"stroke-linejoin": "round",
|
|
243
|
+
"stroke-width": "2",
|
|
244
|
+
d: "M20 6L9 17l-5-5"
|
|
245
|
+
}, null, -1)]]);
|
|
246
|
+
}
|
|
247
|
+
var Ce = d({
|
|
248
|
+
name: "lucide-check",
|
|
249
|
+
render: Se
|
|
250
|
+
}), B = {
|
|
251
|
+
viewBox: "0 0 24 24",
|
|
252
|
+
width: "1.2em",
|
|
253
|
+
height: "1.2em"
|
|
254
|
+
};
|
|
255
|
+
function V(e, t) {
|
|
256
|
+
return g(), i("svg", B, [...t[0] ||= [a("path", {
|
|
257
|
+
fill: "none",
|
|
258
|
+
stroke: "currentColor",
|
|
259
|
+
"stroke-linecap": "round",
|
|
260
|
+
"stroke-linejoin": "round",
|
|
261
|
+
"stroke-width": "2",
|
|
262
|
+
d: "M2 5h20M6 12h12m-9 7h6"
|
|
263
|
+
}, null, -1)]]);
|
|
264
|
+
}
|
|
265
|
+
var we = d({
|
|
266
|
+
name: "lucide-list-filter",
|
|
267
|
+
render: V
|
|
268
|
+
}), H = {
|
|
269
|
+
viewBox: "0 0 24 24",
|
|
270
|
+
width: "1.2em",
|
|
271
|
+
height: "1.2em"
|
|
272
|
+
};
|
|
273
|
+
function U(e, t) {
|
|
274
|
+
return g(), i("svg", H, [...t[0] ||= [a("path", {
|
|
275
|
+
fill: "none",
|
|
276
|
+
stroke: "currentColor",
|
|
277
|
+
"stroke-linecap": "round",
|
|
278
|
+
"stroke-linejoin": "round",
|
|
279
|
+
"stroke-width": "2",
|
|
280
|
+
d: "m11 17l-5-5l5-5m7 10l-5-5l5-5"
|
|
281
|
+
}, null, -1)]]);
|
|
282
|
+
}
|
|
283
|
+
var Te = d({
|
|
284
|
+
name: "lucide-chevrons-left",
|
|
285
|
+
render: U
|
|
286
|
+
}), W = {
|
|
287
|
+
viewBox: "0 0 24 24",
|
|
288
|
+
width: "1.2em",
|
|
289
|
+
height: "1.2em"
|
|
290
|
+
};
|
|
291
|
+
function G(e, t) {
|
|
292
|
+
return g(), i("svg", W, [...t[0] ||= [a("path", {
|
|
293
|
+
fill: "none",
|
|
294
|
+
stroke: "currentColor",
|
|
295
|
+
"stroke-linecap": "round",
|
|
296
|
+
"stroke-linejoin": "round",
|
|
297
|
+
"stroke-width": "2",
|
|
298
|
+
d: "m15 18l-6-6l6-6"
|
|
299
|
+
}, null, -1)]]);
|
|
300
|
+
}
|
|
301
|
+
var Ee = d({
|
|
302
|
+
name: "lucide-chevron-left",
|
|
303
|
+
render: G
|
|
304
|
+
}), De = {
|
|
305
|
+
viewBox: "0 0 24 24",
|
|
306
|
+
width: "1.2em",
|
|
307
|
+
height: "1.2em"
|
|
308
|
+
};
|
|
309
|
+
function Oe(e, t) {
|
|
310
|
+
return g(), i("svg", De, [...t[0] ||= [a("path", {
|
|
311
|
+
fill: "none",
|
|
312
|
+
stroke: "currentColor",
|
|
313
|
+
"stroke-linecap": "round",
|
|
314
|
+
"stroke-linejoin": "round",
|
|
315
|
+
"stroke-width": "2",
|
|
316
|
+
d: "m9 18l6-6l-6-6"
|
|
317
|
+
}, null, -1)]]);
|
|
318
|
+
}
|
|
319
|
+
var ke = d({
|
|
320
|
+
name: "lucide-chevron-right",
|
|
321
|
+
render: Oe
|
|
322
|
+
}), Ae = {
|
|
323
|
+
viewBox: "0 0 24 24",
|
|
324
|
+
width: "1.2em",
|
|
325
|
+
height: "1.2em"
|
|
326
|
+
};
|
|
327
|
+
function K(e, t) {
|
|
328
|
+
return g(), i("svg", Ae, [...t[0] ||= [a("path", {
|
|
329
|
+
fill: "none",
|
|
330
|
+
stroke: "currentColor",
|
|
331
|
+
"stroke-linecap": "round",
|
|
332
|
+
"stroke-linejoin": "round",
|
|
333
|
+
"stroke-width": "2",
|
|
334
|
+
d: "m6 17l5-5l-5-5m7 10l5-5l-5-5"
|
|
335
|
+
}, null, -1)]]);
|
|
336
|
+
}
|
|
337
|
+
var je = d({
|
|
338
|
+
name: "lucide-chevrons-right",
|
|
339
|
+
render: K
|
|
340
|
+
}), Me = { class: "ocr-result-view" }, Ne = { class: "ocr-diff-viewer" }, Pe = { class: "viewer-main" }, Fe = { class: "canvas-col" }, Ie = {
|
|
341
|
+
key: 0,
|
|
342
|
+
class: "canvas-info-bar"
|
|
343
|
+
}, Le = { class: "canvas-info-bar-left" }, Re = { class: "canvas-info-bar-left-filename" }, ze = { class: "canvas-info-bar-right" }, Be = ["disabled"], Ve = ["disabled"], He = { class: "page-num" }, Ue = ["disabled"], We = ["disabled"], Ge = { class: "canvas-col" }, Ke = {
|
|
344
|
+
key: 0,
|
|
345
|
+
class: "canvas-info-bar"
|
|
346
|
+
}, qe = { class: "canvas-info-bar-left" }, Je = { class: "canvas-info-bar-left-filename" }, Ye = { class: "canvas-info-bar-right" }, Xe = ["disabled"], Ze = ["disabled"], Qe = { class: "page-num" }, $e = ["disabled"], et = ["disabled"], tt = {
|
|
347
|
+
key: 1,
|
|
348
|
+
class: "page-loading"
|
|
349
|
+
}, nt = {
|
|
350
|
+
class: "side-panel",
|
|
351
|
+
"aria-label": "差异审阅"
|
|
352
|
+
}, rt = { class: "review-header" }, it = { class: "review-title-row" }, at = { class: "review-total" }, ot = {
|
|
353
|
+
class: "review-segments",
|
|
354
|
+
"aria-label": "差异处理状态"
|
|
355
|
+
}, st = ["aria-pressed", "onClick"], ct = { key: 0 }, lt = {
|
|
356
|
+
class: "review-types",
|
|
357
|
+
"aria-label": "差异类型"
|
|
358
|
+
}, ut = ["aria-pressed", "onClick"], dt = {
|
|
359
|
+
key: 0,
|
|
360
|
+
class: "review-empty",
|
|
361
|
+
role: "status"
|
|
362
|
+
}, ft = { class: "empty-symbol is-passed" }, pt = { class: "empty-symbol" }, mt = ["aria-busy"], ht = ["disabled"], gt = { key: 0 }, _t = ["disabled"], vt = 5, yt = 16, bt = 4, xt = /*#__PURE__*/ z(/* @__PURE__ */ l({
|
|
363
|
+
__name: "OcrDiffViewer",
|
|
364
|
+
props: {
|
|
365
|
+
diffDetail: {},
|
|
366
|
+
sourcePages: {},
|
|
367
|
+
targetPages: {},
|
|
368
|
+
sourceFilename: {},
|
|
369
|
+
targetFilename: {},
|
|
370
|
+
review: {},
|
|
371
|
+
reviewBusy: {
|
|
372
|
+
type: Boolean,
|
|
373
|
+
default: !1
|
|
374
|
+
},
|
|
375
|
+
readonly: {
|
|
376
|
+
type: Boolean,
|
|
377
|
+
default: !0
|
|
378
|
+
},
|
|
379
|
+
imageCrossOrigin: { default: "anonymous" }
|
|
380
|
+
},
|
|
381
|
+
emits: [
|
|
382
|
+
"ignore",
|
|
383
|
+
"select",
|
|
384
|
+
"page-change",
|
|
385
|
+
"filter-change",
|
|
386
|
+
"image-error"
|
|
387
|
+
],
|
|
388
|
+
setup(l, { expose: d, emit: p }) {
|
|
389
|
+
let w = l, T = p, E = t(() => w.review), D = _("pending"), O = t(() => ne(w.diffDetail, j.value, D.value)), ae = t(() => new Set(O.value.map((e) => e.idx))), k = t(() => {
|
|
390
|
+
let e = [], t = [], n = 0, r = 0, i = 0;
|
|
391
|
+
for (let a = 0; a < w.diffDetail.length; a++) {
|
|
392
|
+
let o = w.diffDetail[a];
|
|
393
|
+
if (D.value === "pending" && o.ignored || D.value === "ignored" && !o.ignored) continue;
|
|
394
|
+
let s = o.domain === "table" ? "表格" : "";
|
|
395
|
+
if (o.type === "delete") {
|
|
396
|
+
if (n++, o.sourceBox) {
|
|
397
|
+
let [t, n, r, i] = o.sourceBox;
|
|
398
|
+
e.push({
|
|
399
|
+
x: t,
|
|
400
|
+
y: n,
|
|
401
|
+
w: r - t,
|
|
402
|
+
h: i - n,
|
|
403
|
+
pairIndex: a,
|
|
404
|
+
pageIndex: o.srcPage,
|
|
405
|
+
color: o.ignored ? "gray" : "red",
|
|
406
|
+
title: s ? `${s}删除:${o.sourceText.slice(0, 24)}` : `缺字「${o.chars}」 行${o.sourceLine + 1}: ${o.sourceText.slice(0, 24)}…`
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
o.tgtGap && t.push({
|
|
410
|
+
...o.tgtGap,
|
|
411
|
+
pairIndex: a,
|
|
412
|
+
pageIndex: o.tgtPage,
|
|
413
|
+
color: o.ignored ? "gray" : "red",
|
|
414
|
+
title: `此处缺「${o.chars}」`,
|
|
415
|
+
isGap: !0
|
|
416
|
+
});
|
|
417
|
+
} else if (o.type === "insert") {
|
|
418
|
+
if (r++, o.srcGap && e.push({
|
|
419
|
+
...o.srcGap,
|
|
420
|
+
pairIndex: a,
|
|
421
|
+
pageIndex: o.srcPage,
|
|
422
|
+
color: o.ignored ? "gray" : "green",
|
|
423
|
+
title: `此处多「${o.chars}」`,
|
|
424
|
+
isGap: !0
|
|
425
|
+
}), o.targetBox) {
|
|
426
|
+
let [e, n, r, i] = o.targetBox;
|
|
427
|
+
t.push({
|
|
428
|
+
x: e,
|
|
429
|
+
y: n,
|
|
430
|
+
w: r - e,
|
|
431
|
+
h: i - n,
|
|
432
|
+
pairIndex: a,
|
|
433
|
+
pageIndex: o.tgtPage,
|
|
434
|
+
color: o.ignored ? "gray" : "green",
|
|
435
|
+
title: s ? `${s}新增:${o.targetText.slice(0, 24)}` : `多字「${o.chars}」 行${o.targetLine + 1}: ${o.targetText.slice(0, 24)}…`
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
} else {
|
|
439
|
+
if (i++, o.sourceBox) {
|
|
440
|
+
let [t, n, r, i] = o.sourceBox;
|
|
441
|
+
e.push({
|
|
442
|
+
x: t,
|
|
443
|
+
y: n,
|
|
444
|
+
w: r - t,
|
|
445
|
+
h: i - n,
|
|
446
|
+
pairIndex: a,
|
|
447
|
+
pageIndex: o.srcPage,
|
|
448
|
+
color: o.ignored ? "gray" : "orange",
|
|
449
|
+
title: s ? `${s}修改:${o.delChars} → ${o.insChars}` : `将「${o.delChars}」→「${o.insChars}」`
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
if (o.targetBox) {
|
|
453
|
+
let [e, n, r, i] = o.targetBox;
|
|
454
|
+
t.push({
|
|
455
|
+
x: e,
|
|
456
|
+
y: n,
|
|
457
|
+
w: r - e,
|
|
458
|
+
h: i - n,
|
|
459
|
+
pairIndex: a,
|
|
460
|
+
pageIndex: o.tgtPage,
|
|
461
|
+
color: o.ignored ? "gray" : "orange",
|
|
462
|
+
title: s ? `${s}修改:${o.delChars} → ${o.insChars}` : `「${o.delChars}」→「${o.insChars}」`
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
return {
|
|
468
|
+
srcBoxes: e.filter((e) => ae.value.has(e.pairIndex)),
|
|
469
|
+
tgtBoxes: t.filter((e) => ae.value.has(e.pairIndex)),
|
|
470
|
+
deleteCount: n,
|
|
471
|
+
insertCount: r,
|
|
472
|
+
modifyCount: i
|
|
473
|
+
};
|
|
474
|
+
}), A = _(0), j = _("all"), oe = t(() => ({
|
|
475
|
+
all: k.value.deleteCount + k.value.insertCount + k.value.modifyCount,
|
|
476
|
+
modify: k.value.modifyCount,
|
|
477
|
+
delete: k.value.deleteCount,
|
|
478
|
+
insert: k.value.insertCount
|
|
479
|
+
})), M = _(0), N = _(0), se = _(), ce = _(), le = _(), ue = _(), de = _(), P = _(), F = _(), fe = _(), I = _([]), L = _([]), pe = _(1), me = _(1), he = _(1), ge = _(1), _e = Math.SQRT2, ve = /* @__PURE__ */ new Map(), R = /* @__PURE__ */ new Map(), ye = /* @__PURE__ */ new Map(), z = /* @__PURE__ */ new Set(), xe = [], Se = [], B = 0, V = 0, H = 0, U = 0, W = 0, G = null, De = !1, Oe = !1, Ae, K = !1, xt = [];
|
|
480
|
+
function St(e) {
|
|
481
|
+
let t = /* @__PURE__ */ new Map();
|
|
482
|
+
for (let n of e) {
|
|
483
|
+
let e = t.get(n.pageIndex);
|
|
484
|
+
e ? e.push(n) : t.set(n.pageIndex, [n]);
|
|
485
|
+
}
|
|
486
|
+
return t;
|
|
487
|
+
}
|
|
488
|
+
let Ct = t(() => St(k.value.srcBoxes)), wt = t(() => St(k.value.tgtBoxes));
|
|
489
|
+
function q(e) {
|
|
490
|
+
return e === "src" ? w.sourcePages : w.targetPages;
|
|
491
|
+
}
|
|
492
|
+
function J(e) {
|
|
493
|
+
return e === "src" ? I.value : L.value;
|
|
494
|
+
}
|
|
495
|
+
function Y(e) {
|
|
496
|
+
return e === "src" ? P.value : F.value;
|
|
497
|
+
}
|
|
498
|
+
function Tt(e) {
|
|
499
|
+
return e === "src" ? ce.value : le.value;
|
|
500
|
+
}
|
|
501
|
+
function Et(e) {
|
|
502
|
+
return e === "src" ? ue.value : de.value;
|
|
503
|
+
}
|
|
504
|
+
function Dt(e) {
|
|
505
|
+
let t = ve.get(e.imageUrl);
|
|
506
|
+
if (t) return t;
|
|
507
|
+
if (e.width && e.height) return {
|
|
508
|
+
width: e.width,
|
|
509
|
+
height: e.height
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
function Ot(e, t) {
|
|
513
|
+
let n = e.map(Dt).find(Boolean), r = n ? n.height / n.width : _e, i = [], a = 0;
|
|
514
|
+
for (let n of e) {
|
|
515
|
+
let e = Dt(n), o = e ? e.height / e.width : r, s = Math.max(1, Math.round(t * o));
|
|
516
|
+
i.push({
|
|
517
|
+
top: a,
|
|
518
|
+
width: t,
|
|
519
|
+
height: s,
|
|
520
|
+
naturalWidth: e?.width ?? t,
|
|
521
|
+
naturalHeight: e?.height ?? s,
|
|
522
|
+
measured: !!e
|
|
523
|
+
}), a += s + vt;
|
|
524
|
+
}
|
|
525
|
+
return i;
|
|
526
|
+
}
|
|
527
|
+
function kt(e, t) {
|
|
528
|
+
if (e.length === 0) return 0;
|
|
529
|
+
let n = 0, r = e.length - 1;
|
|
530
|
+
for (; n <= r;) {
|
|
531
|
+
let i = Math.floor((n + r) / 2), a = e[i];
|
|
532
|
+
if (t < a.top) r = i - 1;
|
|
533
|
+
else if (t >= a.top + a.height + vt) n = i + 1;
|
|
534
|
+
else return i;
|
|
535
|
+
}
|
|
536
|
+
return Math.max(0, Math.min(e.length - 1, n));
|
|
537
|
+
}
|
|
538
|
+
function X(e, t = !1) {
|
|
539
|
+
let n = Y(e);
|
|
540
|
+
if (!n || n.clientWidth <= 0) return;
|
|
541
|
+
let r = J(e), i = n.scrollTop, a = r.length > 0 ? kt(r, i) : 0, o = r[a], s = o ? Math.max(0, Math.min(1, (i - o.top) / o.height)) : 0, c = Ot(q(e), n.clientWidth), l = c.length > 0 ? c[c.length - 1].top + c[c.length - 1].height : 1;
|
|
542
|
+
if (e === "src" ? (I.value = c, pe.value = l, he.value = Math.max(1, n.clientHeight)) : (L.value = c, me.value = l, ge.value = Math.max(1, n.clientHeight)), t && o && c[a]) {
|
|
543
|
+
let e = c[a].top + c[a].height * s;
|
|
544
|
+
f(() => {
|
|
545
|
+
n.scrollTop = e;
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
Q(e);
|
|
549
|
+
}
|
|
550
|
+
function At() {
|
|
551
|
+
for (; V < bt && xt.length > 0;) xt.shift()?.();
|
|
552
|
+
}
|
|
553
|
+
function jt(e) {
|
|
554
|
+
for (let t of ["src", "tgt"]) {
|
|
555
|
+
let n = q(t), r = It(t);
|
|
556
|
+
if (r) {
|
|
557
|
+
let t = Math.max(0, r.start - 1), i = Math.min(n.length - 1, r.end + 1);
|
|
558
|
+
for (let r = t; r <= i; r++) if (n[r]?.imageUrl === e) return !0;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
let t = w.diffDetail[A.value];
|
|
562
|
+
return !(!t || w.sourcePages[t.srcPage]?.imageUrl !== e && w.targetPages[t.tgtPage]?.imageUrl !== e);
|
|
563
|
+
}
|
|
564
|
+
function Mt(e) {
|
|
565
|
+
return new Promise((t, n) => {
|
|
566
|
+
xt.push(() => {
|
|
567
|
+
if (!jt(e)) {
|
|
568
|
+
let t = /* @__PURE__ */ Error(`已取消非可见页面加载: ${e}`);
|
|
569
|
+
t.name = "AbortError", n(t);
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
V++;
|
|
573
|
+
let r = new Image();
|
|
574
|
+
w.imageCrossOrigin !== null && (r.crossOrigin = w.imageCrossOrigin), r.onload = () => {
|
|
575
|
+
r.onload = null, r.onerror = null, V--, At(), t(r);
|
|
576
|
+
}, r.onerror = () => {
|
|
577
|
+
r.onload = null, r.onerror = null, V--, At(), K || T("image-error", e), n(/* @__PURE__ */ Error(`图片加载失败: ${e}`));
|
|
578
|
+
}, r.src = e;
|
|
579
|
+
}), At();
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
function Nt(e) {
|
|
583
|
+
let t = R.get(e);
|
|
584
|
+
if (t?.image) return t.lastUsed = ++B, Promise.resolve(t.image);
|
|
585
|
+
if (t?.promise) return t.promise;
|
|
586
|
+
if (z.has(e)) return Promise.reject(/* @__PURE__ */ Error(`图片加载失败: ${e}`));
|
|
587
|
+
let n = { lastUsed: ++B };
|
|
588
|
+
return n.promise = Mt(e).then((e) => (n.image = e, n.promise = void 0, n.lastUsed = ++B, e)).catch((t) => {
|
|
589
|
+
throw R.delete(e), t instanceof Error && t.name !== "AbortError" && z.add(e), t;
|
|
590
|
+
}), R.set(e, n), n.promise;
|
|
591
|
+
}
|
|
592
|
+
function Pt() {
|
|
593
|
+
let e = [...R.entries()].filter(([, e]) => e.image).sort((e, t) => e[1].lastUsed - t[1].lastUsed);
|
|
594
|
+
for (; R.size > yt && e.length > 0;) {
|
|
595
|
+
let [t, n] = e.shift();
|
|
596
|
+
n.image.src = "", R.delete(t);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
function Ft(e, t) {
|
|
600
|
+
let n = q(e)[t];
|
|
601
|
+
if (!n) return Promise.resolve();
|
|
602
|
+
let r = R.get(n.imageUrl)?.image, i = ve.get(n.imageUrl);
|
|
603
|
+
if (r && i) return R.get(n.imageUrl).lastUsed = ++B, Promise.resolve();
|
|
604
|
+
let a = `${e}:${t}:${n.imageUrl}`, o = ye.get(a);
|
|
605
|
+
if (o) return o;
|
|
606
|
+
let s = Nt(n.imageUrl).then((r) => {
|
|
607
|
+
if (K || q(e)[t]?.imageUrl !== n.imageUrl) return;
|
|
608
|
+
let i = ve.get(n.imageUrl), a = i?.width !== r.naturalWidth || i?.height !== r.naturalHeight;
|
|
609
|
+
ve.set(n.imageUrl, {
|
|
610
|
+
width: r.naturalWidth,
|
|
611
|
+
height: r.naturalHeight
|
|
612
|
+
}), a ? X(e, !0) : Q(e), Pt();
|
|
613
|
+
}).catch(() => void 0).finally(() => {
|
|
614
|
+
ye.delete(a);
|
|
615
|
+
});
|
|
616
|
+
return ye.set(a, s), s;
|
|
617
|
+
}
|
|
618
|
+
function It(e) {
|
|
619
|
+
let t = Y(e), n = J(e);
|
|
620
|
+
if (t && n.length !== 0) return {
|
|
621
|
+
start: kt(n, t.scrollTop),
|
|
622
|
+
end: kt(n, t.scrollTop + t.clientHeight)
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
function Lt(e, t, n) {
|
|
626
|
+
let r = Math.min(window.devicePixelRatio || 1, 2), i = Math.max(1, Math.round(t * r)), a = Math.max(1, Math.round(n * r));
|
|
627
|
+
(e.width !== i || e.height !== a) && (e.width = i, e.height = a), e.style.width = `${t}px`, e.style.height = `${n}px`;
|
|
628
|
+
let o = e.getContext("2d");
|
|
629
|
+
return o.setTransform(r, 0, 0, r, 0, 0), o.clearRect(0, 0, t, n), o;
|
|
630
|
+
}
|
|
631
|
+
let Rt = {
|
|
632
|
+
gray: {
|
|
633
|
+
fill: "rgba(148,163,184,0.12)",
|
|
634
|
+
stroke: "#94a3b8",
|
|
635
|
+
pulse: "#64748b"
|
|
636
|
+
},
|
|
637
|
+
red: {
|
|
638
|
+
fill: "rgba(255,0,0,0.2)",
|
|
639
|
+
stroke: "red",
|
|
640
|
+
pulse: "rgba(255,0,0,0.65)"
|
|
641
|
+
},
|
|
642
|
+
green: {
|
|
643
|
+
fill: "rgba(0,255,0,0.2)",
|
|
644
|
+
stroke: "green",
|
|
645
|
+
pulse: "rgba(0,128,0,0.65)"
|
|
646
|
+
},
|
|
647
|
+
orange: {
|
|
648
|
+
fill: "rgba(255,136,0,0.2)",
|
|
649
|
+
stroke: "#FF8800",
|
|
650
|
+
pulse: "rgba(255,136,0,0.7)"
|
|
651
|
+
}
|
|
652
|
+
};
|
|
653
|
+
function zt(e) {
|
|
654
|
+
return e < .3 ? Math.sin(e / .3 * Math.PI) : e >= .38 && e < .7 ? .85 * Math.sin((e - .38) / .32 * Math.PI) : 0;
|
|
655
|
+
}
|
|
656
|
+
function Z(e) {
|
|
657
|
+
let t = Et(e), n = Y(e), r = It(e);
|
|
658
|
+
if (!t || !n || n.clientWidth <= 0 || n.clientHeight <= 0) return;
|
|
659
|
+
let i = Lt(t, n.clientWidth, n.clientHeight);
|
|
660
|
+
if (!r) {
|
|
661
|
+
e === "src" ? xe = [] : Se = [];
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
let a = J(e), o = e === "src" ? Ct.value : wt.value, s = [], c;
|
|
665
|
+
for (let e = r.start; e <= r.end; e++) {
|
|
666
|
+
let t = a[e];
|
|
667
|
+
if (!t?.measured) continue;
|
|
668
|
+
let r = t.width / t.naturalWidth;
|
|
669
|
+
for (let a of o.get(e) ?? []) {
|
|
670
|
+
if (a.isGap && a.pairIndex !== A.value) continue;
|
|
671
|
+
let e = Math.round(a.x * r), o = Math.round(t.top - n.scrollTop + a.y * r), l = Math.max(1, Math.round(a.w * r)), u = Math.max(1, Math.round(a.h * r)), d = Rt[a.color];
|
|
672
|
+
i.fillStyle = d.fill, i.fillRect(e, o, l, u), i.strokeStyle = d.stroke, i.lineWidth = 1, i.strokeRect(e, o, l, u), s.push({
|
|
673
|
+
x: e,
|
|
674
|
+
y: o,
|
|
675
|
+
w: l,
|
|
676
|
+
h: u,
|
|
677
|
+
pairIndex: a.pairIndex
|
|
678
|
+
}), a.pairIndex === A.value && (c = {
|
|
679
|
+
x: e,
|
|
680
|
+
y: o,
|
|
681
|
+
w: l,
|
|
682
|
+
h: u,
|
|
683
|
+
color: a.color
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
if (c && G !== null) {
|
|
688
|
+
let e = zt(G);
|
|
689
|
+
e > 0 && (i.save(), i.globalAlpha = e, i.strokeStyle = Rt[c.color].pulse, i.lineWidth = 1 + e * 4, i.shadowColor = Rt[c.color].pulse, i.shadowBlur = e * 8, i.strokeRect(c.x, c.y, c.w, c.h), i.restore());
|
|
690
|
+
}
|
|
691
|
+
e === "src" ? xe = s : Se = s;
|
|
692
|
+
}
|
|
693
|
+
function Bt(e) {
|
|
694
|
+
let t = Tt(e), n = Y(e), r = It(e);
|
|
695
|
+
if (!t || !n || n.clientWidth <= 0 || n.clientHeight <= 0) return;
|
|
696
|
+
let i = Lt(t, n.clientWidth, n.clientHeight);
|
|
697
|
+
if (i.fillStyle = "#eef0f3", i.fillRect(0, 0, n.clientWidth, n.clientHeight), !r) {
|
|
698
|
+
Z(e);
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
let a = J(e), o = q(e);
|
|
702
|
+
for (let t = r.start; t <= r.end; t++) {
|
|
703
|
+
let r = o[t], s = a[t], c = s.top - n.scrollTop;
|
|
704
|
+
i.fillStyle = "#fff", i.fillRect(0, c, s.width, s.height);
|
|
705
|
+
let l = R.get(r.imageUrl);
|
|
706
|
+
l?.image ? (l.lastUsed = ++B, i.drawImage(l.image, 0, c, s.width, s.height)) : (i.fillStyle = "#8a9099", i.font = "14px Segoe UI, Microsoft YaHei, sans-serif", i.textAlign = "center", i.fillText(`第 ${t + 1} 页加载中…`, s.width / 2, c + Math.min(48, s.height / 2)), Ft(e, t));
|
|
707
|
+
}
|
|
708
|
+
let s = Math.max(0, r.start - 1), c = Math.min(o.length - 1, r.end + 1);
|
|
709
|
+
for (let t = s; t <= c; t++) (t < r.start || t > r.end) && Ft(e, t);
|
|
710
|
+
Z(e);
|
|
711
|
+
}
|
|
712
|
+
function Q(e) {
|
|
713
|
+
(!e || e === "src") && (De = !0), (!e || e === "tgt") && (Oe = !0), !H && (H = requestAnimationFrame(() => {
|
|
714
|
+
H = 0;
|
|
715
|
+
let e = De, t = Oe;
|
|
716
|
+
De = !1, Oe = !1, e && Bt("src"), t && Bt("tgt"), Gt(), Ut();
|
|
717
|
+
}));
|
|
718
|
+
}
|
|
719
|
+
function Vt() {
|
|
720
|
+
U ||= requestAnimationFrame(() => {
|
|
721
|
+
U = 0, X("src", !0), X("tgt", !0);
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
function Ht(e) {
|
|
725
|
+
let t = (e === "src" ? k.value.srcBoxes : k.value.tgtBoxes).find((e) => e.pairIndex === A.value), n = Y(e), r = t ? J(e)[t.pageIndex] : void 0;
|
|
726
|
+
if (!t || !n || !r?.measured) return;
|
|
727
|
+
let i = r.width / r.naturalWidth;
|
|
728
|
+
return {
|
|
729
|
+
x: e === "src" ? (t.x + t.w) * i : t.x * i,
|
|
730
|
+
y: r.top + (t.y + t.h / 2) * i - n.scrollTop,
|
|
731
|
+
color: t.color
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
function Ut() {
|
|
735
|
+
if (!fe.value || !se.value || !P.value || !F.value || !ue.value || !de.value) return;
|
|
736
|
+
let e = fe.value, t = e.querySelector("path"), n = Ht("src"), r = Ht("tgt");
|
|
737
|
+
if (!n || !r) {
|
|
738
|
+
t?.remove();
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
let i = se.value.getBoundingClientRect(), a = P.value.getBoundingClientRect(), o = F.value.getBoundingClientRect(), s = ue.value.getBoundingClientRect(), c = de.value.getBoundingClientRect(), l = a.top - i.top, u = a.left - i.left, d = o.right - a.left, f = a.height, p = (t, n) => {
|
|
742
|
+
let r = `${n}px`;
|
|
743
|
+
e.style[t] !== r && (e.style[t] = r);
|
|
744
|
+
}, m = (e, t, n) => {
|
|
745
|
+
e.getAttribute(t) !== n && e.setAttribute(t, n);
|
|
746
|
+
};
|
|
747
|
+
p("top", l), p("left", u), p("width", d), p("height", f), m(e, "width", String(d)), m(e, "height", String(f));
|
|
748
|
+
let h = s.left - a.left, ee = c.left - a.left, te = h + n.x, g = n.y, _ = ee + r.x, v = r.y, y = s.right - a.left, b = ee, x = y + (b - y) / 2, S = `M${te},${g} L${y},${g} C${x},${g} ${x},${v} ${b},${v} L${_},${v}`, C = t ?? document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
749
|
+
m(C, "d", S), m(C, "fill", "none"), m(C, "stroke", Rt[n.color].stroke), m(C, "stroke-width", "2"), m(C, "stroke-dasharray", "6 4"), t || e.appendChild(C);
|
|
750
|
+
}
|
|
751
|
+
function Wt(e) {
|
|
752
|
+
Q(e);
|
|
753
|
+
}
|
|
754
|
+
function Gt() {
|
|
755
|
+
P.value && I.value.length > 0 && (M.value = kt(I.value, P.value.scrollTop)), F.value && L.value.length > 0 && (N.value = kt(L.value, F.value.scrollTop));
|
|
756
|
+
}
|
|
757
|
+
function Kt(e, t) {
|
|
758
|
+
let n = q(e), r = Y(e), i = J(e)[t];
|
|
759
|
+
t < 0 || t >= n.length || !r || !i || (e === "src" ? M.value = t : N.value = t, f(() => {
|
|
760
|
+
r.scrollTop = i.top, Q(e);
|
|
761
|
+
}));
|
|
762
|
+
}
|
|
763
|
+
function qt(e) {
|
|
764
|
+
Kt("src", e);
|
|
765
|
+
}
|
|
766
|
+
function Jt(e) {
|
|
767
|
+
Kt("tgt", e);
|
|
768
|
+
}
|
|
769
|
+
function Yt(e, t, n) {
|
|
770
|
+
let r = q(e), i = Y(e), a = J(e)[n];
|
|
771
|
+
if (n < 0 || n >= r.length || !i || !a) return;
|
|
772
|
+
let o = (e === "src" ? k.value.srcBoxes : k.value.tgtBoxes).find((e) => e.pairIndex === t);
|
|
773
|
+
e === "src" ? M.value = n : N.value = n, f(() => {
|
|
774
|
+
let t = J(e)[n];
|
|
775
|
+
if (!t) return;
|
|
776
|
+
let r = o ? t.top + (o.y + o.h / 2) * (t.width / t.naturalWidth) - i.clientHeight / 2 : t.top, a = Math.max(0, i.scrollHeight - i.clientHeight);
|
|
777
|
+
i.scrollTop = Math.max(0, Math.min(a, r)), Q(e);
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
function Xt(e) {
|
|
781
|
+
let t = w.diffDetail[e];
|
|
782
|
+
t && (Yt("src", e, t.srcPage), Yt("tgt", e, t.tgtPage));
|
|
783
|
+
}
|
|
784
|
+
function Zt() {
|
|
785
|
+
if (W && cancelAnimationFrame(W), window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
|
|
786
|
+
W = 0, G = null, Z("src"), Z("tgt");
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
let e = performance.now(), t = (n) => {
|
|
790
|
+
G = Math.min(1, (n - e) / 720), Z("src"), Z("tgt"), G < 1 ? W = requestAnimationFrame(t) : (W = 0, G = null, Z("src"), Z("tgt"));
|
|
791
|
+
};
|
|
792
|
+
W = requestAnimationFrame(t);
|
|
793
|
+
}
|
|
794
|
+
async function Qt(e) {
|
|
795
|
+
let t = w.diffDetail[e];
|
|
796
|
+
t && (await Promise.all([Ft("src", t.srcPage), Ft("tgt", t.tgtPage)]), !(K || A.value !== e) && (Xt(e), Q(), Zt()));
|
|
797
|
+
}
|
|
798
|
+
function $(e) {
|
|
799
|
+
K || (T("select", w.diffDetail[e] ?? null, e), A.value = e, Xt(e), Q(), Qt(e));
|
|
800
|
+
}
|
|
801
|
+
function $t(e, t) {
|
|
802
|
+
let n = Et(t), r = Y(t);
|
|
803
|
+
if (!n || !r) return;
|
|
804
|
+
let i = n.getBoundingClientRect(), a = (e.clientX - i.left) * r.clientWidth / i.width, o = (e.clientY - i.top) * r.clientHeight / i.height, s = t === "src" ? xe : Se;
|
|
805
|
+
for (let e = s.length - 1; e >= 0; e--) {
|
|
806
|
+
let t = s[e];
|
|
807
|
+
if (a >= t.x - 3 && a <= t.x + t.w + 3 && o >= t.y - 3 && o <= t.y + t.h + 3) return t.pairIndex;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
function en(e, t) {
|
|
811
|
+
let n = $t(e, t);
|
|
812
|
+
n !== void 0 && $(n);
|
|
813
|
+
}
|
|
814
|
+
function tn(e, t) {
|
|
815
|
+
let n = e.currentTarget;
|
|
816
|
+
n.style.cursor = $t(e, t) === void 0 ? "default" : "pointer";
|
|
817
|
+
}
|
|
818
|
+
let nn = t(() => O.value[0]?.idx ?? -1);
|
|
819
|
+
function rn() {
|
|
820
|
+
I.value = [], L.value = [], pe.value = 1, me.value = 1, xe = [], Se = [], z.clear();
|
|
821
|
+
}
|
|
822
|
+
te(async () => {
|
|
823
|
+
K = !1, await f(), X("src"), X("tgt"), await f(), $(nn.value), Ae = new ResizeObserver(Vt), P.value && Ae.observe(P.value), F.value && Ae.observe(F.value);
|
|
824
|
+
}), S(() => [w.sourcePages, w.targetPages], async () => {
|
|
825
|
+
rn(), await f(), X("src"), X("tgt"), await f(), $(nn.value);
|
|
826
|
+
}, { deep: !0 }), S([j, D], () => {
|
|
827
|
+
T("filter-change", j.value, D.value), $(nn.value);
|
|
828
|
+
}), S(() => w.diffDetail, () => {
|
|
829
|
+
let e = A.value;
|
|
830
|
+
$((O.value.find((t) => t.idx >= e) ?? O.value[O.value.length - 1])?.idx ?? -1);
|
|
831
|
+
}), ee(() => {
|
|
832
|
+
K = !0, Ae?.disconnect(), H && cancelAnimationFrame(H), U && cancelAnimationFrame(U), W && cancelAnimationFrame(W);
|
|
833
|
+
for (let e of R.values()) e.image && (e.image.src = "");
|
|
834
|
+
R.clear();
|
|
835
|
+
});
|
|
836
|
+
async function an(e) {
|
|
837
|
+
let t = typeof e == "string" ? w.diffDetail.findIndex((t) => t.diffId === e) : e;
|
|
838
|
+
return !Number.isInteger(t) || !w.diffDetail[t] || K ? !1 : (ae.value.has(t) || (j.value = "all", D.value = "all", await f()), $(t), !0);
|
|
839
|
+
}
|
|
840
|
+
function on(e) {
|
|
841
|
+
let t = O.value.findIndex((e) => e.idx === A.value), n = O.value[t + e];
|
|
842
|
+
return n ? ($(n.idx), !0) : !1;
|
|
843
|
+
}
|
|
844
|
+
function sn(e, t) {
|
|
845
|
+
let n = e === "source" ? "src" : "tgt";
|
|
846
|
+
return !Number.isInteger(t) || t < 0 || t >= q(n).length ? !1 : (Kt(n, t), !0);
|
|
847
|
+
}
|
|
848
|
+
function cn(e, t = D.value) {
|
|
849
|
+
j.value = e, D.value = t;
|
|
850
|
+
}
|
|
851
|
+
function ln() {
|
|
852
|
+
z.clear(), Q();
|
|
853
|
+
}
|
|
854
|
+
return S(M, (e) => T("page-change", "source", e)), S(N, (e) => T("page-change", "target", e)), d({
|
|
855
|
+
selectDiff: an,
|
|
856
|
+
nextDiff: () => on(1),
|
|
857
|
+
previousDiff: () => on(-1),
|
|
858
|
+
goToPage: sn,
|
|
859
|
+
setFilter: cn,
|
|
860
|
+
resize: Vt,
|
|
861
|
+
retryImages: ln
|
|
862
|
+
}), (t, d) => (g(), i("div", Me, [
|
|
863
|
+
y(t.$slots, "toolbar", {
|
|
864
|
+
activeIndex: A.value,
|
|
865
|
+
selectDiff: an,
|
|
866
|
+
setFilter: cn
|
|
867
|
+
}, void 0, !0),
|
|
868
|
+
a("div", Ne, [a("div", Pe, [w.sourcePages.length > 0 || w.targetPages.length > 0 ? (g(), i("div", {
|
|
869
|
+
key: 0,
|
|
870
|
+
ref_key: "containerRef",
|
|
871
|
+
ref: se,
|
|
872
|
+
class: "compare-row"
|
|
873
|
+
}, [
|
|
874
|
+
a("div", Fe, [w.sourcePages.length ? (g(), i("div", Ie, [a("div", Le, [d[18] ||= a("div", { class: "canvas-info-bar-left-tag" }, "标准文档", -1), a("div", Re, [y(t.$slots, "source-title", { filename: w.sourceFilename }, () => [s(b(w.sourceFilename || "标准文档"), 1)], !0)])]), a("div", ze, [
|
|
875
|
+
a("button", {
|
|
876
|
+
class: "page-btn",
|
|
877
|
+
disabled: M.value <= 0,
|
|
878
|
+
title: "第一页",
|
|
879
|
+
"aria-label": "标准文档第一页",
|
|
880
|
+
onClick: d[0] ||= (e) => qt(0)
|
|
881
|
+
}, [c(x(Te), { "aria-hidden": "true" })], 8, Be),
|
|
882
|
+
a("button", {
|
|
883
|
+
class: "page-btn",
|
|
884
|
+
disabled: M.value <= 0,
|
|
885
|
+
title: "上一页",
|
|
886
|
+
"aria-label": "标准文档上一页",
|
|
887
|
+
onClick: d[1] ||= (e) => qt(M.value - 1)
|
|
888
|
+
}, [c(x(Ee), { "aria-hidden": "true" })], 8, Ve),
|
|
889
|
+
a("span", He, b(M.value + 1) + " / " + b(w.sourcePages.length), 1),
|
|
890
|
+
a("button", {
|
|
891
|
+
class: "page-btn",
|
|
892
|
+
disabled: M.value >= w.sourcePages.length - 1,
|
|
893
|
+
title: "下一页",
|
|
894
|
+
"aria-label": "标准文档下一页",
|
|
895
|
+
onClick: d[2] ||= (e) => qt(M.value + 1)
|
|
896
|
+
}, [c(x(ke), { "aria-hidden": "true" })], 8, Ue),
|
|
897
|
+
a("button", {
|
|
898
|
+
class: "page-btn",
|
|
899
|
+
disabled: M.value >= w.sourcePages.length - 1,
|
|
900
|
+
title: "最后一页",
|
|
901
|
+
"aria-label": "标准文档最后一页",
|
|
902
|
+
onClick: d[3] ||= (e) => qt(w.sourcePages.length - 1)
|
|
903
|
+
}, [c(x(je), { "aria-hidden": "true" })], 8, We)
|
|
904
|
+
])])) : r("", !0), a("div", {
|
|
905
|
+
ref_key: "srcScrollRef",
|
|
906
|
+
ref: P,
|
|
907
|
+
class: "canvas-scroll",
|
|
908
|
+
onScroll: d[6] ||= (e) => Wt("src")
|
|
909
|
+
}, [a("div", {
|
|
910
|
+
class: "virtual-spacer",
|
|
911
|
+
style: h({ height: `${pe.value}px` })
|
|
912
|
+
}, [a("div", {
|
|
913
|
+
class: "viewport-canvas-stack",
|
|
914
|
+
style: h({ height: `${he.value}px` })
|
|
915
|
+
}, [a("canvas", {
|
|
916
|
+
ref_key: "srcCanvasRef",
|
|
917
|
+
ref: ce,
|
|
918
|
+
class: "compare-canvas"
|
|
919
|
+
}, null, 512), a("canvas", {
|
|
920
|
+
ref_key: "srcAnnotationCanvasRef",
|
|
921
|
+
ref: ue,
|
|
922
|
+
class: "annotation-canvas",
|
|
923
|
+
onClick: d[4] ||= (e) => en(e, "src"),
|
|
924
|
+
onMousemove: d[5] ||= (e) => tn(e, "src")
|
|
925
|
+
}, null, 544)], 4)], 4)], 544)]),
|
|
926
|
+
a("div", Ge, [w.targetPages.length ? (g(), i("div", Ke, [a("div", qe, [d[19] ||= a("div", { class: "canvas-info-bar-left-tag gray" }, "对比文档", -1), a("div", Je, [y(t.$slots, "target-title", { filename: w.targetFilename }, () => [s(b(w.targetFilename || "对比文档"), 1)], !0)])]), a("div", Ye, [
|
|
927
|
+
a("button", {
|
|
928
|
+
class: "page-btn",
|
|
929
|
+
disabled: N.value <= 0,
|
|
930
|
+
title: "第一页",
|
|
931
|
+
"aria-label": "对比文档第一页",
|
|
932
|
+
onClick: d[7] ||= (e) => Jt(0)
|
|
933
|
+
}, [c(x(Te), { "aria-hidden": "true" })], 8, Xe),
|
|
934
|
+
a("button", {
|
|
935
|
+
class: "page-btn",
|
|
936
|
+
disabled: N.value <= 0,
|
|
937
|
+
title: "上一页",
|
|
938
|
+
"aria-label": "对比文档上一页",
|
|
939
|
+
onClick: d[8] ||= (e) => Jt(N.value - 1)
|
|
940
|
+
}, [c(x(Ee), { "aria-hidden": "true" })], 8, Ze),
|
|
941
|
+
a("span", Qe, b(N.value + 1) + " / " + b(w.targetPages.length), 1),
|
|
942
|
+
a("button", {
|
|
943
|
+
class: "page-btn",
|
|
944
|
+
disabled: N.value >= w.targetPages.length - 1,
|
|
945
|
+
title: "下一页",
|
|
946
|
+
"aria-label": "对比文档下一页",
|
|
947
|
+
onClick: d[9] ||= (e) => Jt(N.value + 1)
|
|
948
|
+
}, [c(x(ke), { "aria-hidden": "true" })], 8, $e),
|
|
949
|
+
a("button", {
|
|
950
|
+
class: "page-btn",
|
|
951
|
+
disabled: N.value >= w.targetPages.length - 1,
|
|
952
|
+
title: "最后一页",
|
|
953
|
+
"aria-label": "对比文档最后一页",
|
|
954
|
+
onClick: d[10] ||= (e) => Jt(w.targetPages.length - 1)
|
|
955
|
+
}, [c(x(je), { "aria-hidden": "true" })], 8, et)
|
|
956
|
+
])])) : r("", !0), a("div", {
|
|
957
|
+
ref_key: "tgtScrollRef",
|
|
958
|
+
ref: F,
|
|
959
|
+
class: "canvas-scroll canvas-scroll--flip",
|
|
960
|
+
onScroll: d[13] ||= (e) => Wt("tgt")
|
|
961
|
+
}, [a("div", {
|
|
962
|
+
class: "virtual-spacer",
|
|
963
|
+
style: h({ height: `${me.value}px` })
|
|
964
|
+
}, [a("div", {
|
|
965
|
+
class: "viewport-canvas-stack",
|
|
966
|
+
style: h({ height: `${ge.value}px` })
|
|
967
|
+
}, [a("canvas", {
|
|
968
|
+
ref_key: "tgtCanvasRef",
|
|
969
|
+
ref: le,
|
|
970
|
+
class: "compare-canvas"
|
|
971
|
+
}, null, 512), a("canvas", {
|
|
972
|
+
ref_key: "tgtAnnotationCanvasRef",
|
|
973
|
+
ref: de,
|
|
974
|
+
class: "annotation-canvas",
|
|
975
|
+
onClick: d[11] ||= (e) => en(e, "tgt"),
|
|
976
|
+
onMousemove: d[12] ||= (e) => tn(e, "tgt")
|
|
977
|
+
}, null, 544)], 4)], 4)], 544)]),
|
|
978
|
+
(g(), i("svg", {
|
|
979
|
+
ref_key: "svgRef",
|
|
980
|
+
ref: fe,
|
|
981
|
+
class: "line-svg"
|
|
982
|
+
}, null, 512))
|
|
983
|
+
], 512)) : (g(), i("div", tt, [y(t.$slots, "empty", {}, () => [d[20] ||= s("暂无可展示的页面数据", -1)], !0)]))]), a("aside", nt, [
|
|
984
|
+
a("header", rt, [a("div", it, [a("h2", null, [c(x(we), { "aria-hidden": "true" }), d[21] ||= s("差异审阅", -1)]), a("span", at, "共 " + b(E.value?.total_difference_count ?? w.diffDetail.length) + " 处", 1)]), a("div", ot, [(g(), i(e, null, v([
|
|
985
|
+
"pending",
|
|
986
|
+
"ignored",
|
|
987
|
+
"all"
|
|
988
|
+
], (e) => a("button", {
|
|
989
|
+
key: e,
|
|
990
|
+
"aria-pressed": D.value === e,
|
|
991
|
+
onClick: (t) => D.value = e
|
|
992
|
+
}, [s(b(e === "pending" ? "未忽略" : e === "ignored" ? "已忽略" : "全部") + " ", 1), E.value && e !== "all" ? (g(), i("span", ct, b(e === "pending" ? E.value.remaining_difference_count : E.value.ignored_difference_count), 1)) : r("", !0)], 8, st)), 64))])]),
|
|
993
|
+
a("div", lt, [(g(), i(e, null, v([
|
|
994
|
+
"all",
|
|
995
|
+
"modify",
|
|
996
|
+
"delete",
|
|
997
|
+
"insert"
|
|
998
|
+
], (e) => a("button", {
|
|
999
|
+
key: e,
|
|
1000
|
+
class: "review-type",
|
|
1001
|
+
"aria-pressed": j.value === e,
|
|
1002
|
+
onClick: (t) => j.value = e
|
|
1003
|
+
}, [s(b(e === "all" ? "所有类型" : e === "modify" ? "修改" : e === "delete" ? "删除" : "新增") + " ", 1), a("span", null, b(oe.value[e]), 1)], 8, ut)), 64))]),
|
|
1004
|
+
O.value.length ? (g(), n(be, {
|
|
1005
|
+
key: 1,
|
|
1006
|
+
"diff-detail": w.diffDetail,
|
|
1007
|
+
"active-index": A.value,
|
|
1008
|
+
"active-tab": j.value,
|
|
1009
|
+
"review-filter": D.value,
|
|
1010
|
+
busy: l.reviewBusy,
|
|
1011
|
+
readonly: w.readonly,
|
|
1012
|
+
onIgnore: d[15] ||= (e, t) => T("ignore", e, t),
|
|
1013
|
+
onSelect: $
|
|
1014
|
+
}, o({ _: 2 }, [t.$slots["diff-card"] ? {
|
|
1015
|
+
name: "default",
|
|
1016
|
+
fn: C((e) => [y(t.$slots, "diff-card", m(u(e)), void 0, !0)]),
|
|
1017
|
+
key: "0"
|
|
1018
|
+
} : void 0]), 1032, [
|
|
1019
|
+
"diff-detail",
|
|
1020
|
+
"active-index",
|
|
1021
|
+
"active-tab",
|
|
1022
|
+
"review-filter",
|
|
1023
|
+
"busy",
|
|
1024
|
+
"readonly"
|
|
1025
|
+
])) : (g(), i("div", dt, [E.value?.comparison_passed && D.value === "pending" ? (g(), i(e, { key: 0 }, [
|
|
1026
|
+
a("span", ft, [c(x(Ce), { "aria-hidden": "true" })]),
|
|
1027
|
+
d[22] ||= a("h3", null, "比对通过", -1),
|
|
1028
|
+
a("p", null, b(E.value.total_difference_count ? "全部差异已标记为忽略" : "两个文档未发现差异"), 1),
|
|
1029
|
+
E.value.ignored_difference_count ? (g(), i("button", {
|
|
1030
|
+
key: 0,
|
|
1031
|
+
onClick: d[14] ||= (e) => D.value = "ignored"
|
|
1032
|
+
}, " 查看已忽略的差异 ")) : r("", !0)
|
|
1033
|
+
], 64)) : (g(), i(e, { key: 1 }, [
|
|
1034
|
+
a("span", pt, [c(x(we), { "aria-hidden": "true" })]),
|
|
1035
|
+
d[23] ||= a("h3", null, "暂无差异", -1),
|
|
1036
|
+
d[24] ||= a("p", null, "当前筛选下没有差异项", -1)
|
|
1037
|
+
], 64))])),
|
|
1038
|
+
!w.readonly && E.value ? (g(), i("footer", {
|
|
1039
|
+
key: 2,
|
|
1040
|
+
class: "review-footer",
|
|
1041
|
+
"aria-busy": l.reviewBusy
|
|
1042
|
+
}, [a("button", {
|
|
1043
|
+
class: "batch-ignore",
|
|
1044
|
+
disabled: l.reviewBusy || !E.value.remaining_difference_count,
|
|
1045
|
+
title: "忽略整个任务的所有剩余差异,包含当前筛选之外的差异",
|
|
1046
|
+
"aria-label": "忽略整个任务的所有剩余差异,包含筛选外差异",
|
|
1047
|
+
onClick: d[16] ||= (e) => T("ignore", null, !0)
|
|
1048
|
+
}, [
|
|
1049
|
+
c(x(re), { "aria-hidden": "true" }),
|
|
1050
|
+
d[25] ||= s("忽略全部 ", -1),
|
|
1051
|
+
E.value.remaining_difference_count ? (g(), i("span", gt, b(E.value.remaining_difference_count), 1)) : r("", !0)
|
|
1052
|
+
], 8, ht), a("button", {
|
|
1053
|
+
class: "batch-restore",
|
|
1054
|
+
disabled: l.reviewBusy || !E.value.ignored_difference_count,
|
|
1055
|
+
title: "撤销整个任务的所有忽略,包含当前筛选之外的差异",
|
|
1056
|
+
"aria-label": "撤销整个任务的所有差异忽略",
|
|
1057
|
+
onClick: d[17] ||= (e) => T("ignore", null, !1)
|
|
1058
|
+
}, [c(x(ie), { "aria-hidden": "true" }), d[26] ||= s("全部撤销 ", -1)], 8, _t)], 8, mt)) : r("", !0)
|
|
1059
|
+
])]),
|
|
1060
|
+
y(t.$slots, "footer", {
|
|
1061
|
+
activeIndex: A.value,
|
|
1062
|
+
review: E.value
|
|
1063
|
+
}, void 0, !0)
|
|
1064
|
+
]));
|
|
1065
|
+
}
|
|
1066
|
+
}), [["__scopeId", "data-v-c65c6ace"]]);
|
|
1067
|
+
//#endregion
|
|
1068
|
+
export { xt as OcrResultView };
|