@cnc_cbz/usefultools-plugin-official 1.0.1
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 +56 -0
- package/dist/base-converter.mjs +333 -0
- package/dist/case-converter.mjs +142 -0
- package/dist/chmod-calculator.mjs +286 -0
- package/dist/color-converter.mjs +211 -0
- package/dist/cron-expression.mjs +487 -0
- package/dist/cyber-chef.mjs +24885 -0
- package/dist/hash-generator.mjs +239 -0
- package/dist/html-entity.mjs +187 -0
- package/dist/image-compressor.mjs +337 -0
- package/dist/ip-subnet.mjs +222 -0
- package/dist/js-runner.mjs +39973 -0
- package/dist/json-diff.mjs +704 -0
- package/dist/json-formatter.mjs +1138 -0
- package/dist/json-yaml.mjs +256 -0
- package/dist/jwt-parser.mjs +405 -0
- package/dist/lorem-ipsum.mjs +246 -0
- package/dist/markdown-preview.mjs +184 -0
- package/dist/password-generator.mjs +254 -0
- package/dist/qr-generator.mjs +238 -0
- package/dist/regex-tester.mjs +424 -0
- package/dist/sql-formatter.mjs +242 -0
- package/dist/text-diff.mjs +940 -0
- package/dist/text-stats.mjs +205 -0
- package/dist/timestamp-converter.mjs +339 -0
- package/dist/translator.mjs +667 -0
- package/dist/url-codec.mjs +179 -0
- package/dist/uuid-generator.mjs +165 -0
- package/package.json +56 -0
- package/plugin.json +31 -0
|
@@ -0,0 +1,704 @@
|
|
|
1
|
+
import { defineComponent, ref, computed, onBeforeUnmount, openBlock, createElementBlock, createCommentVNode, createElementVNode, createTextVNode, toDisplayString, withDirectives, vModelText, Fragment, renderList, normalizeStyle, normalizeClass, nextTick } from "vue";
|
|
2
|
+
const _hoisted_1 = { class: "flex flex-col h-full gap-3" };
|
|
3
|
+
const _hoisted_2 = { class: "flex flex-wrap items-center gap-3" };
|
|
4
|
+
const _hoisted_3 = { class: "ml-auto flex items-center gap-3" };
|
|
5
|
+
const _hoisted_4 = {
|
|
6
|
+
key: 0,
|
|
7
|
+
class: "flex items-center gap-3 text-sm font-bold"
|
|
8
|
+
};
|
|
9
|
+
const _hoisted_5 = { class: "text-neon-green" };
|
|
10
|
+
const _hoisted_6 = { class: "text-primary" };
|
|
11
|
+
const _hoisted_7 = { class: "text-coral-red" };
|
|
12
|
+
const _hoisted_8 = {
|
|
13
|
+
key: 0,
|
|
14
|
+
class: "px-4 py-2 bg-coral-red/20 border-2 border-coral-red rounded flex items-center gap-2 text-coral-red font-bold text-sm"
|
|
15
|
+
};
|
|
16
|
+
const _hoisted_9 = {
|
|
17
|
+
key: 1,
|
|
18
|
+
class: "flex-1 grid grid-cols-2 gap-3 min-h-0"
|
|
19
|
+
};
|
|
20
|
+
const _hoisted_10 = { class: "flex flex-col min-h-0" };
|
|
21
|
+
const _hoisted_11 = { class: "flex items-center gap-2 mb-1.5" };
|
|
22
|
+
const _hoisted_12 = { class: "flex flex-col min-h-0" };
|
|
23
|
+
const _hoisted_13 = { class: "flex items-center gap-2 mb-1.5" };
|
|
24
|
+
const _hoisted_14 = {
|
|
25
|
+
class: "absolute inset-0 w-full h-full pointer-events-none z-10",
|
|
26
|
+
style: { "overflow": "visible" }
|
|
27
|
+
};
|
|
28
|
+
const _hoisted_15 = ["d", "stroke"];
|
|
29
|
+
const _hoisted_16 = { class: "p-2 font-mono text-sm" };
|
|
30
|
+
const _hoisted_17 = ["data-path"];
|
|
31
|
+
const _hoisted_18 = {
|
|
32
|
+
key: 1,
|
|
33
|
+
class: "text-gray-600 ml-0.5"
|
|
34
|
+
};
|
|
35
|
+
const _hoisted_19 = { class: "p-2 font-mono text-sm" };
|
|
36
|
+
const _hoisted_20 = ["data-path"];
|
|
37
|
+
const _hoisted_21 = {
|
|
38
|
+
key: 1,
|
|
39
|
+
class: "text-gray-600 ml-0.5"
|
|
40
|
+
};
|
|
41
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
42
|
+
__name: "index",
|
|
43
|
+
setup(__props) {
|
|
44
|
+
const oldJson = ref("");
|
|
45
|
+
const newJson = ref("");
|
|
46
|
+
const errorMsg = ref("");
|
|
47
|
+
const hasCompared = ref(false);
|
|
48
|
+
const leftRows = ref([]);
|
|
49
|
+
const rightRows = ref([]);
|
|
50
|
+
const diffMap = ref(/* @__PURE__ */ new Map());
|
|
51
|
+
const lines = ref([]);
|
|
52
|
+
const wrapperRef = ref(null);
|
|
53
|
+
const leftPanelRef = ref(null);
|
|
54
|
+
const rightPanelRef = ref(null);
|
|
55
|
+
function flatten(val, path, key, depth, parentIsArr, out) {
|
|
56
|
+
const isObj = val !== null && typeof val === "object";
|
|
57
|
+
if (isObj) {
|
|
58
|
+
out.push({ path, key, depth, val, isLeaf: false, parentIsArr });
|
|
59
|
+
const childIsArr = Array.isArray(val);
|
|
60
|
+
for (const k of Object.keys(val)) {
|
|
61
|
+
const cp = path ? childIsArr ? `${path}[${k}]` : `${path}.${k}` : k;
|
|
62
|
+
flatten(val[k], cp, k, depth + 1, childIsArr, out);
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
out.push({ path, key, depth, val, isLeaf: true, parentIsArr });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function collectDiff(oldVal, newVal, path, map) {
|
|
69
|
+
const oIsObj = oldVal !== null && typeof oldVal === "object";
|
|
70
|
+
const nIsObj = newVal !== null && typeof newVal === "object";
|
|
71
|
+
if (oIsObj && nIsObj && Array.isArray(oldVal) === Array.isArray(newVal)) {
|
|
72
|
+
const allKeys = /* @__PURE__ */ new Set([...Object.keys(oldVal), ...Object.keys(newVal)]);
|
|
73
|
+
const isArr = Array.isArray(oldVal);
|
|
74
|
+
for (const k of allKeys) {
|
|
75
|
+
const cp = path ? isArr ? `${path}[${k}]` : `${path}.${k}` : k;
|
|
76
|
+
if (k in oldVal && k in newVal) {
|
|
77
|
+
collectDiff(oldVal[k], newVal[k], cp, map);
|
|
78
|
+
} else if (k in oldVal) {
|
|
79
|
+
markAll(oldVal[k], cp, "removed", map);
|
|
80
|
+
} else {
|
|
81
|
+
markAll(newVal[k], cp, "added", map);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
map.set(path, JSON.stringify(oldVal) === JSON.stringify(newVal) ? "equal" : "changed");
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function markAll(val, path, type, map) {
|
|
89
|
+
map.set(path, type);
|
|
90
|
+
if (val !== null && typeof val === "object") {
|
|
91
|
+
const isArr = Array.isArray(val);
|
|
92
|
+
for (const k of Object.keys(val)) {
|
|
93
|
+
markAll(val[k], isArr ? `${path}[${k}]` : `${path}.${k}`, type, map);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function formatVal(v) {
|
|
98
|
+
if (v === null) return "null";
|
|
99
|
+
if (v === void 0) return "";
|
|
100
|
+
if (typeof v === "string") return `"${v}"`;
|
|
101
|
+
return String(v);
|
|
102
|
+
}
|
|
103
|
+
function formatBracket(val) {
|
|
104
|
+
return Array.isArray(val) ? `[${Object.keys(val).length}]` : `{${Object.keys(val).length}}`;
|
|
105
|
+
}
|
|
106
|
+
function getDiffType(path) {
|
|
107
|
+
return diffMap.value.get(path) ?? "equal";
|
|
108
|
+
}
|
|
109
|
+
function hasChildDiff(path) {
|
|
110
|
+
const prefix = path ? path + "." : "";
|
|
111
|
+
const prefixArr = path ? path + "[" : "";
|
|
112
|
+
for (const [k, v] of diffMap.value) {
|
|
113
|
+
if (v !== "equal" && (k.startsWith(prefix) || k.startsWith(prefixArr))) return true;
|
|
114
|
+
}
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
function rowDiffType(row) {
|
|
118
|
+
const dt = getDiffType(row.path);
|
|
119
|
+
if (dt !== "equal") return dt;
|
|
120
|
+
if (!row.isLeaf && hasChildDiff(row.path)) return "container-diff";
|
|
121
|
+
return "equal";
|
|
122
|
+
}
|
|
123
|
+
function updateLines() {
|
|
124
|
+
if (!wrapperRef.value || !leftPanelRef.value || !rightPanelRef.value) return;
|
|
125
|
+
const wRect = wrapperRef.value.getBoundingClientRect();
|
|
126
|
+
const result = [];
|
|
127
|
+
for (const [path, type] of diffMap.value) {
|
|
128
|
+
if (type !== "changed") continue;
|
|
129
|
+
const leftEl = leftPanelRef.value.querySelector(`[data-path="${CSS.escape(path)}"]`);
|
|
130
|
+
const rightEl = rightPanelRef.value.querySelector(`[data-path="${CSS.escape(path)}"]`);
|
|
131
|
+
if (!leftEl || !rightEl) continue;
|
|
132
|
+
const lRect = leftEl.getBoundingClientRect();
|
|
133
|
+
const rRect = rightEl.getBoundingClientRect();
|
|
134
|
+
result.push({
|
|
135
|
+
path,
|
|
136
|
+
type,
|
|
137
|
+
x1: lRect.right - wRect.left,
|
|
138
|
+
y1: lRect.top + lRect.height / 2 - wRect.top,
|
|
139
|
+
x2: rRect.left - wRect.left,
|
|
140
|
+
y2: rRect.top + rRect.height / 2 - wRect.top
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
lines.value = result;
|
|
144
|
+
}
|
|
145
|
+
function handleCompare() {
|
|
146
|
+
errorMsg.value = "";
|
|
147
|
+
let oldObj, newObj;
|
|
148
|
+
try {
|
|
149
|
+
oldObj = JSON.parse(oldJson.value);
|
|
150
|
+
} catch {
|
|
151
|
+
errorMsg.value = "A(原始JSON)解析失败";
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
newObj = JSON.parse(newJson.value);
|
|
156
|
+
} catch {
|
|
157
|
+
errorMsg.value = "B(新JSON)解析失败";
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const lRows = [], rRows = [];
|
|
161
|
+
flatten(oldObj, "", "root", 0, false, lRows);
|
|
162
|
+
flatten(newObj, "", "root", 0, false, rRows);
|
|
163
|
+
leftRows.value = lRows;
|
|
164
|
+
rightRows.value = rRows;
|
|
165
|
+
const map = /* @__PURE__ */ new Map();
|
|
166
|
+
collectDiff(oldObj, newObj, "", map);
|
|
167
|
+
diffMap.value = map;
|
|
168
|
+
hasCompared.value = true;
|
|
169
|
+
nextTick(() => {
|
|
170
|
+
var _a, _b;
|
|
171
|
+
updateLines();
|
|
172
|
+
(_a = leftPanelRef.value) == null ? void 0 : _a.addEventListener("scroll", updateLines);
|
|
173
|
+
(_b = rightPanelRef.value) == null ? void 0 : _b.addEventListener("scroll", updateLines);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
function handleClear() {
|
|
177
|
+
oldJson.value = "";
|
|
178
|
+
newJson.value = "";
|
|
179
|
+
leftRows.value = [];
|
|
180
|
+
rightRows.value = [];
|
|
181
|
+
diffMap.value = /* @__PURE__ */ new Map();
|
|
182
|
+
lines.value = [];
|
|
183
|
+
hasCompared.value = false;
|
|
184
|
+
errorMsg.value = "";
|
|
185
|
+
}
|
|
186
|
+
function handleEdit() {
|
|
187
|
+
cleanup();
|
|
188
|
+
hasCompared.value = false;
|
|
189
|
+
leftRows.value = [];
|
|
190
|
+
rightRows.value = [];
|
|
191
|
+
diffMap.value = /* @__PURE__ */ new Map();
|
|
192
|
+
lines.value = [];
|
|
193
|
+
}
|
|
194
|
+
function handleSwap() {
|
|
195
|
+
const tmp = oldJson.value;
|
|
196
|
+
oldJson.value = newJson.value;
|
|
197
|
+
newJson.value = tmp;
|
|
198
|
+
if (hasCompared.value) handleCompare();
|
|
199
|
+
}
|
|
200
|
+
function handlePaste(target) {
|
|
201
|
+
navigator.clipboard.readText().then((t) => {
|
|
202
|
+
if (target === "old") oldJson.value = t;
|
|
203
|
+
else newJson.value = t;
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
function loadSample() {
|
|
207
|
+
oldJson.value = JSON.stringify({
|
|
208
|
+
name: "UsefulTools",
|
|
209
|
+
version: "1.0.0",
|
|
210
|
+
description: "工具集合",
|
|
211
|
+
features: ["JSON格式化", "代码高亮"],
|
|
212
|
+
config: { theme: "dark", lang: "zh-CN", autoSave: true },
|
|
213
|
+
author: { name: "开发者", email: "dev@example.com" },
|
|
214
|
+
count: 1024,
|
|
215
|
+
active: true
|
|
216
|
+
}, null, 2);
|
|
217
|
+
newJson.value = JSON.stringify({
|
|
218
|
+
name: "UsefulTools",
|
|
219
|
+
version: "2.0.0",
|
|
220
|
+
description: "实用工具集合",
|
|
221
|
+
features: ["JSON格式化", "代码高亮", "文本对比"],
|
|
222
|
+
config: { theme: "light", lang: "zh-CN", fontSize: 14 },
|
|
223
|
+
author: { name: "开发者", url: "https://example.com" },
|
|
224
|
+
count: 2048,
|
|
225
|
+
active: true,
|
|
226
|
+
tags: ["tool", "dev"]
|
|
227
|
+
}, null, 2);
|
|
228
|
+
handleCompare();
|
|
229
|
+
}
|
|
230
|
+
const stats = computed(() => {
|
|
231
|
+
let added = 0, removed = 0, changed = 0;
|
|
232
|
+
for (const [, v] of diffMap.value) {
|
|
233
|
+
if (v === "added") added++;
|
|
234
|
+
else if (v === "removed") removed++;
|
|
235
|
+
else if (v === "changed") changed++;
|
|
236
|
+
}
|
|
237
|
+
return { added, removed, changed };
|
|
238
|
+
});
|
|
239
|
+
function cleanup() {
|
|
240
|
+
var _a, _b;
|
|
241
|
+
(_a = leftPanelRef.value) == null ? void 0 : _a.removeEventListener("scroll", updateLines);
|
|
242
|
+
(_b = rightPanelRef.value) == null ? void 0 : _b.removeEventListener("scroll", updateLines);
|
|
243
|
+
}
|
|
244
|
+
onBeforeUnmount(cleanup);
|
|
245
|
+
function rowBgClass(row) {
|
|
246
|
+
const dt = rowDiffType(row);
|
|
247
|
+
if (dt === "added") return "bg-neon-green/12";
|
|
248
|
+
if (dt === "removed") return "bg-coral-red/12";
|
|
249
|
+
if (dt === "changed") return "bg-primary/10";
|
|
250
|
+
if (dt === "container-diff") return "bg-white/[0.02]";
|
|
251
|
+
return "";
|
|
252
|
+
}
|
|
253
|
+
function rowTextClass(row) {
|
|
254
|
+
const dt = rowDiffType(row);
|
|
255
|
+
if (dt === "added") return "text-neon-green";
|
|
256
|
+
if (dt === "removed") return "text-coral-red";
|
|
257
|
+
if (dt === "changed") return "text-primary";
|
|
258
|
+
return "text-gray-400";
|
|
259
|
+
}
|
|
260
|
+
function lineColor(type) {
|
|
261
|
+
if (type === "changed") return "#EAB308";
|
|
262
|
+
if (type === "added") return "#39FF14";
|
|
263
|
+
if (type === "removed") return "#FF6B6B";
|
|
264
|
+
return "#666";
|
|
265
|
+
}
|
|
266
|
+
function diffIcon(row) {
|
|
267
|
+
const dt = rowDiffType(row);
|
|
268
|
+
if (dt === "added") return "add_circle";
|
|
269
|
+
if (dt === "removed") return "remove_circle";
|
|
270
|
+
if (dt === "changed") return "change_circle";
|
|
271
|
+
return "";
|
|
272
|
+
}
|
|
273
|
+
function diffIconClass(row) {
|
|
274
|
+
const dt = rowDiffType(row);
|
|
275
|
+
if (dt === "added") return "text-neon-green/70";
|
|
276
|
+
if (dt === "removed") return "text-coral-red/70";
|
|
277
|
+
if (dt === "changed") return "text-primary/70";
|
|
278
|
+
return "";
|
|
279
|
+
}
|
|
280
|
+
return (_ctx, _cache) => {
|
|
281
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
282
|
+
createCommentVNode(" Toolbar "),
|
|
283
|
+
createElementVNode("div", _hoisted_2, [
|
|
284
|
+
!hasCompared.value ? (openBlock(), createElementBlock("button", {
|
|
285
|
+
key: 0,
|
|
286
|
+
class: "h-9 px-4 bg-primary text-black font-bold border-2 border-black rounded shadow-hard-sm hover:shadow-none hover:translate-x-0.5 hover:translate-y-0.5 transition-all flex items-center gap-1.5 text-sm",
|
|
287
|
+
onClick: handleCompare
|
|
288
|
+
}, [..._cache[4] || (_cache[4] = [
|
|
289
|
+
createElementVNode(
|
|
290
|
+
"span",
|
|
291
|
+
{ class: "material-icons text-lg" },
|
|
292
|
+
"compare_arrows",
|
|
293
|
+
-1
|
|
294
|
+
/* CACHED */
|
|
295
|
+
),
|
|
296
|
+
createTextVNode(
|
|
297
|
+
"对比 ",
|
|
298
|
+
-1
|
|
299
|
+
/* CACHED */
|
|
300
|
+
)
|
|
301
|
+
])])) : createCommentVNode("v-if", true),
|
|
302
|
+
hasCompared.value ? (openBlock(), createElementBlock("button", {
|
|
303
|
+
key: 1,
|
|
304
|
+
class: "h-9 px-4 bg-primary text-black font-bold border-2 border-black rounded shadow-hard-sm hover:shadow-none hover:translate-x-0.5 hover:translate-y-0.5 transition-all flex items-center gap-1.5 text-sm",
|
|
305
|
+
onClick: handleEdit
|
|
306
|
+
}, [..._cache[5] || (_cache[5] = [
|
|
307
|
+
createElementVNode(
|
|
308
|
+
"span",
|
|
309
|
+
{ class: "material-icons text-lg" },
|
|
310
|
+
"edit",
|
|
311
|
+
-1
|
|
312
|
+
/* CACHED */
|
|
313
|
+
),
|
|
314
|
+
createTextVNode(
|
|
315
|
+
"编辑 ",
|
|
316
|
+
-1
|
|
317
|
+
/* CACHED */
|
|
318
|
+
)
|
|
319
|
+
])])) : createCommentVNode("v-if", true),
|
|
320
|
+
createElementVNode("button", {
|
|
321
|
+
class: "h-9 px-4 bg-white text-black font-bold border-2 border-black rounded shadow-hard-sm hover:shadow-none hover:translate-x-0.5 hover:translate-y-0.5 transition-all flex items-center gap-1.5 text-sm",
|
|
322
|
+
onClick: handleSwap
|
|
323
|
+
}, [..._cache[6] || (_cache[6] = [
|
|
324
|
+
createElementVNode(
|
|
325
|
+
"span",
|
|
326
|
+
{ class: "material-icons text-lg" },
|
|
327
|
+
"swap_horiz",
|
|
328
|
+
-1
|
|
329
|
+
/* CACHED */
|
|
330
|
+
),
|
|
331
|
+
createTextVNode(
|
|
332
|
+
"交换 ",
|
|
333
|
+
-1
|
|
334
|
+
/* CACHED */
|
|
335
|
+
)
|
|
336
|
+
])]),
|
|
337
|
+
createElementVNode("button", {
|
|
338
|
+
class: "h-9 px-4 bg-coral-red text-white font-bold border-2 border-black rounded shadow-hard-sm hover:shadow-none hover:translate-x-0.5 hover:translate-y-0.5 transition-all flex items-center gap-1.5 text-sm",
|
|
339
|
+
onClick: handleClear
|
|
340
|
+
}, [..._cache[7] || (_cache[7] = [
|
|
341
|
+
createElementVNode(
|
|
342
|
+
"span",
|
|
343
|
+
{ class: "material-icons text-lg" },
|
|
344
|
+
"delete_outline",
|
|
345
|
+
-1
|
|
346
|
+
/* CACHED */
|
|
347
|
+
),
|
|
348
|
+
createTextVNode(
|
|
349
|
+
"清空 ",
|
|
350
|
+
-1
|
|
351
|
+
/* CACHED */
|
|
352
|
+
)
|
|
353
|
+
])]),
|
|
354
|
+
createElementVNode("div", _hoisted_3, [
|
|
355
|
+
hasCompared.value ? (openBlock(), createElementBlock("div", _hoisted_4, [
|
|
356
|
+
createElementVNode(
|
|
357
|
+
"span",
|
|
358
|
+
_hoisted_5,
|
|
359
|
+
"+" + toDisplayString(stats.value.added),
|
|
360
|
+
1
|
|
361
|
+
/* TEXT */
|
|
362
|
+
),
|
|
363
|
+
createElementVNode(
|
|
364
|
+
"span",
|
|
365
|
+
_hoisted_6,
|
|
366
|
+
"~" + toDisplayString(stats.value.changed),
|
|
367
|
+
1
|
|
368
|
+
/* TEXT */
|
|
369
|
+
),
|
|
370
|
+
createElementVNode(
|
|
371
|
+
"span",
|
|
372
|
+
_hoisted_7,
|
|
373
|
+
"-" + toDisplayString(stats.value.removed),
|
|
374
|
+
1
|
|
375
|
+
/* TEXT */
|
|
376
|
+
)
|
|
377
|
+
])) : createCommentVNode("v-if", true),
|
|
378
|
+
createElementVNode("button", {
|
|
379
|
+
class: "h-9 px-3 bg-deep-charcoal text-gray-300 font-bold border-2 border-white/20 rounded hover:border-primary hover:text-primary transition-all text-sm flex items-center gap-1.5",
|
|
380
|
+
onClick: loadSample
|
|
381
|
+
}, [..._cache[8] || (_cache[8] = [
|
|
382
|
+
createElementVNode(
|
|
383
|
+
"span",
|
|
384
|
+
{ class: "material-icons text-lg" },
|
|
385
|
+
"science",
|
|
386
|
+
-1
|
|
387
|
+
/* CACHED */
|
|
388
|
+
),
|
|
389
|
+
createTextVNode(
|
|
390
|
+
"示例 ",
|
|
391
|
+
-1
|
|
392
|
+
/* CACHED */
|
|
393
|
+
)
|
|
394
|
+
])])
|
|
395
|
+
])
|
|
396
|
+
]),
|
|
397
|
+
createCommentVNode(" Error "),
|
|
398
|
+
errorMsg.value ? (openBlock(), createElementBlock("div", _hoisted_8, [
|
|
399
|
+
_cache[9] || (_cache[9] = createElementVNode(
|
|
400
|
+
"span",
|
|
401
|
+
{ class: "material-icons text-lg" },
|
|
402
|
+
"error_outline",
|
|
403
|
+
-1
|
|
404
|
+
/* CACHED */
|
|
405
|
+
)),
|
|
406
|
+
createTextVNode(
|
|
407
|
+
toDisplayString(errorMsg.value),
|
|
408
|
+
1
|
|
409
|
+
/* TEXT */
|
|
410
|
+
)
|
|
411
|
+
])) : createCommentVNode("v-if", true),
|
|
412
|
+
createCommentVNode(" 编辑模式 "),
|
|
413
|
+
!hasCompared.value ? (openBlock(), createElementBlock("div", _hoisted_9, [
|
|
414
|
+
createElementVNode("div", _hoisted_10, [
|
|
415
|
+
createElementVNode("div", _hoisted_11, [
|
|
416
|
+
_cache[11] || (_cache[11] = createElementVNode(
|
|
417
|
+
"span",
|
|
418
|
+
{ class: "text-sm font-bold text-gray-400 tracking-wider" },
|
|
419
|
+
"A 原始JSON",
|
|
420
|
+
-1
|
|
421
|
+
/* CACHED */
|
|
422
|
+
)),
|
|
423
|
+
createElementVNode("button", {
|
|
424
|
+
class: "ml-auto text-xs text-gray-500 hover:text-primary transition-colors flex items-center gap-1",
|
|
425
|
+
onClick: _cache[0] || (_cache[0] = ($event) => handlePaste("old"))
|
|
426
|
+
}, [..._cache[10] || (_cache[10] = [
|
|
427
|
+
createElementVNode(
|
|
428
|
+
"span",
|
|
429
|
+
{ class: "material-icons text-sm" },
|
|
430
|
+
"content_paste",
|
|
431
|
+
-1
|
|
432
|
+
/* CACHED */
|
|
433
|
+
),
|
|
434
|
+
createTextVNode(
|
|
435
|
+
"粘贴 ",
|
|
436
|
+
-1
|
|
437
|
+
/* CACHED */
|
|
438
|
+
)
|
|
439
|
+
])])
|
|
440
|
+
]),
|
|
441
|
+
withDirectives(createElementVNode(
|
|
442
|
+
"textarea",
|
|
443
|
+
{
|
|
444
|
+
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => oldJson.value = $event),
|
|
445
|
+
placeholder: "在此粘贴原始 JSON...",
|
|
446
|
+
spellcheck: "false",
|
|
447
|
+
class: "flex-1 w-full bg-deep-charcoal text-gray-100 border-4 border-black rounded-xl p-4 font-mono text-sm leading-relaxed resize-none shadow-hard focus:border-primary focus:shadow-none focus:translate-x-1 focus:translate-y-1 transition-all outline-none placeholder-gray-600"
|
|
448
|
+
},
|
|
449
|
+
null,
|
|
450
|
+
512
|
|
451
|
+
/* NEED_PATCH */
|
|
452
|
+
), [
|
|
453
|
+
[vModelText, oldJson.value]
|
|
454
|
+
])
|
|
455
|
+
]),
|
|
456
|
+
createElementVNode("div", _hoisted_12, [
|
|
457
|
+
createElementVNode("div", _hoisted_13, [
|
|
458
|
+
_cache[13] || (_cache[13] = createElementVNode(
|
|
459
|
+
"span",
|
|
460
|
+
{ class: "text-sm font-bold text-gray-400 tracking-wider" },
|
|
461
|
+
"B 新JSON",
|
|
462
|
+
-1
|
|
463
|
+
/* CACHED */
|
|
464
|
+
)),
|
|
465
|
+
createElementVNode("button", {
|
|
466
|
+
class: "ml-auto text-xs text-gray-500 hover:text-primary transition-colors flex items-center gap-1",
|
|
467
|
+
onClick: _cache[2] || (_cache[2] = ($event) => handlePaste("new"))
|
|
468
|
+
}, [..._cache[12] || (_cache[12] = [
|
|
469
|
+
createElementVNode(
|
|
470
|
+
"span",
|
|
471
|
+
{ class: "material-icons text-sm" },
|
|
472
|
+
"content_paste",
|
|
473
|
+
-1
|
|
474
|
+
/* CACHED */
|
|
475
|
+
),
|
|
476
|
+
createTextVNode(
|
|
477
|
+
"粘贴 ",
|
|
478
|
+
-1
|
|
479
|
+
/* CACHED */
|
|
480
|
+
)
|
|
481
|
+
])])
|
|
482
|
+
]),
|
|
483
|
+
withDirectives(createElementVNode(
|
|
484
|
+
"textarea",
|
|
485
|
+
{
|
|
486
|
+
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => newJson.value = $event),
|
|
487
|
+
placeholder: "在此粘贴新 JSON...",
|
|
488
|
+
spellcheck: "false",
|
|
489
|
+
class: "flex-1 w-full bg-deep-charcoal text-gray-100 border-4 border-black rounded-xl p-4 font-mono text-sm leading-relaxed resize-none shadow-hard focus:border-primary focus:shadow-none focus:translate-x-1 focus:translate-y-1 transition-all outline-none placeholder-gray-600"
|
|
490
|
+
},
|
|
491
|
+
null,
|
|
492
|
+
512
|
|
493
|
+
/* NEED_PATCH */
|
|
494
|
+
), [
|
|
495
|
+
[vModelText, newJson.value]
|
|
496
|
+
])
|
|
497
|
+
])
|
|
498
|
+
])) : createCommentVNode("v-if", true),
|
|
499
|
+
createCommentVNode(" 对比结果:左右 JSON 树 + 连线 "),
|
|
500
|
+
hasCompared.value ? (openBlock(), createElementBlock(
|
|
501
|
+
"div",
|
|
502
|
+
{
|
|
503
|
+
key: 2,
|
|
504
|
+
ref_key: "wrapperRef",
|
|
505
|
+
ref: wrapperRef,
|
|
506
|
+
class: "flex-1 relative grid grid-cols-[1fr_60px_1fr] min-h-0"
|
|
507
|
+
},
|
|
508
|
+
[
|
|
509
|
+
createCommentVNode(" SVG 连线层(覆盖整个 wrapper) "),
|
|
510
|
+
(openBlock(), createElementBlock("svg", _hoisted_14, [
|
|
511
|
+
(openBlock(true), createElementBlock(
|
|
512
|
+
Fragment,
|
|
513
|
+
null,
|
|
514
|
+
renderList(lines.value, (l, idx) => {
|
|
515
|
+
return openBlock(), createElementBlock("path", {
|
|
516
|
+
key: idx,
|
|
517
|
+
d: `M ${l.x1} ${l.y1} C ${l.x1 + 25} ${l.y1}, ${l.x2 - 25} ${l.y2}, ${l.x2} ${l.y2}`,
|
|
518
|
+
stroke: lineColor(l.type),
|
|
519
|
+
"stroke-width": "2",
|
|
520
|
+
fill: "none",
|
|
521
|
+
opacity: "0.7"
|
|
522
|
+
}, null, 8, _hoisted_15);
|
|
523
|
+
}),
|
|
524
|
+
128
|
|
525
|
+
/* KEYED_FRAGMENT */
|
|
526
|
+
))
|
|
527
|
+
])),
|
|
528
|
+
createCommentVNode(" 左树 "),
|
|
529
|
+
createElementVNode(
|
|
530
|
+
"div",
|
|
531
|
+
{
|
|
532
|
+
ref_key: "leftPanelRef",
|
|
533
|
+
ref: leftPanelRef,
|
|
534
|
+
class: "bg-deep-charcoal border-4 border-black rounded-xl overflow-auto shadow-hard"
|
|
535
|
+
},
|
|
536
|
+
[
|
|
537
|
+
createElementVNode("div", _hoisted_16, [
|
|
538
|
+
(openBlock(true), createElementBlock(
|
|
539
|
+
Fragment,
|
|
540
|
+
null,
|
|
541
|
+
renderList(leftRows.value, (row, idx) => {
|
|
542
|
+
return openBlock(), createElementBlock("div", {
|
|
543
|
+
key: idx,
|
|
544
|
+
"data-path": row.path,
|
|
545
|
+
class: normalizeClass(["flex items-baseline py-0.5 px-2 rounded -mx-1", rowBgClass(row)]),
|
|
546
|
+
style: normalizeStyle({ paddingLeft: row.depth * 16 + 8 + "px" })
|
|
547
|
+
}, [
|
|
548
|
+
createElementVNode(
|
|
549
|
+
"span",
|
|
550
|
+
{
|
|
551
|
+
class: normalizeClass(["shrink-0 mr-1", rowTextClass(row)])
|
|
552
|
+
},
|
|
553
|
+
toDisplayString(row.parentIsArr ? `[${row.key}]` : row.key),
|
|
554
|
+
3
|
|
555
|
+
/* TEXT, CLASS */
|
|
556
|
+
),
|
|
557
|
+
row.isLeaf ? (openBlock(), createElementBlock(
|
|
558
|
+
Fragment,
|
|
559
|
+
{ key: 0 },
|
|
560
|
+
[
|
|
561
|
+
_cache[14] || (_cache[14] = createElementVNode(
|
|
562
|
+
"span",
|
|
563
|
+
{ class: "text-gray-600 mx-0.5" },
|
|
564
|
+
":",
|
|
565
|
+
-1
|
|
566
|
+
/* CACHED */
|
|
567
|
+
)),
|
|
568
|
+
createElementVNode(
|
|
569
|
+
"span",
|
|
570
|
+
{
|
|
571
|
+
class: normalizeClass(rowTextClass(row))
|
|
572
|
+
},
|
|
573
|
+
toDisplayString(formatVal(row.val)),
|
|
574
|
+
3
|
|
575
|
+
/* TEXT, CLASS */
|
|
576
|
+
)
|
|
577
|
+
],
|
|
578
|
+
64
|
|
579
|
+
/* STABLE_FRAGMENT */
|
|
580
|
+
)) : (openBlock(), createElementBlock(
|
|
581
|
+
"span",
|
|
582
|
+
_hoisted_18,
|
|
583
|
+
toDisplayString(formatBracket(row.val)),
|
|
584
|
+
1
|
|
585
|
+
/* TEXT */
|
|
586
|
+
)),
|
|
587
|
+
diffIcon(row) ? (openBlock(), createElementBlock(
|
|
588
|
+
"span",
|
|
589
|
+
{
|
|
590
|
+
key: 2,
|
|
591
|
+
class: normalizeClass(["material-icons ml-auto shrink-0 text-sm leading-none", diffIconClass(row)])
|
|
592
|
+
},
|
|
593
|
+
toDisplayString(diffIcon(row)),
|
|
594
|
+
3
|
|
595
|
+
/* TEXT, CLASS */
|
|
596
|
+
)) : createCommentVNode("v-if", true)
|
|
597
|
+
], 14, _hoisted_17);
|
|
598
|
+
}),
|
|
599
|
+
128
|
|
600
|
+
/* KEYED_FRAGMENT */
|
|
601
|
+
))
|
|
602
|
+
])
|
|
603
|
+
],
|
|
604
|
+
512
|
|
605
|
+
/* NEED_PATCH */
|
|
606
|
+
),
|
|
607
|
+
createCommentVNode(" 中间间距 "),
|
|
608
|
+
_cache[16] || (_cache[16] = createElementVNode(
|
|
609
|
+
"div",
|
|
610
|
+
null,
|
|
611
|
+
null,
|
|
612
|
+
-1
|
|
613
|
+
/* CACHED */
|
|
614
|
+
)),
|
|
615
|
+
createCommentVNode(" 右树 "),
|
|
616
|
+
createElementVNode(
|
|
617
|
+
"div",
|
|
618
|
+
{
|
|
619
|
+
ref_key: "rightPanelRef",
|
|
620
|
+
ref: rightPanelRef,
|
|
621
|
+
class: "bg-deep-charcoal border-4 border-black rounded-xl overflow-auto shadow-hard"
|
|
622
|
+
},
|
|
623
|
+
[
|
|
624
|
+
createElementVNode("div", _hoisted_19, [
|
|
625
|
+
(openBlock(true), createElementBlock(
|
|
626
|
+
Fragment,
|
|
627
|
+
null,
|
|
628
|
+
renderList(rightRows.value, (row, idx) => {
|
|
629
|
+
return openBlock(), createElementBlock("div", {
|
|
630
|
+
key: idx,
|
|
631
|
+
"data-path": row.path,
|
|
632
|
+
class: normalizeClass(["flex items-baseline py-0.5 px-2 rounded -mx-1", rowBgClass(row)]),
|
|
633
|
+
style: normalizeStyle({ paddingLeft: row.depth * 16 + 8 + "px" })
|
|
634
|
+
}, [
|
|
635
|
+
createElementVNode(
|
|
636
|
+
"span",
|
|
637
|
+
{
|
|
638
|
+
class: normalizeClass(["shrink-0 mr-1", rowTextClass(row)])
|
|
639
|
+
},
|
|
640
|
+
toDisplayString(row.parentIsArr ? `[${row.key}]` : row.key),
|
|
641
|
+
3
|
|
642
|
+
/* TEXT, CLASS */
|
|
643
|
+
),
|
|
644
|
+
row.isLeaf ? (openBlock(), createElementBlock(
|
|
645
|
+
Fragment,
|
|
646
|
+
{ key: 0 },
|
|
647
|
+
[
|
|
648
|
+
_cache[15] || (_cache[15] = createElementVNode(
|
|
649
|
+
"span",
|
|
650
|
+
{ class: "text-gray-600 mx-0.5" },
|
|
651
|
+
":",
|
|
652
|
+
-1
|
|
653
|
+
/* CACHED */
|
|
654
|
+
)),
|
|
655
|
+
createElementVNode(
|
|
656
|
+
"span",
|
|
657
|
+
{
|
|
658
|
+
class: normalizeClass(rowTextClass(row))
|
|
659
|
+
},
|
|
660
|
+
toDisplayString(formatVal(row.val)),
|
|
661
|
+
3
|
|
662
|
+
/* TEXT, CLASS */
|
|
663
|
+
)
|
|
664
|
+
],
|
|
665
|
+
64
|
|
666
|
+
/* STABLE_FRAGMENT */
|
|
667
|
+
)) : (openBlock(), createElementBlock(
|
|
668
|
+
"span",
|
|
669
|
+
_hoisted_21,
|
|
670
|
+
toDisplayString(formatBracket(row.val)),
|
|
671
|
+
1
|
|
672
|
+
/* TEXT */
|
|
673
|
+
)),
|
|
674
|
+
diffIcon(row) ? (openBlock(), createElementBlock(
|
|
675
|
+
"span",
|
|
676
|
+
{
|
|
677
|
+
key: 2,
|
|
678
|
+
class: normalizeClass(["material-icons ml-auto shrink-0 text-sm leading-none", diffIconClass(row)])
|
|
679
|
+
},
|
|
680
|
+
toDisplayString(diffIcon(row)),
|
|
681
|
+
3
|
|
682
|
+
/* TEXT, CLASS */
|
|
683
|
+
)) : createCommentVNode("v-if", true)
|
|
684
|
+
], 14, _hoisted_20);
|
|
685
|
+
}),
|
|
686
|
+
128
|
|
687
|
+
/* KEYED_FRAGMENT */
|
|
688
|
+
))
|
|
689
|
+
])
|
|
690
|
+
],
|
|
691
|
+
512
|
|
692
|
+
/* NEED_PATCH */
|
|
693
|
+
)
|
|
694
|
+
],
|
|
695
|
+
512
|
|
696
|
+
/* NEED_PATCH */
|
|
697
|
+
)) : createCommentVNode("v-if", true)
|
|
698
|
+
]);
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
export {
|
|
703
|
+
_sfc_main as default
|
|
704
|
+
};
|