@cnc_cbz/usefultools-plugin-official 1.0.7 → 1.0.9

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.
@@ -1,4 +1,4 @@
1
- import { defineComponent, ref, watch, openBlock, createElementBlock, createCommentVNode, createElementVNode, normalizeClass, toDisplayString, createTextVNode, Fragment, withDirectives, renderList, vModelSelect, unref, vModelText, createBlock, Teleport } from "vue";
1
+ import { defineComponent, ref, watch, computed, openBlock, createElementBlock, createCommentVNode, createElementVNode, normalizeClass, toDisplayString, createTextVNode, Fragment, withDirectives, renderList, vModelSelect, vModelCheckbox, createStaticVNode, unref, vModelText, createBlock, Teleport, vModelDynamic } from "vue";
2
2
  import { fetch } from "@tauri-apps/plugin-http";
3
3
  const _hoisted_1 = { class: "flex flex-col h-full gap-4" };
4
4
  const _hoisted_2 = { class: "flex flex-wrap items-center gap-3" };
@@ -19,46 +19,62 @@ const _hoisted_10 = {
19
19
  key: 0,
20
20
  class: "text-coral-red text-xs font-bold"
21
21
  };
22
- const _hoisted_11 = { class: "flex items-center gap-3" };
23
- const _hoisted_12 = ["value"];
24
- const _hoisted_13 = ["value"];
25
- const _hoisted_14 = {
22
+ const _hoisted_11 = { class: "flex items-center gap-2 ml-auto" };
23
+ const _hoisted_12 = { class: "flex items-center gap-1.5 cursor-pointer" };
24
+ const _hoisted_13 = { class: "flex items-center gap-3" };
25
+ const _hoisted_14 = ["value"];
26
+ const _hoisted_15 = ["value"];
27
+ const _hoisted_16 = {
26
28
  key: 0,
27
29
  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"
28
30
  };
29
- const _hoisted_15 = { class: "flex-1 grid grid-cols-1 lg:grid-cols-2 gap-4 min-h-0" };
30
- const _hoisted_16 = { class: "flex flex-col min-h-0" };
31
- const _hoisted_17 = ["placeholder"];
31
+ const _hoisted_17 = { class: "flex-1 grid grid-cols-1 lg:grid-cols-2 gap-4 min-h-0" };
32
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 = {
33
+ const _hoisted_19 = ["placeholder"];
34
+ const _hoisted_20 = { class: "flex flex-col min-h-0" };
35
+ const _hoisted_21 = { class: "flex items-center gap-2 mb-2" };
36
+ const _hoisted_22 = { class: "material-icons text-sm" };
37
+ const _hoisted_23 = { 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" };
38
+ const _hoisted_24 = {
37
39
  key: 0,
38
40
  class: "text-gray-400 flex items-center gap-2"
39
41
  };
40
- const _hoisted_23 = {
42
+ const _hoisted_25 = {
41
43
  key: 1,
42
44
  class: "text-gray-600"
43
45
  };
44
- const _hoisted_24 = {
46
+ const _hoisted_26 = {
45
47
  key: 2,
46
48
  class: "text-gray-100 whitespace-pre-wrap"
47
49
  };
48
- const _hoisted_25 = {
50
+ const _hoisted_27 = {
49
51
  key: 0,
50
52
  class: "fixed inset-0 z-50 flex items-center justify-center"
51
53
  };
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" };
54
+ const _hoisted_28 = { 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" };
55
+ const _hoisted_29 = { class: "flex items-center gap-2" };
56
+ const _hoisted_30 = {
57
+ key: 0,
58
+ class: "flex flex-col gap-1.5"
59
+ };
60
+ const _hoisted_31 = { class: "relative" };
61
+ const _hoisted_32 = ["type"];
62
+ const _hoisted_33 = { class: "material-icons text-base" };
63
+ const _hoisted_34 = {
64
+ key: 1,
65
+ class: "flex flex-col gap-1.5"
66
+ };
67
+ const _hoisted_35 = { class: "relative" };
68
+ const _hoisted_36 = ["type"];
69
+ const _hoisted_37 = { class: "material-icons text-base" };
70
+ const _hoisted_38 = { class: "flex justify-end gap-3 mt-1" };
57
71
  const GOOGLE_KEY = "translator-google-api-key";
58
72
  const AI_KEY = "translator-ai-api-key";
59
73
  const AI_MODEL_KEY = "translator-ai-model";
60
74
  const ENGINE_KEY = "translator-engine";
61
75
  const DEFAULT_MODEL = "Qwen/Qwen2.5-72B-Instruct";
76
+ const VAR_MODE_KEY = "translator-var-mode";
77
+ const VAR_CASE_KEY = "translator-var-case";
62
78
  const _sfc_main = /* @__PURE__ */ defineComponent({
63
79
  __name: "index",
64
80
  setup(__props) {
@@ -69,6 +85,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
69
85
  const showSettings = ref(false);
70
86
  const googleKeyInput = ref("");
71
87
  const aiKeyInput = ref("");
88
+ const showGoogleKey = ref(false);
89
+ const showAiKey = ref(false);
90
+ const hasGoogleApiKey = computed(() => !!googleApiKey.value.trim());
91
+ const hasAiApiKey = computed(() => !!aiApiKey.value.trim());
92
+ const hasCurrentApiKey = computed(() => engine.value === "google" ? hasGoogleApiKey.value : hasAiApiKey.value);
93
+ const canToggleGoogleKey = computed(() => !!googleKeyInput.value.trim());
94
+ const canToggleAiKey = computed(() => !!aiKeyInput.value.trim());
72
95
  const aiModel = ref(localStorage.getItem(AI_MODEL_KEY) || DEFAULT_MODEL);
73
96
  const aiModels = ref([]);
74
97
  const modelsLoading = ref(false);
@@ -105,6 +128,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
105
128
  const loading = ref(false);
106
129
  const errorMsg = ref("");
107
130
  const copySuccess = ref(false);
131
+ const varMode = ref(localStorage.getItem(VAR_MODE_KEY) === "true");
132
+ const varCase = ref(
133
+ localStorage.getItem(VAR_CASE_KEY) || "camel"
134
+ );
135
+ watch(varMode, (v) => localStorage.setItem(VAR_MODE_KEY, String(v)));
136
+ watch(varCase, (v) => localStorage.setItem(VAR_CASE_KEY, v));
108
137
  const languages = [
109
138
  { code: "auto", name: "自动检测" },
110
139
  { code: "zh-CN", name: "中文(简体)" },
@@ -135,6 +164,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
135
164
  function openSettings() {
136
165
  googleKeyInput.value = googleApiKey.value;
137
166
  aiKeyInput.value = aiApiKey.value;
167
+ showGoogleKey.value = false;
168
+ showAiKey.value = false;
138
169
  showSettings.value = true;
139
170
  }
140
171
  function saveKeys() {
@@ -159,6 +190,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
159
190
  sourceText.value = translatedText.value;
160
191
  translatedText.value = tmpText;
161
192
  }
193
+ function cleanText(text) {
194
+ return text.replace(/\n{3,}/g, "\n\n").replace(/[ \t]+/g, " ").trim();
195
+ }
162
196
  async function translateGoogle() {
163
197
  var _a, _b;
164
198
  if (!googleApiKey.value) {
@@ -166,8 +200,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
166
200
  showSettings.value = true;
167
201
  return;
168
202
  }
203
+ const cleanedText = cleanText(sourceText.value);
169
204
  const body = {
170
- q: sourceText.value,
205
+ q: cleanedText,
171
206
  target: targetLang.value,
172
207
  format: "text"
173
208
  };
@@ -188,11 +223,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
188
223
  showSettings.value = true;
189
224
  return;
190
225
  }
226
+ const cleanedText = cleanText(sourceText.value);
191
227
  const targetName = getLangName(targetLang.value);
192
228
  const sourceName = sourceLang.value === "auto" ? "" : `源语言是${getLangName(sourceLang.value)},`;
193
229
  const prompt = `你是一个专业翻译。${sourceName}请将以下文本翻译为${targetName}。只输出翻译结果,不要解释。
194
230
 
195
- ${sourceText.value}`;
231
+ ${cleanedText}`;
196
232
  const res = await fetch("https://api.siliconflow.cn/v1/chat/completions", {
197
233
  method: "POST",
198
234
  headers: {
@@ -233,6 +269,24 @@ ${sourceText.value}`;
233
269
  }
234
270
  }
235
271
  }
272
+ function toVarName(text, caseType) {
273
+ const words = text.trim().toLowerCase().replace(/[^\w\s]/g, " ").split(/\s+/).filter((w) => w);
274
+ if (!words.length) return "";
275
+ switch (caseType) {
276
+ case "camel":
277
+ return words[0] + words.slice(1).map((w) => w[0].toUpperCase() + w.slice(1)).join("");
278
+ case "pascal":
279
+ return words.map((w) => w[0].toUpperCase() + w.slice(1)).join("");
280
+ case "snake":
281
+ return words.join("_");
282
+ case "screaming":
283
+ return words.join("_").toUpperCase();
284
+ case "kebab":
285
+ return words.join("-");
286
+ default:
287
+ return text;
288
+ }
289
+ }
236
290
  async function translate() {
237
291
  if (!sourceText.value.trim()) return;
238
292
  loading.value = true;
@@ -241,6 +295,9 @@ ${sourceText.value}`;
241
295
  try {
242
296
  if (engine.value === "google") await translateGoogle();
243
297
  else await translateAI();
298
+ if (varMode.value && translatedText.value) {
299
+ translatedText.value = toVarName(translatedText.value, varCase.value);
300
+ }
244
301
  } catch (e) {
245
302
  errorMsg.value = e.message || "翻译失败";
246
303
  } finally {
@@ -248,8 +305,9 @@ ${sourceText.value}`;
248
305
  }
249
306
  }
250
307
  async function copyResult() {
251
- if (!translatedText.value) return;
252
- await navigator.clipboard.writeText(translatedText.value);
308
+ const textToCopy = translatedText.value.trim();
309
+ if (!textToCopy) return;
310
+ await navigator.clipboard.writeText(textToCopy);
253
311
  copySuccess.value = true;
254
312
  setTimeout(() => {
255
313
  copySuccess.value = false;
@@ -279,6 +337,9 @@ ${sourceText.value}`;
279
337
  googleDebounceTimer = setTimeout(async () => {
280
338
  try {
281
339
  await translateGoogle();
340
+ if (varMode.value && translatedText.value) {
341
+ translatedText.value = toVarName(translatedText.value, varCase.value);
342
+ }
282
343
  } catch (e) {
283
344
  errorMsg.value = e.message || "翻译失败";
284
345
  } finally {
@@ -294,6 +355,7 @@ ${sourceText.value}`;
294
355
  function onTextareaKeydown(e) {
295
356
  if (engine.value === "ai" && e.key === "Enter" && !e.shiftKey) {
296
357
  e.preventDefault();
358
+ e.stopPropagation();
297
359
  translate();
298
360
  }
299
361
  }
@@ -351,19 +413,19 @@ ${sourceText.value}`;
351
413
  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",
352
414
  onClick: openSettings
353
415
  }, [
354
- _cache[11] || (_cache[11] = createElementVNode(
416
+ _cache[15] || (_cache[15] = createElementVNode(
355
417
  "span",
356
418
  { class: "material-icons text-lg" },
357
419
  "key",
358
420
  -1
359
421
  /* CACHED */
360
422
  )),
361
- _cache[12] || (_cache[12] = createTextVNode(
423
+ _cache[16] || (_cache[16] = createTextVNode(
362
424
  " API Key ",
363
425
  -1
364
426
  /* CACHED */
365
427
  )),
366
- engine.value === "google" && googleApiKey.value || engine.value === "ai" && aiApiKey.value ? (openBlock(), createElementBlock("span", _hoisted_5)) : (openBlock(), createElementBlock("span", _hoisted_6))
428
+ hasCurrentApiKey.value ? (openBlock(), createElementBlock("span", _hoisted_5)) : (openBlock(), createElementBlock("span", _hoisted_6))
367
429
  ]),
368
430
  createCommentVNode(" AI 模型选择 "),
369
431
  engine.value === "ai" ? (openBlock(), createElementBlock(
@@ -371,7 +433,7 @@ ${sourceText.value}`;
371
433
  { key: 0 },
372
434
  [
373
435
  createElementVNode("div", _hoisted_7, [
374
- _cache[14] || (_cache[14] = createElementVNode(
436
+ _cache[18] || (_cache[18] = createElementVNode(
375
437
  "span",
376
438
  { class: "material-icons text-vibrant-purple text-base" },
377
439
  "smart_toy",
@@ -414,7 +476,7 @@ ${sourceText.value}`;
414
476
  title: "刷新模型列表",
415
477
  onClick: fetchModels
416
478
  },
417
- [..._cache[13] || (_cache[13] = [
479
+ [..._cache[17] || (_cache[17] = [
418
480
  createElementVNode(
419
481
  "span",
420
482
  { class: "material-icons text-sm" },
@@ -437,14 +499,54 @@ ${sourceText.value}`;
437
499
  ],
438
500
  64
439
501
  /* STABLE_FRAGMENT */
440
- )) : createCommentVNode("v-if", true)
502
+ )) : createCommentVNode("v-if", true),
503
+ createCommentVNode(" 变量名模式 "),
504
+ createElementVNode("div", _hoisted_11, [
505
+ createElementVNode("label", _hoisted_12, [
506
+ withDirectives(createElementVNode(
507
+ "input",
508
+ {
509
+ "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => varMode.value = $event),
510
+ type: "checkbox",
511
+ class: "accent-electric-blue w-4 h-4"
512
+ },
513
+ null,
514
+ 512
515
+ /* NEED_PATCH */
516
+ ), [
517
+ [vModelCheckbox, varMode.value]
518
+ ]),
519
+ _cache[19] || (_cache[19] = createElementVNode(
520
+ "span",
521
+ { class: "text-xs text-gray-400 font-bold" },
522
+ "变量名模式",
523
+ -1
524
+ /* CACHED */
525
+ ))
526
+ ]),
527
+ varMode.value ? withDirectives((openBlock(), createElementBlock(
528
+ "select",
529
+ {
530
+ key: 0,
531
+ "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => varCase.value = $event),
532
+ class: "h-9 bg-deep-charcoal text-white border-2 border-black rounded px-3 text-sm font-bold outline-none focus:border-electric-blue transition-colors"
533
+ },
534
+ [..._cache[20] || (_cache[20] = [
535
+ createStaticVNode('<option value="camel" data-v-f1bace68>驼峰 camelCase</option><option value="pascal" data-v-f1bace68>帕斯卡 PascalCase</option><option value="snake" data-v-f1bace68>蛇形 snake_case</option><option value="screaming" data-v-f1bace68>常量 SCREAMING_CASE</option><option value="kebab" data-v-f1bace68>短横 kebab-case</option>', 5)
536
+ ])],
537
+ 512
538
+ /* NEED_PATCH */
539
+ )), [
540
+ [vModelSelect, varCase.value]
541
+ ]) : createCommentVNode("v-if", true)
542
+ ])
441
543
  ]),
442
544
  createCommentVNode(" 语言选择栏 "),
443
- createElementVNode("div", _hoisted_11, [
545
+ createElementVNode("div", _hoisted_13, [
444
546
  withDirectives(createElementVNode(
445
547
  "select",
446
548
  {
447
- "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => sourceLang.value = $event),
549
+ "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => sourceLang.value = $event),
448
550
  class: "bg-deep-charcoal text-white border-2 border-black rounded px-3 py-1.5 text-sm font-bold outline-none focus:border-primary transition-colors"
449
551
  },
450
552
  [
@@ -455,7 +557,7 @@ ${sourceText.value}`;
455
557
  return createElementVNode("option", {
456
558
  key: l.code,
457
559
  value: l.code
458
- }, toDisplayString(l.name), 9, _hoisted_12);
560
+ }, toDisplayString(l.name), 9, _hoisted_14);
459
561
  }),
460
562
  64
461
563
  /* STABLE_FRAGMENT */
@@ -469,7 +571,7 @@ ${sourceText.value}`;
469
571
  createElementVNode("button", {
470
572
  class: "w-8 h-8 flex items-center justify-center bg-deep-charcoal border-2 border-white/20 rounded-full hover:border-primary hover:text-primary transition-all",
471
573
  onClick: swapLangs
472
- }, [..._cache[15] || (_cache[15] = [
574
+ }, [..._cache[21] || (_cache[21] = [
473
575
  createElementVNode(
474
576
  "span",
475
577
  { class: "material-icons text-base" },
@@ -481,7 +583,7 @@ ${sourceText.value}`;
481
583
  withDirectives(createElementVNode(
482
584
  "select",
483
585
  {
484
- "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => targetLang.value = $event),
586
+ "onUpdate:modelValue": _cache[6] || (_cache[6] = ($event) => targetLang.value = $event),
485
587
  class: "bg-deep-charcoal text-white border-2 border-black rounded px-3 py-1.5 text-sm font-bold outline-none focus:border-primary transition-colors"
486
588
  },
487
589
  [
@@ -492,7 +594,7 @@ ${sourceText.value}`;
492
594
  return openBlock(), createElementBlock("option", {
493
595
  key: l.code,
494
596
  value: l.code
495
- }, toDisplayString(l.name), 9, _hoisted_13);
597
+ }, toDisplayString(l.name), 9, _hoisted_15);
496
598
  }),
497
599
  128
498
600
  /* KEYED_FRAGMENT */
@@ -505,8 +607,8 @@ ${sourceText.value}`;
505
607
  ])
506
608
  ]),
507
609
  createCommentVNode(" Error bar "),
508
- errorMsg.value ? (openBlock(), createElementBlock("div", _hoisted_14, [
509
- _cache[16] || (_cache[16] = createElementVNode(
610
+ errorMsg.value ? (openBlock(), createElementBlock("div", _hoisted_16, [
611
+ _cache[22] || (_cache[22] = createElementVNode(
510
612
  "span",
511
613
  { class: "material-icons text-lg" },
512
614
  "error_outline",
@@ -520,10 +622,10 @@ ${sourceText.value}`;
520
622
  )
521
623
  ])) : createCommentVNode("v-if", true),
522
624
  createCommentVNode(" 翻译面板 "),
523
- createElementVNode("div", _hoisted_15, [
625
+ createElementVNode("div", _hoisted_17, [
524
626
  createCommentVNode(" 源文本 "),
525
- createElementVNode("div", _hoisted_16, [
526
- _cache[17] || (_cache[17] = createElementVNode(
627
+ createElementVNode("div", _hoisted_18, [
628
+ _cache[23] || (_cache[23] = createElementVNode(
527
629
  "div",
528
630
  { class: "flex items-center gap-2 mb-2" },
529
631
  [
@@ -534,26 +636,26 @@ ${sourceText.value}`;
534
636
  /* CACHED */
535
637
  )),
536
638
  withDirectives(createElementVNode("textarea", {
537
- "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => sourceText.value = $event),
639
+ "onUpdate:modelValue": _cache[7] || (_cache[7] = ($event) => sourceText.value = $event),
538
640
  spellcheck: "false",
539
641
  placeholder: engine.value === "google" ? "输入文本自动翻译..." : "在此输入要翻译的文本...\nEnter 翻译 / Shift+Enter 换行",
540
642
  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
643
  onKeydown: onTextareaKeydown
542
- }, null, 40, _hoisted_17), [
644
+ }, null, 40, _hoisted_19), [
543
645
  [vModelText, sourceText.value]
544
646
  ])
545
647
  ]),
546
648
  createCommentVNode(" 翻译结果 "),
547
- createElementVNode("div", _hoisted_18, [
548
- createElementVNode("div", _hoisted_19, [
549
- _cache[18] || (_cache[18] = createElementVNode(
649
+ createElementVNode("div", _hoisted_20, [
650
+ createElementVNode("div", _hoisted_21, [
651
+ _cache[24] || (_cache[24] = createElementVNode(
550
652
  "span",
551
653
  { class: "material-icons text-neon-green text-lg" },
552
654
  "g_translate",
553
655
  -1
554
656
  /* CACHED */
555
657
  )),
556
- _cache[19] || (_cache[19] = createElementVNode(
658
+ _cache[25] || (_cache[25] = createElementVNode(
557
659
  "span",
558
660
  { class: "text-sm font-bold text-gray-400 uppercase tracking-wider" },
559
661
  "译文",
@@ -570,7 +672,7 @@ ${sourceText.value}`;
570
672
  [
571
673
  createElementVNode(
572
674
  "span",
573
- _hoisted_20,
675
+ _hoisted_22,
574
676
  toDisplayString(copySuccess.value ? "check_circle" : "content_copy"),
575
677
  1
576
678
  /* TEXT */
@@ -585,8 +687,8 @@ ${sourceText.value}`;
585
687
  /* CLASS */
586
688
  )) : createCommentVNode("v-if", true)
587
689
  ]),
588
- createElementVNode("div", _hoisted_21, [
589
- loading.value && engine.value === "google" ? (openBlock(), createElementBlock("div", _hoisted_22, [..._cache[20] || (_cache[20] = [
690
+ createElementVNode("div", _hoisted_23, [
691
+ loading.value && engine.value === "google" ? (openBlock(), createElementBlock("div", _hoisted_24, [..._cache[26] || (_cache[26] = [
590
692
  createElementVNode(
591
693
  "span",
592
694
  { class: "material-icons text-primary text-base animate-spin" },
@@ -599,9 +701,9 @@ ${sourceText.value}`;
599
701
  -1
600
702
  /* CACHED */
601
703
  )
602
- ])])) : !translatedText.value ? (openBlock(), createElementBlock("div", _hoisted_23, " 翻译结果将显示在这里... ")) : (openBlock(), createElementBlock(
704
+ ])])) : !translatedText.value ? (openBlock(), createElementBlock("div", _hoisted_25, " 翻译结果将显示在这里... ")) : (openBlock(), createElementBlock(
603
705
  "div",
604
- _hoisted_24,
706
+ _hoisted_26,
605
707
  toDisplayString(translatedText.value),
606
708
  1
607
709
  /* TEXT */
@@ -611,21 +713,21 @@ ${sourceText.value}`;
611
713
  ]),
612
714
  createCommentVNode(" API Key 设置弹窗 "),
613
715
  (openBlock(), createBlock(Teleport, { to: "body" }, [
614
- showSettings.value ? (openBlock(), createElementBlock("div", _hoisted_25, [
716
+ showSettings.value ? (openBlock(), createElementBlock("div", _hoisted_27, [
615
717
  createElementVNode("div", {
616
718
  class: "absolute inset-0 bg-black/60",
617
- onClick: _cache[6] || (_cache[6] = ($event) => showSettings.value = false)
719
+ onClick: _cache[8] || (_cache[8] = ($event) => showSettings.value = false)
618
720
  }),
619
- createElementVNode("div", _hoisted_26, [
620
- createElementVNode("div", _hoisted_27, [
621
- _cache[22] || (_cache[22] = createElementVNode(
721
+ createElementVNode("div", _hoisted_28, [
722
+ createElementVNode("div", _hoisted_29, [
723
+ _cache[28] || (_cache[28] = createElementVNode(
622
724
  "span",
623
725
  { class: "material-icons text-primary text-xl" },
624
726
  "key",
625
727
  -1
626
728
  /* CACHED */
627
729
  )),
628
- _cache[23] || (_cache[23] = createElementVNode(
730
+ _cache[29] || (_cache[29] = createElementVNode(
629
731
  "span",
630
732
  { class: "text-lg font-bold text-white" },
631
733
  "配置 API Key",
@@ -634,8 +736,8 @@ ${sourceText.value}`;
634
736
  )),
635
737
  createElementVNode("button", {
636
738
  class: "ml-auto w-8 h-8 flex items-center justify-center text-gray-400 hover:text-white transition-colors",
637
- onClick: _cache[7] || (_cache[7] = ($event) => showSettings.value = false)
638
- }, [..._cache[21] || (_cache[21] = [
739
+ onClick: _cache[9] || (_cache[9] = ($event) => showSettings.value = false)
740
+ }, [..._cache[27] || (_cache[27] = [
639
741
  createElementVNode(
640
742
  "span",
641
743
  { class: "material-icons" },
@@ -645,65 +747,81 @@ ${sourceText.value}`;
645
747
  )
646
748
  ])])
647
749
  ]),
648
- createCommentVNode(" Google API Key "),
649
- createElementVNode("div", _hoisted_28, [
650
- _cache[24] || (_cache[24] = createElementVNode(
750
+ createCommentVNode(" 当前引擎 API Key "),
751
+ engine.value === "google" ? (openBlock(), createElementBlock("div", _hoisted_30, [
752
+ _cache[30] || (_cache[30] = createElementVNode(
651
753
  "label",
652
754
  { class: "text-xs font-bold text-gray-400 uppercase tracking-wider" },
653
755
  "Google Translation API Key",
654
756
  -1
655
757
  /* CACHED */
656
758
  )),
657
- withDirectives(createElementVNode(
658
- "input",
659
- {
660
- "onUpdate:modelValue": _cache[8] || (_cache[8] = ($event) => googleKeyInput.value = $event),
661
- type: "password",
759
+ createElementVNode("div", _hoisted_31, [
760
+ withDirectives(createElementVNode("input", {
761
+ "onUpdate:modelValue": _cache[10] || (_cache[10] = ($event) => googleKeyInput.value = $event),
762
+ type: showGoogleKey.value ? "text" : "password",
662
763
  placeholder: "AIzaSy...",
663
- class: "w-full bg-bg-dark text-gray-100 border-2 border-black rounded-lg px-4 py-2.5 font-mono text-sm outline-none focus:border-primary transition-colors placeholder-gray-600"
664
- },
665
- null,
666
- 512
667
- /* NEED_PATCH */
668
- ), [
669
- [vModelText, googleKeyInput.value]
764
+ class: "api-key-input w-full bg-bg-dark text-gray-100 border-2 border-black rounded-lg px-4 py-2.5 pr-11 font-mono text-sm outline-none focus:border-primary transition-colors placeholder-gray-600"
765
+ }, null, 8, _hoisted_32), [
766
+ [vModelDynamic, googleKeyInput.value]
767
+ ]),
768
+ canToggleGoogleKey.value ? (openBlock(), createElementBlock("button", {
769
+ key: 0,
770
+ class: "absolute right-2 top-1/2 -translate-y-1/2 w-7 h-7 flex items-center justify-center text-gray-400 hover:text-primary transition-colors",
771
+ onClick: _cache[11] || (_cache[11] = ($event) => showGoogleKey.value = !showGoogleKey.value)
772
+ }, [
773
+ createElementVNode(
774
+ "span",
775
+ _hoisted_33,
776
+ toDisplayString(showGoogleKey.value ? "visibility_off" : "visibility"),
777
+ 1
778
+ /* TEXT */
779
+ )
780
+ ])) : createCommentVNode("v-if", true)
670
781
  ])
671
- ]),
672
- createCommentVNode(" SiliconFlow API Key "),
673
- createElementVNode("div", _hoisted_29, [
674
- _cache[25] || (_cache[25] = createElementVNode(
782
+ ])) : (openBlock(), createElementBlock("div", _hoisted_34, [
783
+ _cache[31] || (_cache[31] = createElementVNode(
675
784
  "label",
676
785
  { class: "text-xs font-bold text-gray-400 uppercase tracking-wider" },
677
786
  "SiliconFlow API Key(AI 翻译)",
678
787
  -1
679
788
  /* CACHED */
680
789
  )),
681
- withDirectives(createElementVNode(
682
- "input",
683
- {
684
- "onUpdate:modelValue": _cache[9] || (_cache[9] = ($event) => aiKeyInput.value = $event),
685
- type: "password",
790
+ createElementVNode("div", _hoisted_35, [
791
+ withDirectives(createElementVNode("input", {
792
+ "onUpdate:modelValue": _cache[12] || (_cache[12] = ($event) => aiKeyInput.value = $event),
793
+ type: showAiKey.value ? "text" : "password",
686
794
  placeholder: "sk-...",
687
- class: "w-full bg-bg-dark text-gray-100 border-2 border-black rounded-lg px-4 py-2.5 font-mono text-sm outline-none focus:border-primary transition-colors placeholder-gray-600"
688
- },
689
- null,
690
- 512
691
- /* NEED_PATCH */
692
- ), [
693
- [vModelText, aiKeyInput.value]
795
+ class: "api-key-input w-full bg-bg-dark text-gray-100 border-2 border-black rounded-lg px-4 py-2.5 pr-11 font-mono text-sm outline-none focus:border-primary transition-colors placeholder-gray-600"
796
+ }, null, 8, _hoisted_36), [
797
+ [vModelDynamic, aiKeyInput.value]
798
+ ]),
799
+ canToggleAiKey.value ? (openBlock(), createElementBlock("button", {
800
+ key: 0,
801
+ class: "absolute right-2 top-1/2 -translate-y-1/2 w-7 h-7 flex items-center justify-center text-gray-400 hover:text-primary transition-colors",
802
+ onClick: _cache[13] || (_cache[13] = ($event) => showAiKey.value = !showAiKey.value)
803
+ }, [
804
+ createElementVNode(
805
+ "span",
806
+ _hoisted_37,
807
+ toDisplayString(showAiKey.value ? "visibility_off" : "visibility"),
808
+ 1
809
+ /* TEXT */
810
+ )
811
+ ])) : createCommentVNode("v-if", true)
694
812
  ]),
695
- _cache[26] || (_cache[26] = createElementVNode(
813
+ _cache[32] || (_cache[32] = createElementVNode(
696
814
  "p",
697
815
  { class: "text-[11px] text-gray-600" },
698
816
  "密钥从 cloud.siliconflow.cn 获取,保存后可在工具栏选择模型",
699
817
  -1
700
818
  /* CACHED */
701
819
  ))
702
- ]),
703
- createElementVNode("div", _hoisted_30, [
820
+ ])),
821
+ createElementVNode("div", _hoisted_38, [
704
822
  createElementVNode("button", {
705
823
  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",
706
- onClick: _cache[10] || (_cache[10] = ($event) => showSettings.value = false)
824
+ onClick: _cache[14] || (_cache[14] = ($event) => showSettings.value = false)
707
825
  }, " 取消 "),
708
826
  createElementVNode("button", {
709
827
  class: "px-4 py-2 bg-primary text-black font-bold border-2 border-black rounded shadow-hard-sm hover:shadow-none hover:translate-x-[2px] hover:translate-y-[2px] transition-all text-sm",
@@ -717,8 +835,16 @@ ${sourceText.value}`;
717
835
  };
718
836
  }
719
837
  });
838
+ const _export_sfc = (sfc, props) => {
839
+ const target = sfc.__vccOpts || sfc;
840
+ for (const [key, val] of props) {
841
+ target[key] = val;
842
+ }
843
+ return target;
844
+ };
845
+ const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-f1bace68"]]);
720
846
  export {
721
- _sfc_main as default
847
+ index as default
722
848
  };
723
849
 
724
850
  ;(function(){var c=typeof __exports__!=="undefined"&&__exports__;var d=c&&(c.default||c);if(d)d.__pluginCss=`/*! tailwindcss v4.2.1 | MIT License | https://tailwindcss.com */
@@ -876,6 +1002,10 @@ export {
876
1002
  top: 50%;
877
1003
  }
878
1004
 
1005
+ .right-2 {
1006
+ right: calc(var(--spacing) * 2);
1007
+ }
1008
+
879
1009
  .left-2 {
880
1010
  left: calc(var(--spacing) * 2);
881
1011
  }
@@ -1108,6 +1238,10 @@ export {
1108
1238
  width: calc(var(--spacing) * 5);
1109
1239
  }
1110
1240
 
1241
+ .w-7 {
1242
+ width: calc(var(--spacing) * 7);
1243
+ }
1244
+
1111
1245
  .w-8 {
1112
1246
  width: calc(var(--spacing) * 8);
1113
1247
  }
@@ -1843,6 +1977,10 @@ export {
1843
1977
  padding-right: calc(var(--spacing) * 6);
1844
1978
  }
1845
1979
 
1980
+ .pr-11 {
1981
+ padding-right: calc(var(--spacing) * 11);
1982
+ }
1983
+
1846
1984
  .pl-1\\.5 {
1847
1985
  padding-left: calc(var(--spacing) * 1.5);
1848
1986
  }
@@ -2146,6 +2284,10 @@ export {
2146
2284
  color: var(--color-gray-600);
2147
2285
  }
2148
2286
 
2287
+ .accent-electric-blue {
2288
+ accent-color: var(--color-electric-blue);
2289
+ }
2290
+
2149
2291
  .accent-primary {
2150
2292
  accent-color: var(--color-primary);
2151
2293
  }
@@ -2753,4 +2895,13 @@ export {
2753
2895
  opacity: .5;
2754
2896
  }
2755
2897
  }
2898
+
2899
+ .api-key-input[data-v-f1bace68]::-ms-reveal,
2900
+ .api-key-input[data-v-f1bace68]::-ms-clear,
2901
+ .api-key-input[data-v-f1bace68]::-webkit-credentials-auto-fill-button,
2902
+ .api-key-input[data-v-f1bace68]::-webkit-contacts-auto-fill-button {
2903
+ display: none !important;
2904
+ visibility: hidden;
2905
+ pointer-events: none;
2906
+ }
2756
2907
  `;})();