@cnc_cbz/usefultools-plugin-official 1.0.5 → 1.0.7

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.
@@ -28,27 +28,32 @@ const _hoisted_14 = {
28
28
  };
29
29
  const _hoisted_15 = { class: "flex-1 grid grid-cols-1 lg:grid-cols-2 gap-4 min-h-0" };
30
30
  const _hoisted_16 = { class: "flex flex-col min-h-0" };
31
- const _hoisted_17 = { class: "flex flex-col min-h-0" };
32
- const _hoisted_18 = { class: "flex items-center gap-2 mb-2" };
33
- const _hoisted_19 = { class: "material-icons text-sm" };
34
- const _hoisted_20 = { class: "flex-1 w-full bg-deep-charcoal border-4 border-black rounded-xl p-4 overflow-auto shadow-hard min-h-[200px] text-sm leading-relaxed flex flex-col" };
35
- const _hoisted_21 = {
31
+ const _hoisted_17 = ["placeholder"];
32
+ const _hoisted_18 = { class: "flex flex-col min-h-0" };
33
+ const _hoisted_19 = { class: "flex items-center gap-2 mb-2" };
34
+ const _hoisted_20 = { class: "material-icons text-sm" };
35
+ const _hoisted_21 = { class: "flex-1 w-full bg-deep-charcoal border-4 border-black rounded-xl p-4 overflow-auto shadow-hard min-h-[200px] text-sm leading-relaxed flex flex-col" };
36
+ const _hoisted_22 = {
36
37
  key: 0,
37
- class: "text-gray-600"
38
+ class: "text-gray-400 flex items-center gap-2"
38
39
  };
39
- const _hoisted_22 = {
40
+ const _hoisted_23 = {
40
41
  key: 1,
42
+ class: "text-gray-600"
43
+ };
44
+ const _hoisted_24 = {
45
+ key: 2,
41
46
  class: "text-gray-100 whitespace-pre-wrap"
42
47
  };
43
- const _hoisted_23 = {
48
+ const _hoisted_25 = {
44
49
  key: 0,
45
50
  class: "fixed inset-0 z-50 flex items-center justify-center"
46
51
  };
47
- const _hoisted_24 = { class: "relative w-full max-w-lg bg-deep-charcoal border-4 border-black rounded-xl shadow-hard-xl p-6 flex flex-col gap-4" };
48
- const _hoisted_25 = { class: "flex items-center gap-2" };
49
- const _hoisted_26 = { class: "flex flex-col gap-1.5" };
50
- const _hoisted_27 = { class: "flex flex-col gap-1.5" };
51
- const _hoisted_28 = { class: "flex justify-end gap-3 mt-1" };
52
+ const _hoisted_26 = { class: "relative w-full max-w-lg bg-deep-charcoal border-4 border-black rounded-xl shadow-hard-xl p-6 flex flex-col gap-4" };
53
+ const _hoisted_27 = { class: "flex items-center gap-2" };
54
+ const _hoisted_28 = { class: "flex flex-col gap-1.5" };
55
+ const _hoisted_29 = { class: "flex flex-col gap-1.5" };
56
+ const _hoisted_30 = { class: "flex justify-end gap-3 mt-1" };
52
57
  const GOOGLE_KEY = "translator-google-api-key";
53
58
  const AI_KEY = "translator-ai-api-key";
54
59
  const AI_MODEL_KEY = "translator-ai-model";
@@ -250,6 +255,48 @@ ${sourceText.value}`;
250
255
  copySuccess.value = false;
251
256
  }, 1500);
252
257
  }
258
+ function detectAndSwitchTarget(text) {
259
+ if (sourceLang.value !== "auto") return;
260
+ const stripped = text.replace(/\s+/g, "");
261
+ if (!stripped) return;
262
+ const cjkCount = (stripped.match(/[\u4e00-\u9fff]/g) || []).length;
263
+ const ratio = cjkCount / stripped.length;
264
+ const newTarget = ratio > 0.3 ? "en" : "zh-CN";
265
+ if (targetLang.value !== newTarget) targetLang.value = newTarget;
266
+ }
267
+ let googleDebounceTimer = null;
268
+ function triggerGoogleAuto() {
269
+ if (engine.value !== "google") return;
270
+ if (googleDebounceTimer) clearTimeout(googleDebounceTimer);
271
+ if (!sourceText.value.trim()) {
272
+ translatedText.value = "";
273
+ loading.value = false;
274
+ return;
275
+ }
276
+ loading.value = true;
277
+ translatedText.value = "";
278
+ errorMsg.value = "";
279
+ googleDebounceTimer = setTimeout(async () => {
280
+ try {
281
+ await translateGoogle();
282
+ } catch (e) {
283
+ errorMsg.value = e.message || "翻译失败";
284
+ } finally {
285
+ loading.value = false;
286
+ }
287
+ }, 500);
288
+ }
289
+ watch(sourceText, (val) => {
290
+ detectAndSwitchTarget(val);
291
+ triggerGoogleAuto();
292
+ });
293
+ watch([sourceLang, targetLang], () => triggerGoogleAuto());
294
+ function onTextareaKeydown(e) {
295
+ if (engine.value === "ai" && e.key === "Enter" && !e.shiftKey) {
296
+ e.preventDefault();
297
+ translate();
298
+ }
299
+ }
253
300
  return (_ctx, _cache) => {
254
301
  return openBlock(), createElementBlock("div", _hoisted_1, [
255
302
  createCommentVNode(" Toolbar "),
@@ -486,24 +533,19 @@ ${sourceText.value}`;
486
533
  -1
487
534
  /* CACHED */
488
535
  )),
489
- withDirectives(createElementVNode(
490
- "textarea",
491
- {
492
- "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => sourceText.value = $event),
493
- spellcheck: "false",
494
- placeholder: "在此输入要翻译的文本...",
495
- 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-[4px] focus:translate-y-[4px] transition-all outline-none placeholder-gray-600 min-h-[200px]"
496
- },
497
- null,
498
- 512
499
- /* NEED_PATCH */
500
- ), [
536
+ withDirectives(createElementVNode("textarea", {
537
+ "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => sourceText.value = $event),
538
+ spellcheck: "false",
539
+ placeholder: engine.value === "google" ? "输入文本自动翻译..." : "在此输入要翻译的文本...\nEnter 翻译 / Shift+Enter 换行",
540
+ 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-[4px] focus:translate-y-[4px] transition-all outline-none placeholder-gray-600 min-h-[200px]",
541
+ onKeydown: onTextareaKeydown
542
+ }, null, 40, _hoisted_17), [
501
543
  [vModelText, sourceText.value]
502
544
  ])
503
545
  ]),
504
546
  createCommentVNode(" 翻译结果 "),
505
- createElementVNode("div", _hoisted_17, [
506
- createElementVNode("div", _hoisted_18, [
547
+ createElementVNode("div", _hoisted_18, [
548
+ createElementVNode("div", _hoisted_19, [
507
549
  _cache[18] || (_cache[18] = createElementVNode(
508
550
  "span",
509
551
  { class: "material-icons text-neon-green text-lg" },
@@ -528,7 +570,7 @@ ${sourceText.value}`;
528
570
  [
529
571
  createElementVNode(
530
572
  "span",
531
- _hoisted_19,
573
+ _hoisted_20,
532
574
  toDisplayString(copySuccess.value ? "check_circle" : "content_copy"),
533
575
  1
534
576
  /* TEXT */
@@ -543,10 +585,23 @@ ${sourceText.value}`;
543
585
  /* CLASS */
544
586
  )) : createCommentVNode("v-if", true)
545
587
  ]),
546
- createElementVNode("div", _hoisted_20, [
547
- !translatedText.value ? (openBlock(), createElementBlock("div", _hoisted_21, " 翻译结果将显示在这里... ")) : (openBlock(), createElementBlock(
588
+ createElementVNode("div", _hoisted_21, [
589
+ loading.value && engine.value === "google" ? (openBlock(), createElementBlock("div", _hoisted_22, [..._cache[20] || (_cache[20] = [
590
+ createElementVNode(
591
+ "span",
592
+ { class: "material-icons text-primary text-base animate-spin" },
593
+ "hourglass_top",
594
+ -1
595
+ /* CACHED */
596
+ ),
597
+ createTextVNode(
598
+ " 翻译中... ",
599
+ -1
600
+ /* CACHED */
601
+ )
602
+ ])])) : !translatedText.value ? (openBlock(), createElementBlock("div", _hoisted_23, " 翻译结果将显示在这里... ")) : (openBlock(), createElementBlock(
548
603
  "div",
549
- _hoisted_22,
604
+ _hoisted_24,
550
605
  toDisplayString(translatedText.value),
551
606
  1
552
607
  /* TEXT */
@@ -556,21 +611,21 @@ ${sourceText.value}`;
556
611
  ]),
557
612
  createCommentVNode(" API Key 设置弹窗 "),
558
613
  (openBlock(), createBlock(Teleport, { to: "body" }, [
559
- showSettings.value ? (openBlock(), createElementBlock("div", _hoisted_23, [
614
+ showSettings.value ? (openBlock(), createElementBlock("div", _hoisted_25, [
560
615
  createElementVNode("div", {
561
616
  class: "absolute inset-0 bg-black/60",
562
617
  onClick: _cache[6] || (_cache[6] = ($event) => showSettings.value = false)
563
618
  }),
564
- createElementVNode("div", _hoisted_24, [
565
- createElementVNode("div", _hoisted_25, [
566
- _cache[21] || (_cache[21] = createElementVNode(
619
+ createElementVNode("div", _hoisted_26, [
620
+ createElementVNode("div", _hoisted_27, [
621
+ _cache[22] || (_cache[22] = createElementVNode(
567
622
  "span",
568
623
  { class: "material-icons text-primary text-xl" },
569
624
  "key",
570
625
  -1
571
626
  /* CACHED */
572
627
  )),
573
- _cache[22] || (_cache[22] = createElementVNode(
628
+ _cache[23] || (_cache[23] = createElementVNode(
574
629
  "span",
575
630
  { class: "text-lg font-bold text-white" },
576
631
  "配置 API Key",
@@ -580,7 +635,7 @@ ${sourceText.value}`;
580
635
  createElementVNode("button", {
581
636
  class: "ml-auto w-8 h-8 flex items-center justify-center text-gray-400 hover:text-white transition-colors",
582
637
  onClick: _cache[7] || (_cache[7] = ($event) => showSettings.value = false)
583
- }, [..._cache[20] || (_cache[20] = [
638
+ }, [..._cache[21] || (_cache[21] = [
584
639
  createElementVNode(
585
640
  "span",
586
641
  { class: "material-icons" },
@@ -591,8 +646,8 @@ ${sourceText.value}`;
591
646
  ])])
592
647
  ]),
593
648
  createCommentVNode(" Google API Key "),
594
- createElementVNode("div", _hoisted_26, [
595
- _cache[23] || (_cache[23] = createElementVNode(
649
+ createElementVNode("div", _hoisted_28, [
650
+ _cache[24] || (_cache[24] = createElementVNode(
596
651
  "label",
597
652
  { class: "text-xs font-bold text-gray-400 uppercase tracking-wider" },
598
653
  "Google Translation API Key",
@@ -615,8 +670,8 @@ ${sourceText.value}`;
615
670
  ])
616
671
  ]),
617
672
  createCommentVNode(" SiliconFlow API Key "),
618
- createElementVNode("div", _hoisted_27, [
619
- _cache[24] || (_cache[24] = createElementVNode(
673
+ createElementVNode("div", _hoisted_29, [
674
+ _cache[25] || (_cache[25] = createElementVNode(
620
675
  "label",
621
676
  { class: "text-xs font-bold text-gray-400 uppercase tracking-wider" },
622
677
  "SiliconFlow API Key(AI 翻译)",
@@ -637,7 +692,7 @@ ${sourceText.value}`;
637
692
  ), [
638
693
  [vModelText, aiKeyInput.value]
639
694
  ]),
640
- _cache[25] || (_cache[25] = createElementVNode(
695
+ _cache[26] || (_cache[26] = createElementVNode(
641
696
  "p",
642
697
  { class: "text-[11px] text-gray-600" },
643
698
  "密钥从 cloud.siliconflow.cn 获取,保存后可在工具栏选择模型",
@@ -645,7 +700,7 @@ ${sourceText.value}`;
645
700
  /* CACHED */
646
701
  ))
647
702
  ]),
648
- createElementVNode("div", _hoisted_28, [
703
+ createElementVNode("div", _hoisted_30, [
649
704
  createElementVNode("button", {
650
705
  class: "px-4 py-2 bg-white/10 text-gray-300 font-bold border-2 border-white/20 rounded hover:border-white hover:text-white transition-all text-sm",
651
706
  onClick: _cache[10] || (_cache[10] = ($event) => showSettings.value = false)
@@ -829,6 +884,10 @@ export {
829
884
  z-index: 50;
830
885
  }
831
886
 
887
+ .col-span-2 {
888
+ grid-column: span 2 / span 2;
889
+ }
890
+
832
891
  .-mx-1 {
833
892
  margin-inline: calc(var(--spacing) * -1);
834
893
  }
@@ -949,6 +1008,10 @@ export {
949
1008
  height: calc(var(--spacing) * 4);
950
1009
  }
951
1010
 
1011
+ .h-5 {
1012
+ height: calc(var(--spacing) * 5);
1013
+ }
1014
+
952
1015
  .h-7 {
953
1016
  height: calc(var(--spacing) * 7);
954
1017
  }
@@ -981,10 +1044,18 @@ export {
981
1044
  height: 100%;
982
1045
  }
983
1046
 
1047
+ .max-h-36 {
1048
+ max-height: calc(var(--spacing) * 36);
1049
+ }
1050
+
984
1051
  .max-h-40 {
985
1052
  max-height: calc(var(--spacing) * 40);
986
1053
  }
987
1054
 
1055
+ .max-h-48 {
1056
+ max-height: calc(var(--spacing) * 48);
1057
+ }
1058
+
988
1059
  .max-h-60 {
989
1060
  max-height: calc(var(--spacing) * 60);
990
1061
  }
@@ -1013,6 +1084,10 @@ export {
1013
1084
  min-height: 200px;
1014
1085
  }
1015
1086
 
1087
+ .w-1\\.5 {
1088
+ width: calc(var(--spacing) * 1.5);
1089
+ }
1090
+
1016
1091
  .w-2 {
1017
1092
  width: calc(var(--spacing) * 2);
1018
1093
  }
@@ -1093,6 +1168,10 @@ export {
1093
1168
  min-width: calc(var(--spacing) * 0);
1094
1169
  }
1095
1170
 
1171
+ .min-w-\\[90px\\] {
1172
+ min-width: 90px;
1173
+ }
1174
+
1096
1175
  .min-w-\\[200px\\] {
1097
1176
  min-width: 200px;
1098
1177
  }
@@ -1396,6 +1475,16 @@ export {
1396
1475
  border-color: var(--color-primary);
1397
1476
  }
1398
1477
 
1478
+ .border-primary\\/40 {
1479
+ border-color: #f9b11f66;
1480
+ }
1481
+
1482
+ @supports (color: color-mix(in lab, red, red)) {
1483
+ .border-primary\\/40 {
1484
+ border-color: color-mix(in oklab, var(--color-primary) 40%, transparent);
1485
+ }
1486
+ }
1487
+
1399
1488
  .border-transparent {
1400
1489
  border-color: #0000;
1401
1490
  }
@@ -1534,6 +1623,16 @@ export {
1534
1623
  }
1535
1624
  }
1536
1625
 
1626
+ .bg-neon-green\\/20 {
1627
+ background-color: #84cc1633;
1628
+ }
1629
+
1630
+ @supports (color: color-mix(in lab, red, red)) {
1631
+ .bg-neon-green\\/20 {
1632
+ background-color: color-mix(in oklab, var(--color-neon-green) 20%, transparent);
1633
+ }
1634
+ }
1635
+
1537
1636
  .bg-primary {
1538
1637
  background-color: var(--color-primary);
1539
1638
  }
@@ -1760,6 +1859,14 @@ export {
1760
1859
  padding-left: calc(var(--spacing) * 8);
1761
1860
  }
1762
1861
 
1862
+ .pl-\\[22px\\] {
1863
+ padding-left: 22px;
1864
+ }
1865
+
1866
+ .pl-\\[98px\\] {
1867
+ padding-left: 98px;
1868
+ }
1869
+
1763
1870
  .text-center {
1764
1871
  text-align: center;
1765
1872
  }
@@ -1772,6 +1879,10 @@ export {
1772
1879
  text-align: right;
1773
1880
  }
1774
1881
 
1882
+ .align-middle {
1883
+ vertical-align: middle;
1884
+ }
1885
+
1775
1886
  .font-mono {
1776
1887
  font-family: var(--font-mono);
1777
1888
  }
@@ -2258,6 +2369,10 @@ export {
2258
2369
  color: var(--color-coral-red);
2259
2370
  }
2260
2371
 
2372
+ .hover\\:text-gray-200:hover {
2373
+ color: var(--color-gray-200);
2374
+ }
2375
+
2261
2376
  .hover\\:text-gray-300:hover {
2262
2377
  color: var(--color-gray-300);
2263
2378
  }
@@ -2309,6 +2424,18 @@ export {
2309
2424
  translate: var(--tw-translate-x) var(--tw-translate-y);
2310
2425
  }
2311
2426
 
2427
+ .focus\\:border-electric-blue:focus {
2428
+ border-color: var(--color-electric-blue);
2429
+ }
2430
+
2431
+ .focus\\:border-gray-500:focus {
2432
+ border-color: var(--color-gray-500);
2433
+ }
2434
+
2435
+ .focus\\:border-neon-green:focus {
2436
+ border-color: var(--color-neon-green);
2437
+ }
2438
+
2312
2439
  .focus\\:border-primary:focus {
2313
2440
  border-color: var(--color-primary);
2314
2441
  }
@@ -2326,6 +2453,14 @@ export {
2326
2453
  cursor: grabbing;
2327
2454
  }
2328
2455
 
2456
+ .disabled\\:cursor-not-allowed:disabled {
2457
+ cursor: not-allowed;
2458
+ }
2459
+
2460
+ .disabled\\:opacity-40:disabled {
2461
+ opacity: .4;
2462
+ }
2463
+
2329
2464
  @media (min-width: 40rem) {
2330
2465
  .sm\\:grid-cols-2 {
2331
2466
  grid-template-columns: repeat(2, minmax(0, 1fr));
@@ -341,6 +341,10 @@ export {
341
341
  z-index: 50;
342
342
  }
343
343
 
344
+ .col-span-2 {
345
+ grid-column: span 2 / span 2;
346
+ }
347
+
344
348
  .-mx-1 {
345
349
  margin-inline: calc(var(--spacing) * -1);
346
350
  }
@@ -461,6 +465,10 @@ export {
461
465
  height: calc(var(--spacing) * 4);
462
466
  }
463
467
 
468
+ .h-5 {
469
+ height: calc(var(--spacing) * 5);
470
+ }
471
+
464
472
  .h-7 {
465
473
  height: calc(var(--spacing) * 7);
466
474
  }
@@ -493,10 +501,18 @@ export {
493
501
  height: 100%;
494
502
  }
495
503
 
504
+ .max-h-36 {
505
+ max-height: calc(var(--spacing) * 36);
506
+ }
507
+
496
508
  .max-h-40 {
497
509
  max-height: calc(var(--spacing) * 40);
498
510
  }
499
511
 
512
+ .max-h-48 {
513
+ max-height: calc(var(--spacing) * 48);
514
+ }
515
+
500
516
  .max-h-60 {
501
517
  max-height: calc(var(--spacing) * 60);
502
518
  }
@@ -525,6 +541,10 @@ export {
525
541
  min-height: 200px;
526
542
  }
527
543
 
544
+ .w-1\\.5 {
545
+ width: calc(var(--spacing) * 1.5);
546
+ }
547
+
528
548
  .w-2 {
529
549
  width: calc(var(--spacing) * 2);
530
550
  }
@@ -605,6 +625,10 @@ export {
605
625
  min-width: calc(var(--spacing) * 0);
606
626
  }
607
627
 
628
+ .min-w-\\[90px\\] {
629
+ min-width: 90px;
630
+ }
631
+
608
632
  .min-w-\\[200px\\] {
609
633
  min-width: 200px;
610
634
  }
@@ -908,6 +932,16 @@ export {
908
932
  border-color: var(--color-primary);
909
933
  }
910
934
 
935
+ .border-primary\\/40 {
936
+ border-color: #f9b11f66;
937
+ }
938
+
939
+ @supports (color: color-mix(in lab, red, red)) {
940
+ .border-primary\\/40 {
941
+ border-color: color-mix(in oklab, var(--color-primary) 40%, transparent);
942
+ }
943
+ }
944
+
911
945
  .border-transparent {
912
946
  border-color: #0000;
913
947
  }
@@ -1046,6 +1080,16 @@ export {
1046
1080
  }
1047
1081
  }
1048
1082
 
1083
+ .bg-neon-green\\/20 {
1084
+ background-color: #84cc1633;
1085
+ }
1086
+
1087
+ @supports (color: color-mix(in lab, red, red)) {
1088
+ .bg-neon-green\\/20 {
1089
+ background-color: color-mix(in oklab, var(--color-neon-green) 20%, transparent);
1090
+ }
1091
+ }
1092
+
1049
1093
  .bg-primary {
1050
1094
  background-color: var(--color-primary);
1051
1095
  }
@@ -1272,6 +1316,14 @@ export {
1272
1316
  padding-left: calc(var(--spacing) * 8);
1273
1317
  }
1274
1318
 
1319
+ .pl-\\[22px\\] {
1320
+ padding-left: 22px;
1321
+ }
1322
+
1323
+ .pl-\\[98px\\] {
1324
+ padding-left: 98px;
1325
+ }
1326
+
1275
1327
  .text-center {
1276
1328
  text-align: center;
1277
1329
  }
@@ -1284,6 +1336,10 @@ export {
1284
1336
  text-align: right;
1285
1337
  }
1286
1338
 
1339
+ .align-middle {
1340
+ vertical-align: middle;
1341
+ }
1342
+
1287
1343
  .font-mono {
1288
1344
  font-family: var(--font-mono);
1289
1345
  }
@@ -1770,6 +1826,10 @@ export {
1770
1826
  color: var(--color-coral-red);
1771
1827
  }
1772
1828
 
1829
+ .hover\\:text-gray-200:hover {
1830
+ color: var(--color-gray-200);
1831
+ }
1832
+
1773
1833
  .hover\\:text-gray-300:hover {
1774
1834
  color: var(--color-gray-300);
1775
1835
  }
@@ -1821,6 +1881,18 @@ export {
1821
1881
  translate: var(--tw-translate-x) var(--tw-translate-y);
1822
1882
  }
1823
1883
 
1884
+ .focus\\:border-electric-blue:focus {
1885
+ border-color: var(--color-electric-blue);
1886
+ }
1887
+
1888
+ .focus\\:border-gray-500:focus {
1889
+ border-color: var(--color-gray-500);
1890
+ }
1891
+
1892
+ .focus\\:border-neon-green:focus {
1893
+ border-color: var(--color-neon-green);
1894
+ }
1895
+
1824
1896
  .focus\\:border-primary:focus {
1825
1897
  border-color: var(--color-primary);
1826
1898
  }
@@ -1838,6 +1910,14 @@ export {
1838
1910
  cursor: grabbing;
1839
1911
  }
1840
1912
 
1913
+ .disabled\\:cursor-not-allowed:disabled {
1914
+ cursor: not-allowed;
1915
+ }
1916
+
1917
+ .disabled\\:opacity-40:disabled {
1918
+ opacity: .4;
1919
+ }
1920
+
1841
1921
  @media (min-width: 40rem) {
1842
1922
  .sm\\:grid-cols-2 {
1843
1923
  grid-template-columns: repeat(2, minmax(0, 1fr));