dsh-quick-translate 0.2.0 → 0.3.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 +26 -8
- package/client.js +752 -34
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
# 快速翻译 · DeepSeek Harness 插件
|
|
2
2
|
|
|
3
|
-
英译中 / 中译英,直接选用 DSH「设置 ›
|
|
3
|
+
英译中 / 中译英,直接选用 DSH「设置 › 模型」里已经添加的服务商和模型,结果流式显示;翻译结果还能一键做成分享卡片。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
界面有两种风格,在头部随时切换(记在本机):
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- **纸本**(默认):一张纸本拼贴风格的桌面,原文写在方格本上,译文印在叠在上面的硫酸纸上。
|
|
8
|
+
- **色场**:简洁版。左边一块素色圆角容器放原文,右边一整块品牌色放译文,颜色跟随 DSH 的明暗主题。适合只想快速翻译、不想看太多装饰的人。
|
|
9
|
+
|
|
10
|
+
### 纸本
|
|
11
|
+
|
|
12
|
+

|
|
13
|
+
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
### 色场
|
|
17
|
+
|
|
18
|
+

|
|
19
|
+
|
|
20
|
+

|
|
21
|
+
|
|
22
|
+

|
|
8
23
|
|
|
9
24
|
## 安装
|
|
10
25
|
|
|
@@ -13,6 +28,8 @@
|
|
|
13
28
|
|
|
14
29
|
## 怎么用
|
|
15
30
|
|
|
31
|
+
下面按纸本风格描述;色场风格功能完全一样,只是换了样子:翻译、互换、方向、模型、历史、复制、分享图片都在对应位置,历史是一张盖在译文位置上的卡片。
|
|
32
|
+
|
|
16
33
|
1. 左侧栏点「快速翻译」图标,主区域打开翻译桌面。
|
|
17
34
|
2. 在方格本上贴原文,按 **⌘/Ctrl + Enter**(或点红色的「翻译」胶带),硫酸纸上边生成边显示译文,完成后盖一个「已译」章。
|
|
18
35
|
3. 右下角牛皮纸标签选方向:**英 → 中** / **中 → 英** / **自动**(自动按汉字占比判断,方格本右上角会提示本次译成哪种语言)。
|
|
@@ -20,14 +37,15 @@
|
|
|
20
37
|
5. 两张纸接缝处的牛皮纸「互换」签把原文和译文**互换**并翻转方向(再点一次换回来),方便回译检验。
|
|
21
38
|
6. 每次完成的翻译自动进入**历史**(右上角「历史」打开一张热敏小票):可搜索原文/译文/模型,点一条即回看,悬停可删单条,「清空历史」需点两次确认。历史最多保留 100 条,存在浏览器 localStorage 里。
|
|
22
39
|
7. **Esc** 取消进行中的翻译;「复制」把译文放进剪贴板;方格本上的「清空」开始新一轮。
|
|
23
|
-
8.
|
|
40
|
+
8. 「分享图片」把这次的原文和译文画成一张竖版卡片(纸本是拼贴卡,色场是白底蓝块卡),可以复制到剪贴板或保存成 PNG。
|
|
41
|
+
9. 头部的「风格」切换纸本 / 色场,内容和历史不受影响。
|
|
24
42
|
|
|
25
43
|
## 它做了什么
|
|
26
44
|
|
|
27
45
|
- **Host 半边**(`index.js`)在 DSH Web 服务器上挂两个仅限本机 owner 的接口:
|
|
28
46
|
- `GET /quick-translate/api/models`:通过 `ctx.llm.listProviders()` + `listModels()` 列出已配置模型
|
|
29
47
|
- `POST /quick-translate/api/translate`:用 `ctx.llm.prepareCall()` + `stream()` 做一次翻译,SSE 流式回传
|
|
30
|
-
- **Client 半边**(`client.js`)在 `sidebar.panellist` 注册侧栏图标,在 `main`
|
|
48
|
+
- **Client 半边**(`client.js`)在 `sidebar.panellist` 注册侧栏图标,在 `main` 注册面板;两种风格都按设计稿的尺寸原样搭好再整体缩放到面板大小(纸本 1200×690,色场 1200×696);纸本的颜色固定,色场的颜色全部用 DSH 主题 token、跟随明暗主题;文案走 DSH 的 locale 服务。
|
|
31
49
|
- 翻译请求会发给所选模型对应的服务商;插件本身不保存任何密钥,也不改动任何会话。不联网加载字体或其它资源。
|
|
32
50
|
- 思考型模型自动选最低推理档位(翻译不需要长思考,快最重要)。
|
|
33
51
|
|
|
@@ -44,13 +62,13 @@
|
|
|
44
62
|
|
|
45
63
|
```
|
|
46
64
|
index.js Host:HTTP 接口 + 调 DSH 的 llm 服务
|
|
47
|
-
client.js 浏览器:侧栏入口 +
|
|
65
|
+
client.js 浏览器:侧栏入口 + 翻译界面(纸本 / 色场两种风格,界面全在这里)
|
|
48
66
|
cordis.patch.yml Loader 补丁:插入 quick-translate 这一行
|
|
49
67
|
locale/ 插件管理器里显示的标题和说明(zh / en)
|
|
50
68
|
icon.svg 侧栏和插件列表里的图标
|
|
51
|
-
dev/smoke.mjs 离线冒烟测试:node dev/smoke.mjs(
|
|
69
|
+
dev/smoke.mjs 离线冒烟测试:node dev/smoke.mjs(68 项,含两种风格,不需要 DSH)
|
|
52
70
|
dev/harness.html 本地预览壳:不开 DSH 也能看界面(用法见 AGENTS.md §7)
|
|
53
|
-
docs/screenshots/ README 截图(由 dev/harness.html?demo=1
|
|
71
|
+
docs/screenshots/ README 截图(由 dev/harness.html?demo=1 生成;色场加 &skin=field&h=750)
|
|
54
72
|
AGENTS.md 交接文档:接手界面工作的人或 Agent 先读这个
|
|
55
73
|
```
|
|
56
74
|
|
package/client.js
CHANGED
|
@@ -24,6 +24,9 @@ window.__ModuleLoader__.load({
|
|
|
24
24
|
const AUTHOR = 'Erek'
|
|
25
25
|
const COMP_W = 1200 // 画板 E 的桌面尺寸(去掉标题行)
|
|
26
26
|
const COMP_H = 690
|
|
27
|
+
const FIELD_W = 1200 // 画板 F 色场的工作区(1200×760 去掉 64px 头部)
|
|
28
|
+
const FIELD_H = 696
|
|
29
|
+
const FIELD_MAX_ZOOM = 1.3 // 简洁风格放太大会显得臃肿(作者 2026-11-24 同意)
|
|
27
30
|
|
|
28
31
|
/* ============================== 文案 ================================ */
|
|
29
32
|
|
|
@@ -106,6 +109,18 @@ window.__ModuleLoader__.load({
|
|
|
106
109
|
modelCount: (n) => `DSH 已配置 ${n} 个`,
|
|
107
110
|
historyTotal: (n) => `共 ${n} 条`,
|
|
108
111
|
noModelsTitle: '还没有可用的模型',
|
|
112
|
+
skin: '风格',
|
|
113
|
+
skinPaper: '纸本',
|
|
114
|
+
skinField: '色场',
|
|
115
|
+
fieldAuto: '自动识别',
|
|
116
|
+
fieldAutoTo: (t) => `自动识别 · 译成${t === 'zh' ? '中文' : '英文'}`,
|
|
117
|
+
fieldLocked: '翻译中,原文已锁定',
|
|
118
|
+
fSrc: '源文',
|
|
119
|
+
fDst: '译文',
|
|
120
|
+
historyCount: (n) => `${n} 条`,
|
|
121
|
+
historyHide: '收起历史',
|
|
122
|
+
historyKeep: '最多保留 100 条 · 点一条即可回看',
|
|
123
|
+
refreshShort: '刷新',
|
|
109
124
|
},
|
|
110
125
|
en: {
|
|
111
126
|
title: 'Quick translate',
|
|
@@ -185,6 +200,18 @@ window.__ModuleLoader__.load({
|
|
|
185
200
|
modelCount: (n) => `${n} in DSH`,
|
|
186
201
|
historyTotal: (n) => `${n} total`,
|
|
187
202
|
noModelsTitle: 'No model yet',
|
|
203
|
+
skin: 'Style',
|
|
204
|
+
skinPaper: 'Paper',
|
|
205
|
+
skinField: 'Field',
|
|
206
|
+
fieldAuto: 'Auto-detect',
|
|
207
|
+
fieldAutoTo: (t) => `Auto-detect · to ${t === 'zh' ? 'Chinese' : 'English'}`,
|
|
208
|
+
fieldLocked: 'Translating · source locked',
|
|
209
|
+
fSrc: 'Source',
|
|
210
|
+
fDst: 'Output',
|
|
211
|
+
historyCount: (n) => `${n}`,
|
|
212
|
+
historyHide: 'Hide history',
|
|
213
|
+
historyKeep: 'Keeps the latest 100 · click one to reopen',
|
|
214
|
+
refreshShort: 'Refresh',
|
|
188
215
|
},
|
|
189
216
|
}
|
|
190
217
|
|
|
@@ -484,6 +511,227 @@ window.__ModuleLoader__.load({
|
|
|
484
511
|
.qt-title{-webkit-text-stroke:.5px currentColor}
|
|
485
512
|
.qt-go,.qt-clear,.qt-swap b,.qt-picker-head b,.qt-history-head b,.qt-empty-card b{-webkit-text-stroke:.6px currentColor}
|
|
486
513
|
.qt-tag-big,.qt-waiting b{-webkit-text-stroke:1.1px currentColor}
|
|
514
|
+
/* 纸本头部的风格切换:打字机字「风格: [ 纸本 ] / 色场」 */
|
|
515
|
+
.qt-skinsw{display:inline-flex;align-items:center;gap:10px;font-size:12px;margin-right:10px;white-space:nowrap}
|
|
516
|
+
.qt-skinsw-k{opacity:.55}
|
|
517
|
+
.qt-skinsw-sep{opacity:.4}
|
|
518
|
+
.qt-skinsw .qt-hbtn[aria-pressed="true"]{font-weight:600}
|
|
519
|
+
.qt-skinsw .qt-hbtn[aria-pressed="true"]::before{content:"[ "}.qt-skinsw .qt-hbtn[aria-pressed="true"]::after{content:" ]"}
|
|
520
|
+
.qt-skinsw .qt-hbtn[aria-pressed="false"]{opacity:.6}
|
|
521
|
+
.qt-skinsw .qt-hbtn[aria-pressed="false"]:hover{opacity:1}
|
|
522
|
+
|
|
523
|
+
/* ============ 色场(F):画板 F 的 1200×696 工作区原样搭,再整体缩放(最多 1.3 倍);颜色全部走 DSH 主题 token ============ */
|
|
524
|
+
.qt-root.qt-skin-field{
|
|
525
|
+
--qt-f-base:var(--dsw-alias-bg-base,#fff);--qt-f-l1:var(--dsw-alias-bg-layer-1,#f6f6f8);--qt-f-l2:var(--dsw-alias-bg-layer-2,#ececf0);--qt-f-ov:var(--dsw-alias-bg-overlay,#fff);
|
|
526
|
+
--qt-f-b1:var(--dsw-alias-border-l1,#e9e9ee);--qt-f-b2:var(--dsw-alias-border-l2,#d8d8de);--qt-f-brand:var(--dsw-alias-brand-primary,#4d6bfe);
|
|
527
|
+
--qt-f-ink:var(--dsw-alias-label-primary,#1d1d22);--qt-f-mute:var(--dsw-alias-label-secondary,#6c6c75);--qt-f-idle:var(--dsw-alias-state-idle-primary,#a7a7ae);
|
|
528
|
+
--qt-f-err:var(--dsw-alias-state-error-primary,#d14343);
|
|
529
|
+
--qt-f-field:var(--qt-f-brand);--qt-f-on:#fff;--qt-f-on2:rgba(255,255,255,.86);--qt-f-on3:rgba(255,255,255,.16);--qt-f-wm:rgba(255,255,255,.08);
|
|
530
|
+
--qt-f-ui:-apple-system,BlinkMacSystemFont,"PingFang SC","Helvetica Neue",var(--qt-zh-sans);
|
|
531
|
+
--qt-f-mono:"SF Mono",Menlo,var(--qt-mono);
|
|
532
|
+
background:var(--qt-f-base);color:var(--qt-f-ink);font-family:var(--qt-f-ui)}
|
|
533
|
+
.qt-root.qt-skin-field[data-tone="dark"]{--qt-f-field:color-mix(in srgb,var(--qt-f-brand) 55%,var(--qt-f-base));--qt-f-on2:rgba(255,255,255,.8);--qt-f-on3:rgba(255,255,255,.12);--qt-f-wm:rgba(255,255,255,.06)}
|
|
534
|
+
.qt-skin-field :focus-visible{outline:2px solid var(--qt-f-brand);outline-offset:2px}
|
|
535
|
+
.qt-ffield :focus-visible{outline-color:#fff}
|
|
536
|
+
|
|
537
|
+
/* 头部 */
|
|
538
|
+
.qt-fhead{display:flex;align-items:center;gap:12px;flex:none;height:calc(64px + var(--dsh-frame-top-clearance,0px));padding:var(--dsh-frame-top-clearance,0px) 32px 0 calc(32px + var(--dsh-frame-leading-clearance,0px))}
|
|
539
|
+
.qt-ftitle{font-size:17px;font-weight:700;letter-spacing:-.01em;white-space:nowrap}
|
|
540
|
+
.qt-fsub{font-size:12px;color:var(--qt-f-mute);margin-right:auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}
|
|
541
|
+
.qt-ftrack{display:flex;gap:2px;padding:3px;border-radius:11px;background:var(--qt-f-l2);flex:none}
|
|
542
|
+
.qt-ftrack button{height:28px;padding:0 12px;border-radius:8px;font-size:12.5px;color:var(--qt-f-mute);display:inline-flex;align-items:center;gap:7px;white-space:nowrap;transition:background .15s,color .15s}
|
|
543
|
+
.qt-ftrack button:hover:not(:disabled){color:var(--qt-f-ink)}
|
|
544
|
+
.qt-ftrack button[aria-pressed="true"]{background:var(--qt-f-base);color:var(--qt-f-ink);font-weight:600;box-shadow:0 1px 2px rgba(0,0,0,.08),0 0 0 .5px rgba(0,0,0,.04)}
|
|
545
|
+
.qt-ftrack button:disabled{opacity:.45}
|
|
546
|
+
.qt-fsw{width:10px;height:10px;border-radius:3px;flex:none}
|
|
547
|
+
.qt-fsw-paper{background:#eeede7;box-shadow:inset 0 0 0 1px rgba(0,0,0,.18),inset -4px 0 0 #b88f62}
|
|
548
|
+
.qt-fsw-field{background:var(--qt-f-brand)}
|
|
549
|
+
.qt-fhb{height:32px;padding:0 12px;border-radius:10px;display:inline-flex;align-items:center;gap:8px;font-size:13px;color:var(--qt-f-mute);white-space:nowrap;flex:none;transition:background .15s,color .15s}
|
|
550
|
+
.qt-fhb:hover:not(:disabled),.qt-fhb[aria-pressed="true"]{background:var(--qt-f-l2);color:var(--qt-f-ink)}
|
|
551
|
+
.qt-fhb:disabled{opacity:.5}
|
|
552
|
+
.qt-fcnt{min-width:20px;height:18px;padding:0 6px;border-radius:9px;background:var(--qt-f-l2);color:var(--qt-f-ink);font-size:11px;font-weight:600;display:inline-grid;place-items:center;font-variant-numeric:tabular-nums}
|
|
553
|
+
.qt-fhb[aria-pressed="true"] .qt-fcnt,.qt-fhb:hover .qt-fcnt{background:var(--qt-f-base)}
|
|
554
|
+
|
|
555
|
+
/* 工作区 */
|
|
556
|
+
.qt-fboard{flex:1;min-height:0;position:relative;display:flex;align-items:center;justify-content:center;overflow:hidden}
|
|
557
|
+
.qt-fcomp{position:relative;width:1200px;height:696px;flex:none}
|
|
558
|
+
.qt-fbox{position:absolute;top:8px;height:664px;border-radius:28px;display:flex;flex-direction:column;min-width:0}
|
|
559
|
+
.qt-fsrc{left:24px;width:556px;padding:32px 36px 28px 40px;background:var(--qt-f-l1);box-shadow:inset 0 0 0 1px var(--qt-f-b1)}
|
|
560
|
+
.qt-ffield{left:596px;width:580px;padding:32px 36px 28px 48px;background:var(--qt-f-field);color:var(--qt-f-on);overflow:hidden}
|
|
561
|
+
.qt-frow{position:relative;display:flex;align-items:center;gap:12px;height:40px;flex:none;min-width:0}
|
|
562
|
+
.qt-flang{font-size:28px;line-height:1;white-space:nowrap;flex:none}
|
|
563
|
+
.qt-flang[data-lang="en"]{font-family:var(--qt-en-serif);font-style:italic}
|
|
564
|
+
.qt-flang[data-lang="zh"]{font-family:var(--qt-zh-serif);font-weight:600}
|
|
565
|
+
.qt-fhint{font-size:12.5px;color:var(--qt-f-mute);margin-right:auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}
|
|
566
|
+
.qt-fhint.is-locked{color:var(--qt-f-brand)}
|
|
567
|
+
.qt-ffield .qt-fhint{color:var(--qt-f-on2)}
|
|
568
|
+
.qt-fchip-warn{color:var(--qt-f-on);font-weight:600;padding:3px 8px;border-radius:8px;background:var(--qt-f-on3)}
|
|
569
|
+
.qt-fbody{position:relative;flex:1;min-height:0;display:flex;flex-direction:column}
|
|
570
|
+
.qt-fta{flex:1;min-height:0;width:100%;resize:none;border:0;outline:0;background:transparent;padding:0;margin:28px 0 0;color:inherit;scrollbar-width:thin;scrollbar-color:var(--qt-f-b2) transparent}
|
|
571
|
+
.qt-fta:focus-visible{outline:0}
|
|
572
|
+
.qt-fsrc .qt-fta{font-family:var(--qt-f-ui);font-size:18px;line-height:1.75}
|
|
573
|
+
.qt-fsrc .qt-fta::placeholder{color:var(--qt-f-idle)}
|
|
574
|
+
.qt-fsrc .qt-fta[readonly]{color:var(--qt-f-mute);cursor:default}
|
|
575
|
+
.qt-ffield .qt-fta{scrollbar-color:rgba(255,255,255,.35) transparent}
|
|
576
|
+
.qt-fres{font-family:var(--qt-zh-serif);font-size:25px;font-weight:600;line-height:1.8;letter-spacing:.02em}
|
|
577
|
+
.qt-fres[data-lang="en"]{font-family:var(--qt-en-serif);font-weight:500;line-height:1.6;letter-spacing:0}
|
|
578
|
+
.qt-fres::placeholder{color:transparent}
|
|
579
|
+
.qt-fwait{position:absolute;inset:28px 0 0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;padding-bottom:40px;text-align:center;pointer-events:none}
|
|
580
|
+
.qt-fwait b{font-family:var(--qt-zh-serif);font-size:44px;font-weight:600;letter-spacing:.08em;line-height:1.2}
|
|
581
|
+
.qt-fwait span{font-size:13px;color:var(--qt-f-on2)}
|
|
582
|
+
.qt-ffoot{position:relative;display:flex;align-items:center;gap:8px;height:48px;flex:none;min-width:0}
|
|
583
|
+
.qt-fcount{font-size:12.5px;color:var(--qt-f-mute);margin-right:auto;font-variant-numeric:tabular-nums;white-space:nowrap}
|
|
584
|
+
.qt-fclear{height:40px;padding:0 16px;border-radius:12px;font-size:13.5px;color:var(--qt-f-mute);white-space:nowrap}
|
|
585
|
+
.qt-fclear:hover:not(:disabled){background:var(--qt-f-l2);color:var(--qt-f-ink)}
|
|
586
|
+
.qt-fclear:disabled{opacity:.4}
|
|
587
|
+
.qt-fgo{height:44px;padding:0 8px 0 20px;border-radius:14px;background:var(--qt-f-ink);color:var(--qt-f-base);font-size:14.5px;font-weight:600;display:inline-flex;align-items:center;gap:12px;white-space:nowrap;flex:none;transition:transform .15s,opacity .15s}
|
|
588
|
+
.qt-fgo:hover:not(:disabled){transform:translateY(-1px)}
|
|
589
|
+
.qt-fgo:disabled{opacity:.32}
|
|
590
|
+
.qt-fgo kbd{font:inherit;font-size:11.5px;font-weight:500;height:26px;padding:0 8px;border-radius:8px;display:inline-grid;place-items:center;background:color-mix(in srgb,currentColor 16%,transparent)}
|
|
591
|
+
.qt-fgo.is-stop{background:var(--qt-f-base);color:var(--qt-f-ink);box-shadow:inset 0 0 0 1px var(--qt-f-b2)}
|
|
592
|
+
.qt-fgo.is-stop kbd{background:var(--qt-f-l2)}
|
|
593
|
+
.qt-fswap{position:absolute;left:562px;top:38px;z-index:5;width:52px;height:52px;border-radius:50%;background:var(--qt-f-base);color:var(--qt-f-ink);display:grid;place-items:center;box-shadow:0 0 0 6px var(--qt-f-base),0 8px 22px -6px rgba(0,0,0,.28);transition:transform .3s var(--qt-ease),opacity .15s}
|
|
594
|
+
.qt-fswap:hover:not(:disabled){transform:rotate(180deg)}
|
|
595
|
+
.qt-fswap:disabled{opacity:.45}
|
|
596
|
+
.qt-fcomp.is-hist .qt-fswap{visibility:hidden}
|
|
597
|
+
.qt-fwm{position:absolute;right:-44px;bottom:-132px;font-family:var(--qt-zh-serif);font-weight:600;font-size:480px;line-height:1;color:var(--qt-f-wm);pointer-events:none;user-select:none}
|
|
598
|
+
.qt-fwm[data-lang="en"]{font-family:var(--qt-en-serif);font-weight:500;right:-20px;bottom:-150px}
|
|
599
|
+
.qt-fstats{position:relative;display:flex;gap:20px;font-size:12px;color:var(--qt-f-on2);padding-bottom:14px;flex:none;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden}
|
|
600
|
+
.qt-fprog{position:absolute;left:0;right:0;top:0;height:3px;background:var(--qt-f-on3);overflow:hidden}
|
|
601
|
+
.qt-fprog::after{content:"";position:absolute;top:0;bottom:0;left:-36%;width:36%;border-radius:2px;background:rgba(255,255,255,.75);animation:qt-fprog 1.4s ease-in-out infinite}
|
|
602
|
+
@keyframes qt-fprog{from{left:-36%}to{left:100%}}
|
|
603
|
+
.qt-ferror{position:relative;margin:20px 0 0;padding:10px 10px 10px 16px;border-radius:14px;background:var(--qt-f-on3);display:flex;gap:12px;align-items:center;font-size:13px;line-height:1.55;flex:none}
|
|
604
|
+
.qt-ferror .qt-error-text{flex:1;min-width:0;word-break:break-word}
|
|
605
|
+
.qt-ferror button,.qt-fcopy{height:40px;padding:0 18px;border-radius:12px;background:#fff;color:color-mix(in srgb,var(--qt-f-field) 82%,#000);font-size:13.5px;font-weight:600;white-space:nowrap;flex:none}
|
|
606
|
+
.qt-ferror button{height:32px;padding:0 14px;border-radius:10px}
|
|
607
|
+
.qt-fcopy.is-warn{color:var(--qt-f-err)}
|
|
608
|
+
.qt-fcopy:disabled,.qt-flink:disabled{opacity:.4}
|
|
609
|
+
.qt-flink{height:40px;padding:0 14px;border-radius:12px;font-size:13.5px;color:var(--qt-f-on);white-space:nowrap;flex:none}
|
|
610
|
+
.qt-flink:hover:not(:disabled){background:var(--qt-f-on3)}
|
|
611
|
+
|
|
612
|
+
/* 色场的模型选择:白字按钮 + 往上弹的圆角菜单 */
|
|
613
|
+
.qt-fpick{position:relative;min-width:0;flex:0 1 auto}
|
|
614
|
+
.qt-fpick-btn{height:40px;padding:0 14px;border-radius:12px;background:var(--qt-f-on3);color:var(--qt-f-on);display:inline-flex;align-items:center;gap:8px;font-size:13.5px;white-space:nowrap;max-width:100%;transition:background .15s}
|
|
615
|
+
.qt-fpick-btn:hover:not(:disabled),.qt-fpick-btn[aria-expanded="true"]{background:rgba(255,255,255,.28)}
|
|
616
|
+
.qt-fpick-btn:disabled{opacity:.5}
|
|
617
|
+
.qt-fpick-k,.qt-fpick-tag{color:var(--qt-f-on2);flex:none}
|
|
618
|
+
.qt-fpick-label{font-weight:600;overflow:hidden;text-overflow:ellipsis;min-width:0}
|
|
619
|
+
.qt-fpick-btn svg{flex:none;transition:transform .2s var(--qt-ease)}
|
|
620
|
+
.qt-fpick-btn[aria-expanded="true"] svg{transform:rotate(180deg)}
|
|
621
|
+
.qt-fmenu{position:absolute;left:0;bottom:calc(100% + 10px);z-index:30;width:336px;max-height:420px;overflow:auto;padding:16px 8px 8px;background:var(--qt-f-ov);color:var(--qt-f-ink);border:1px solid var(--qt-f-b1);border-radius:20px;box-shadow:0 24px 60px -16px rgba(0,0,0,.28),0 2px 8px rgba(0,0,0,.06);animation:qt-fade .15s ease}
|
|
622
|
+
.qt-fmenu-head{display:flex;align-items:baseline;justify-content:space-between;gap:12px;padding:0 12px 8px}
|
|
623
|
+
.qt-fmenu-head b{font-size:15px;font-weight:600}
|
|
624
|
+
.qt-fmenu-head span{font-size:12px;color:var(--qt-f-mute)}
|
|
625
|
+
.qt-fmi{display:flex;align-items:center;gap:10px;width:100%;height:40px;padding:0 12px;border-radius:10px;font-size:13.5px;text-align:left;white-space:nowrap;color:var(--qt-f-ink)}
|
|
626
|
+
.qt-fmi:hover{background:var(--qt-f-l1)}
|
|
627
|
+
.qt-fmi[aria-selected="true"]{background:var(--qt-f-l2);font-weight:600}
|
|
628
|
+
.qt-fmi .qt-check{width:16px;flex:none;color:var(--qt-f-brand);visibility:hidden;display:inline-flex}
|
|
629
|
+
.qt-fmi[aria-selected="true"] .qt-check{visibility:visible}
|
|
630
|
+
.qt-fmi .qt-name{overflow:hidden;text-overflow:ellipsis;min-width:0}
|
|
631
|
+
.qt-fmi .qt-id{margin-left:auto;font-family:var(--qt-f-mono);font-size:11px;font-weight:400;color:var(--qt-f-mute);overflow:hidden;text-overflow:ellipsis;max-width:46%}
|
|
632
|
+
.qt-fmg{padding:12px 12px 4px;font-size:11.5px;font-weight:600;color:var(--qt-f-mute)}
|
|
633
|
+
.qt-fmenu-empty{padding:10px 12px;font-size:12.5px;color:var(--qt-f-mute)}
|
|
634
|
+
|
|
635
|
+
/* 色场的历史:一张和译文容器同样大的卡,盖在译文的位置上;头尾固定,中间单独滚动 */
|
|
636
|
+
.qt-fhist{position:absolute;left:596px;top:8px;width:580px;height:664px;border-radius:28px;background:var(--qt-f-ov);color:var(--qt-f-ink);box-shadow:inset 0 0 0 1px var(--qt-f-b1),0 24px 60px -24px rgba(0,0,0,.22);display:flex;flex-direction:column;overflow:hidden;z-index:6;animation:qt-fade .18s ease}
|
|
637
|
+
.qt-fhist-head{display:flex;align-items:center;gap:12px;height:68px;padding:28px 28px 0 36px;flex:none;min-width:0}
|
|
638
|
+
.qt-fhist-head b{font-size:20px;font-weight:600;white-space:nowrap}
|
|
639
|
+
.qt-fhist-head > span{font-size:12.5px;color:var(--qt-f-mute);margin-right:auto;white-space:nowrap}
|
|
640
|
+
.qt-fhist-search{width:240px;min-width:0;height:36px;border-radius:10px;background:var(--qt-f-l1);box-shadow:inset 0 0 0 1px var(--qt-f-b1);display:flex;align-items:center;gap:8px;padding:0 12px;color:var(--qt-f-mute)}
|
|
641
|
+
.qt-fhist-search svg{flex:none}
|
|
642
|
+
.qt-fhist-search input{flex:1;min-width:0;border:0;outline:0;background:none;font-size:13px;color:var(--qt-f-ink)}
|
|
643
|
+
.qt-fhist-search input::placeholder{color:var(--qt-f-mute)}
|
|
644
|
+
.qt-fhist-search:focus-within{box-shadow:inset 0 0 0 1.5px var(--qt-f-brand)}
|
|
645
|
+
.qt-ficon{width:36px;height:36px;border-radius:10px;display:grid;place-items:center;color:var(--qt-f-mute);flex:none}
|
|
646
|
+
.qt-ficon:hover{background:var(--qt-f-l2);color:var(--qt-f-ink)}
|
|
647
|
+
.qt-fhist-rule{height:1px;background:var(--qt-f-b1);margin-top:20px;flex:none}
|
|
648
|
+
.qt-fhist-scroll{flex:1;min-height:0;position:relative}
|
|
649
|
+
.qt-fhist-list{position:absolute;inset:0;overflow-y:auto;padding:0 24px 24px 20px;scrollbar-width:none}
|
|
650
|
+
.qt-fhist-list::-webkit-scrollbar{display:none}
|
|
651
|
+
.qt-fhday{position:sticky;top:0;z-index:2;background:var(--qt-f-ov);padding:16px 12px 6px;font-size:12px;font-weight:600;color:var(--qt-f-mute)}
|
|
652
|
+
.qt-fhi-wrap{position:relative;margin-bottom:2px}
|
|
653
|
+
.qt-fhi{display:grid;grid-template-columns:44px minmax(0,1fr) 112px;column-gap:14px;align-items:start;width:100%;text-align:left;padding:14px 14px 14px 12px;border-radius:14px;color:var(--qt-f-ink);transition:background .12s}
|
|
654
|
+
.qt-fhi-wrap:hover .qt-fhi{background:var(--qt-f-l2)}
|
|
655
|
+
.qt-fhi[aria-current="true"],.qt-fhi-wrap:hover .qt-fhi[aria-current="true"]{background:color-mix(in srgb,var(--qt-f-brand) 10%,transparent)}
|
|
656
|
+
.qt-fhi-time{font-size:12px;color:var(--qt-f-mute);padding-top:3px;font-variant-numeric:tabular-nums}
|
|
657
|
+
.qt-fhi-main{display:flex;flex-direction:column;gap:4px;min-width:0}
|
|
658
|
+
.qt-fhi-dst{font-family:var(--qt-zh-serif);font-size:15px;line-height:1.55;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;word-break:break-word;white-space:pre-line}
|
|
659
|
+
.qt-fhi-dst[data-lang="en"]{font-family:var(--qt-en-serif)}
|
|
660
|
+
.qt-fhi-src{font-size:12.5px;color:var(--qt-f-mute);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
661
|
+
.qt-fhi-meta{display:flex;flex-direction:column;align-items:flex-end;gap:3px;font-size:11.5px;color:var(--qt-f-mute);padding-top:3px;white-space:nowrap;overflow:hidden;min-width:0}
|
|
662
|
+
.qt-fhi-meta span{max-width:100%;overflow:hidden;text-overflow:ellipsis}
|
|
663
|
+
.qt-fhi-wrap:hover .qt-fhi-meta{visibility:hidden}
|
|
664
|
+
.qt-fhi-del{position:absolute;right:12px;top:14px;width:26px;height:26px;border-radius:8px;display:grid;place-items:center;color:var(--qt-f-mute);background:var(--qt-f-base);opacity:0;pointer-events:none}
|
|
665
|
+
.qt-fhi-wrap:hover .qt-fhi-del,.qt-fhi-del:focus-visible{opacity:1;pointer-events:auto}
|
|
666
|
+
.qt-fhi-del:hover{color:var(--qt-f-err)}
|
|
667
|
+
.qt-fempty{padding:56px 12px;text-align:center;font-size:13px;line-height:1.8;color:var(--qt-f-mute);white-space:pre-line}
|
|
668
|
+
.qt-ffade-top,.qt-ffade-bot{position:absolute;left:0;right:0;pointer-events:none;z-index:3}
|
|
669
|
+
.qt-ffade-top{top:38px;height:36px;background:linear-gradient(var(--qt-f-ov),transparent)}
|
|
670
|
+
.qt-ffade-bot{bottom:0;height:64px;background:linear-gradient(transparent,var(--qt-f-ov))}
|
|
671
|
+
.qt-fthumb{position:absolute;right:8px;top:10px;bottom:10px;width:4px;pointer-events:none;z-index:4}
|
|
672
|
+
.qt-fthumb i{position:absolute;left:0;right:0;border-radius:2px;background:var(--qt-f-b2)}
|
|
673
|
+
.qt-fhist-foot{display:flex;align-items:center;justify-content:space-between;gap:12px;height:65px;padding:0 28px 4px 26px;border-top:1px solid var(--qt-f-b1);flex:none;font-size:12px;color:var(--qt-f-mute);white-space:nowrap}
|
|
674
|
+
.qt-fhist-foot > span{overflow:hidden;text-overflow:ellipsis;min-width:0}
|
|
675
|
+
.qt-fhist-clear{height:34px;padding:0 10px;border-radius:9px;font-size:13px;color:var(--qt-f-mute);flex:none}
|
|
676
|
+
.qt-fhist-clear:hover{background:var(--qt-f-l2);color:var(--qt-f-ink)}
|
|
677
|
+
.qt-fhist-clear.is-armed{color:var(--qt-f-err)}
|
|
678
|
+
|
|
679
|
+
/* 色场:没有模型 */
|
|
680
|
+
.qt-fempty-card{max-width:440px;margin:24px;padding:32px 36px;border-radius:28px;background:var(--qt-f-l1);box-shadow:inset 0 0 0 1px var(--qt-f-b1);display:flex;flex-direction:column;align-items:flex-start;gap:14px}
|
|
681
|
+
.qt-fempty-card b{font-size:18px;font-weight:600}
|
|
682
|
+
.qt-fempty-card p{margin:0;font-size:13.5px;line-height:1.7;color:var(--qt-f-mute);white-space:pre-line}
|
|
683
|
+
.qt-fempty-card .qt-fgo{padding:0 20px}
|
|
684
|
+
|
|
685
|
+
/* 分享浮层在色场下的按钮 */
|
|
686
|
+
.qt-fsbtn{height:44px;padding:0 22px;border-radius:14px;font-size:14.5px;font-weight:600;white-space:nowrap}
|
|
687
|
+
.qt-fsbtn-primary{background:var(--qt-f-brand);color:#fff}
|
|
688
|
+
.qt-fsbtn-secondary{background:#fff;color:#1d1d22}
|
|
689
|
+
.qt-fsbtn:disabled{opacity:.45}
|
|
690
|
+
.qt-share-bar .qt-fhb{color:#e6e3dc}
|
|
691
|
+
.qt-share-bar .qt-fhb:hover{background:rgba(255,255,255,.12);color:#fff}
|
|
692
|
+
|
|
693
|
+
/* 色场窄面板(< 760):上下叠放、不缩放,尺寸照画板「F 色场 · 窄面板 440」 */
|
|
694
|
+
.qt-fhead.is-narrow{height:calc(56px + var(--dsh-frame-top-clearance,0px));gap:6px;padding-right:12px;padding-left:calc(16px + var(--dsh-frame-leading-clearance,0px))}
|
|
695
|
+
.qt-fhead.is-narrow .qt-ftitle{font-size:15px;margin-right:auto}
|
|
696
|
+
.qt-fhead.is-narrow .qt-fsub{display:none}
|
|
697
|
+
.qt-fhead.is-narrow .qt-ftrack button{padding:0 10px;gap:6px}
|
|
698
|
+
.qt-fhead.is-narrow .qt-fhb{padding:0 10px;gap:6px}
|
|
699
|
+
.qt-fboard.is-narrow{align-items:flex-start;overflow-y:auto}
|
|
700
|
+
.qt-fcomp.is-narrow{width:100%;height:auto;padding:0 16px 16px;display:flex;flex-direction:column}
|
|
701
|
+
.qt-fcomp.is-narrow .qt-fbox,.qt-fcomp.is-narrow .qt-fhist{position:relative;left:auto;top:auto;width:auto;flex:none;border-radius:24px}
|
|
702
|
+
.qt-fcomp.is-narrow .qt-fsrc{height:360px;padding:22px 22px 18px 24px}
|
|
703
|
+
.qt-fcomp.is-narrow .qt-ffield{height:452px;padding:30px 22px 18px 24px}
|
|
704
|
+
.qt-fcomp.is-narrow .qt-fhist{height:452px}
|
|
705
|
+
.qt-fcomp.is-narrow .qt-frow{height:34px;gap:10px}
|
|
706
|
+
.qt-fcomp.is-narrow .qt-flang{font-size:24px}
|
|
707
|
+
.qt-fcomp.is-narrow .qt-fsrc .qt-fhint{display:none}
|
|
708
|
+
.qt-fcomp.is-narrow .qt-fsrc .qt-frow .qt-ftrack{margin-left:auto}
|
|
709
|
+
.qt-fcomp.is-narrow .qt-ftrack button{padding:0 10px}
|
|
710
|
+
.qt-fcomp.is-narrow .qt-fta{margin-top:18px}
|
|
711
|
+
.qt-fcomp.is-narrow .qt-fsrc .qt-fta{font-size:16px;line-height:1.7}
|
|
712
|
+
.qt-fcomp.is-narrow .qt-fres{font-size:21px}
|
|
713
|
+
.qt-fcomp.is-narrow .qt-fwait{inset:18px 0 0}
|
|
714
|
+
.qt-fcomp.is-narrow .qt-fwait b{font-size:36px}
|
|
715
|
+
.qt-fcomp.is-narrow .qt-fwm{font-size:340px;right:-40px;bottom:-96px}
|
|
716
|
+
.qt-fcomp.is-narrow .qt-fstats{gap:14px;padding-bottom:10px}
|
|
717
|
+
.qt-fcomp.is-narrow .qt-ffoot{height:44px;gap:4px}
|
|
718
|
+
.qt-fcomp.is-narrow .qt-fclear{padding:0 14px}
|
|
719
|
+
.qt-fcomp.is-narrow .qt-fgo{padding-left:18px;gap:10px}
|
|
720
|
+
.qt-fcomp.is-narrow .qt-fpick-btn{padding:0 12px;gap:6px;font-size:13px}
|
|
721
|
+
.qt-fcomp.is-narrow .qt-fpick-k{display:none}
|
|
722
|
+
.qt-fcomp.is-narrow .qt-flink{padding:0 10px;font-size:13px}
|
|
723
|
+
.qt-fcomp.is-narrow .qt-fcopy{padding:0 16px;font-size:13px}
|
|
724
|
+
.qt-fcomp.is-narrow .qt-fswap{position:relative;left:auto;top:auto;align-self:center;margin:-16px 0;width:48px;height:48px;flex:none}
|
|
725
|
+
.qt-fcomp.is-narrow .qt-fswap svg{transform:rotate(90deg)}
|
|
726
|
+
.qt-fcomp.is-narrow .qt-fmenu{width:min(336px,calc(100vw - 72px))}
|
|
727
|
+
.qt-fcomp.is-narrow .qt-fhist-head{height:58px;padding:22px 16px 0 20px;gap:8px}
|
|
728
|
+
.qt-fcomp.is-narrow .qt-fhist-head > span{display:none}
|
|
729
|
+
.qt-fcomp.is-narrow .qt-fhist-search{flex:1;width:auto}
|
|
730
|
+
.qt-fcomp.is-narrow .qt-fhist-rule{margin-top:14px}
|
|
731
|
+
.qt-fcomp.is-narrow .qt-fhist-list{padding:0 16px 20px 10px}
|
|
732
|
+
.qt-fcomp.is-narrow .qt-fhi{grid-template-columns:40px minmax(0,1fr);column-gap:10px}
|
|
733
|
+
.qt-fcomp.is-narrow .qt-fhi-meta{display:none}
|
|
734
|
+
.qt-fcomp.is-narrow .qt-fhist-foot{height:56px;padding:0 20px 2px 14px}
|
|
487
735
|
@media (prefers-reduced-motion:reduce){.qt-root *,.qt-root *::before,.qt-root *::after{animation:none!important;transition:none!important}}
|
|
488
736
|
`
|
|
489
737
|
|
|
@@ -709,6 +957,17 @@ window.__ModuleLoader__.load({
|
|
|
709
957
|
)
|
|
710
958
|
}
|
|
711
959
|
|
|
960
|
+
// 色场风格用的几枚线条图标(纸本风格不用)
|
|
961
|
+
const icon = (size, ...d) => h('svg', { ...svgProps, width: size, height: size, viewBox: '0 0 24 24', strokeWidth: 2 }, ...P(...d))
|
|
962
|
+
const SwapIcon = () => icon(18, 'm16 3 4 4-4 4', 'M20 7H4', 'm8 21-4-4 4-4', 'M4 17h16')
|
|
963
|
+
const RefreshIcon = () => icon(15, 'M21 12a9 9 0 1 1-3-6.7L21 8', 'M21 3v5h-5')
|
|
964
|
+
const SearchIcon = () => h('svg', { ...svgProps, width: 14, height: 14, viewBox: '0 0 24 24', strokeWidth: 2 }, h('circle', { cx: 11, cy: 11, r: 7 }), h('path', { d: 'm20 20-3.5-3.5' }))
|
|
965
|
+
const CloseIcon = ({ size = 14 }) => h('svg', { ...svgProps, width: size, height: size, viewBox: '0 0 24 24', strokeWidth: 2.3 }, h('path', { d: 'M6 6l12 12M18 6 6 18' }))
|
|
966
|
+
const CheckIcon = () => h('svg', { ...svgProps, width: 16, height: 16, viewBox: '0 0 24 24', strokeWidth: 2.6 }, h('path', { d: 'm5 12.5 4.5 4.5L19 7' }))
|
|
967
|
+
const ChevronIcon = () => h('svg', { ...svgProps, width: 12, height: 12, viewBox: '0 0 24 24', strokeWidth: 2.4 }, h('path', { d: 'm6 9 6 6 6-6' }))
|
|
968
|
+
// 语言在色场里用它自己的名字写:English / 中文
|
|
969
|
+
const nativeName = (code) => (code === 'en' ? 'English' : '中文')
|
|
970
|
+
|
|
712
971
|
const MONTHS = ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC']
|
|
713
972
|
const pad2 = (n) => String(n).padStart(2, '0')
|
|
714
973
|
const fmtClock = (ts) => { const d = new Date(ts); return `${pad2(d.getHours())}:${pad2(d.getMinutes())}` }
|
|
@@ -1055,15 +1314,154 @@ window.__ModuleLoader__.load({
|
|
|
1055
1314
|
return new Promise((resolve) => canvas.toBlob((b) => resolve(b), 'image/png'))
|
|
1056
1315
|
}
|
|
1057
1316
|
|
|
1317
|
+
// 色场风格的分享卡片:白底,上面一块浅灰圆角(原文),下面一整块品牌色圆角(译文 + 超大「文」),照画板「F 色场 · 分享卡片」540 宽 ×2
|
|
1318
|
+
async function renderFieldShareCard({ source, result, target, modelName, elapsedMs, t, brand }) {
|
|
1319
|
+
try {
|
|
1320
|
+
await document.fonts?.ready
|
|
1321
|
+
} catch {
|
|
1322
|
+
/* 字体没就绪就用回退字体画 */
|
|
1323
|
+
}
|
|
1324
|
+
const F = { ...SHARE_FONTS, ui: '-apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif' }
|
|
1325
|
+
const W = 1080
|
|
1326
|
+
const S = 2
|
|
1327
|
+
const toZh = target !== 'en'
|
|
1328
|
+
const blue = brand || '#4d6bfe'
|
|
1329
|
+
const measure = document.createElement('canvas').getContext('2d')
|
|
1330
|
+
const padX = 64
|
|
1331
|
+
const innerW = W - padX * 2
|
|
1332
|
+
|
|
1333
|
+
// 原文卡
|
|
1334
|
+
const srcFont = `400 29px ${F.ui}`
|
|
1335
|
+
measure.font = srcFont
|
|
1336
|
+
const src = wrapLines(measure, source, innerW - 96, 7)
|
|
1337
|
+
const srcLH = 49
|
|
1338
|
+
const srcY = 160
|
|
1339
|
+
const srcH = 44 + 40 + 24 + src.lines.length * srcLH + 40
|
|
1340
|
+
|
|
1341
|
+
// 译文卡:字号随长度在 42 → 32 之间收
|
|
1342
|
+
let size = 42
|
|
1343
|
+
let dst = null
|
|
1344
|
+
for (; size >= 32; size -= 2) {
|
|
1345
|
+
measure.font = toZh ? `600 ${size}px ${F.zhSerif}` : `500 ${size}px ${F.enSerif}`
|
|
1346
|
+
dst = wrapLines(measure, result, innerW - 104, 12)
|
|
1347
|
+
if (!dst.truncated && dst.lines.length <= 9) break
|
|
1348
|
+
}
|
|
1349
|
+
size = Math.max(size, 32)
|
|
1350
|
+
const dstFont = toZh ? `600 ${size}px ${F.zhSerif}` : `500 ${size}px ${F.enSerif}`
|
|
1351
|
+
const dstLH = Math.round(size * (toZh ? 1.8 : 1.55))
|
|
1352
|
+
const fieldY = srcY + srcH + 28
|
|
1353
|
+
const fieldH = Math.max(520, 48 + 40 + 28 + dst.lines.length * dstLH + 44 + 52 + 44)
|
|
1354
|
+
const H = fieldY + fieldH + 28 + 22 + 52
|
|
1355
|
+
|
|
1356
|
+
const canvas = document.createElement('canvas')
|
|
1357
|
+
canvas.width = W * S
|
|
1358
|
+
canvas.height = H * S
|
|
1359
|
+
const ctx = canvas.getContext('2d')
|
|
1360
|
+
ctx.scale(S, S)
|
|
1361
|
+
ctx.textBaseline = 'alphabetic'
|
|
1362
|
+
const round = (x, y, w, hh, r) => {
|
|
1363
|
+
ctx.beginPath()
|
|
1364
|
+
ctx.moveTo(x + r, y)
|
|
1365
|
+
ctx.arcTo(x + w, y, x + w, y + hh, r)
|
|
1366
|
+
ctx.arcTo(x + w, y + hh, x, y + hh, r)
|
|
1367
|
+
ctx.arcTo(x, y + hh, x, y, r)
|
|
1368
|
+
ctx.arcTo(x, y, x + w, y, r)
|
|
1369
|
+
ctx.closePath()
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
ctx.fillStyle = '#ffffff'
|
|
1373
|
+
ctx.fillRect(0, 0, W, H)
|
|
1374
|
+
|
|
1375
|
+
// 头部
|
|
1376
|
+
ctx.fillStyle = '#1d1d22'
|
|
1377
|
+
ctx.font = `700 38px ${F.ui}`
|
|
1378
|
+
ctx.fillText('Quick Translate', padX + 8, 112)
|
|
1379
|
+
const titleW = ctx.measureText('Quick Translate').width
|
|
1380
|
+
ctx.font = `400 22px ${F.ui}`
|
|
1381
|
+
ctx.fillStyle = '#6c6c75'
|
|
1382
|
+
ctx.fillText(`${t.title} · DSH Plugin · by ${AUTHOR}`, padX + 8 + titleW + 20, 112)
|
|
1383
|
+
ctx.textAlign = 'right'
|
|
1384
|
+
ctx.font = `400 24px ${F.ui}`
|
|
1385
|
+
ctx.fillText(toZh ? t.en2zh : t.zh2en, W - padX - 8, 112)
|
|
1386
|
+
ctx.textAlign = 'left'
|
|
1387
|
+
|
|
1388
|
+
// 原文卡
|
|
1389
|
+
round(padX, srcY, innerW, srcH, 40)
|
|
1390
|
+
ctx.fillStyle = '#f6f6f8'
|
|
1391
|
+
ctx.fill()
|
|
1392
|
+
ctx.strokeStyle = '#e9e9ee'
|
|
1393
|
+
ctx.lineWidth = 2
|
|
1394
|
+
ctx.stroke()
|
|
1395
|
+
const sx = padX + 48
|
|
1396
|
+
ctx.fillStyle = '#1d1d22'
|
|
1397
|
+
ctx.font = toZh ? `italic 400 40px ${F.enSerif}` : `600 40px ${F.zhSerif}`
|
|
1398
|
+
ctx.fillText(nativeName(toZh ? 'en' : 'zh'), sx, srcY + 44 + 32)
|
|
1399
|
+
ctx.font = srcFont
|
|
1400
|
+
src.lines.forEach((ln, i) => ctx.fillText(ln, sx, srcY + 44 + 40 + 24 + 22 + i * srcLH))
|
|
1401
|
+
|
|
1402
|
+
// 译文卡
|
|
1403
|
+
ctx.save()
|
|
1404
|
+
round(padX, fieldY, innerW, fieldH, 40)
|
|
1405
|
+
ctx.fillStyle = blue
|
|
1406
|
+
ctx.fill()
|
|
1407
|
+
ctx.clip()
|
|
1408
|
+
ctx.fillStyle = 'rgba(255,255,255,0.08)'
|
|
1409
|
+
ctx.textAlign = 'right'
|
|
1410
|
+
ctx.font = toZh ? `600 600px ${F.zhSerif}` : `500 640px ${F.enSerif}`
|
|
1411
|
+
ctx.fillText(toZh ? '文' : 'A', padX + innerW + 68, fieldY + fieldH + 120)
|
|
1412
|
+
ctx.textAlign = 'left'
|
|
1413
|
+
const fx = padX + 52
|
|
1414
|
+
ctx.fillStyle = '#ffffff'
|
|
1415
|
+
ctx.font = toZh ? `600 40px ${F.zhSerif}` : `italic 400 40px ${F.enSerif}`
|
|
1416
|
+
const lname = nativeName(toZh ? 'zh' : 'en')
|
|
1417
|
+
ctx.fillText(lname, fx, fieldY + 48 + 32)
|
|
1418
|
+
const lw = ctx.measureText(lname).width
|
|
1419
|
+
ctx.font = `400 23px ${F.ui}`
|
|
1420
|
+
ctx.fillStyle = 'rgba(255,255,255,0.86)'
|
|
1421
|
+
ctx.fillText(elapsedMs ? `${t.done} · ${fmtElapsed(elapsedMs, t)}` : t.done, fx + lw + 20, fieldY + 48 + 30)
|
|
1422
|
+
ctx.fillStyle = '#ffffff'
|
|
1423
|
+
ctx.font = dstFont
|
|
1424
|
+
const dy0 = fieldY + 48 + 40 + 28 + size
|
|
1425
|
+
dst.lines.forEach((ln, i) => ctx.fillText(ln, fx, dy0 + i * dstLH))
|
|
1426
|
+
// 底部:模型胶囊 + 日期
|
|
1427
|
+
const by = fieldY + fieldH - 44 - 52
|
|
1428
|
+
ctx.font = `600 24px ${F.ui}`
|
|
1429
|
+
const mn = modelName || '—'
|
|
1430
|
+
const mw = Math.min(ctx.measureText(mn).width, innerW - 104 - 260)
|
|
1431
|
+
round(fx, by, mw + 40, 52, 18)
|
|
1432
|
+
ctx.fillStyle = 'rgba(255,255,255,0.16)'
|
|
1433
|
+
ctx.fill()
|
|
1434
|
+
ctx.fillStyle = '#ffffff'
|
|
1435
|
+
ctx.fillText(mn, fx + 20, by + 34, mw)
|
|
1436
|
+
const now = new Date()
|
|
1437
|
+
ctx.textAlign = 'right'
|
|
1438
|
+
ctx.font = `400 24px ${F.ui}`
|
|
1439
|
+
ctx.fillStyle = 'rgba(255,255,255,0.86)'
|
|
1440
|
+
ctx.fillText(`${now.getFullYear()}.${pad2(now.getMonth() + 1)}.${pad2(now.getDate())}`, padX + innerW - 52, by + 34)
|
|
1441
|
+
ctx.textAlign = 'left'
|
|
1442
|
+
ctx.restore()
|
|
1443
|
+
|
|
1444
|
+
// 页脚
|
|
1445
|
+
ctx.fillStyle = '#9a9aa4'
|
|
1446
|
+
ctx.font = `400 22px ${F.ui}`
|
|
1447
|
+
ctx.fillText('Made with DeepSeek Harness', padX + 8, H - 52)
|
|
1448
|
+
ctx.textAlign = 'right'
|
|
1449
|
+
ctx.fillText('dsh-quick-translate', W - padX - 8, H - 52)
|
|
1450
|
+
ctx.textAlign = 'left'
|
|
1451
|
+
|
|
1452
|
+
return new Promise((resolve) => canvas.toBlob((b) => resolve(b), 'image/png'))
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1058
1455
|
/** 分享:生成卡片 → 预览 → 复制图片 / 保存图片。浮层画在面板自己里面,不往 body 挂东西。 */
|
|
1059
1456
|
function ShareSheet({ data, t, onClose }) {
|
|
1060
1457
|
const [url, setUrl] = useState('')
|
|
1061
1458
|
const [blob, setBlob] = useState(null)
|
|
1062
1459
|
const [msg, setMsg] = useState('')
|
|
1460
|
+
const field = data.skin === 'field'
|
|
1063
1461
|
useEffect(() => {
|
|
1064
1462
|
let alive = true
|
|
1065
1463
|
let made = ''
|
|
1066
|
-
renderShareCard(data)
|
|
1464
|
+
;(data.skin === 'field' ? renderFieldShareCard : renderShareCard)(data)
|
|
1067
1465
|
.then((b) => {
|
|
1068
1466
|
if (!alive || !b) return
|
|
1069
1467
|
made = URL.createObjectURL(b)
|
|
@@ -1107,14 +1505,34 @@ window.__ModuleLoader__.load({
|
|
|
1107
1505
|
h(
|
|
1108
1506
|
'div',
|
|
1109
1507
|
{ className: 'qt-share-bar' },
|
|
1110
|
-
h('button', { type: 'button', className: 'qt-tapebtn qt-go qt-btn-primary', onClick: copy, disabled: !blob }, t.shareCopy),
|
|
1111
|
-
h('button', { type: 'button', className: 'qt-tapebtn qt-clear', onClick: save, disabled: !url }, t.shareSave),
|
|
1112
|
-
h('button', { type: 'button', className: 'qt-hbtn', onClick: onClose }, t.shareClose),
|
|
1508
|
+
h('button', { type: 'button', className: field ? 'qt-fsbtn qt-fsbtn-primary' : 'qt-tapebtn qt-go qt-btn-primary', onClick: copy, disabled: !blob }, t.shareCopy),
|
|
1509
|
+
h('button', { type: 'button', className: field ? 'qt-fsbtn qt-fsbtn-secondary' : 'qt-tapebtn qt-clear', onClick: save, disabled: !url }, t.shareSave),
|
|
1510
|
+
h('button', { type: 'button', className: field ? 'qt-fhb' : 'qt-hbtn', onClick: onClose }, t.shareClose),
|
|
1113
1511
|
url && msg ? h('span', { className: 'qt-share-msg', role: 'status' }, msg) : null,
|
|
1114
1512
|
),
|
|
1115
1513
|
)
|
|
1116
1514
|
}
|
|
1117
1515
|
|
|
1516
|
+
// 解析主题 token 的颜色值(#rgb / #rrggbb / rgb()),算相对亮度判断明暗;解析不了就看系统偏好
|
|
1517
|
+
function isDarkColor(value) {
|
|
1518
|
+
const v = String(value || '').trim()
|
|
1519
|
+
let rgb = null
|
|
1520
|
+
const hex = v.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i)
|
|
1521
|
+
if (hex) {
|
|
1522
|
+
const x = hex[1].length === 3 ? hex[1].replace(/./g, '$&$&') : hex[1]
|
|
1523
|
+
rgb = [0, 2, 4].map((i) => parseInt(x.slice(i, i + 2), 16))
|
|
1524
|
+
} else {
|
|
1525
|
+
const m = v.match(/rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/i)
|
|
1526
|
+
if (m) rgb = [m[1], m[2], m[3]].map(Number)
|
|
1527
|
+
}
|
|
1528
|
+
if (!rgb) return Boolean(window.matchMedia?.('(prefers-color-scheme: dark)').matches)
|
|
1529
|
+
const [r, g, b] = rgb.map((c) => {
|
|
1530
|
+
const k = c / 255
|
|
1531
|
+
return k <= 0.03928 ? k / 12.92 : ((k + 0.055) / 1.055) ** 2.4
|
|
1532
|
+
})
|
|
1533
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b < 0.3
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1118
1536
|
// 文本框的刻度尺:内容超出时才出现,实心段表示当前位置
|
|
1119
1537
|
function thumbOf(el) {
|
|
1120
1538
|
if (!el || !el.scrollHeight) return null
|
|
@@ -1129,7 +1547,14 @@ window.__ModuleLoader__.load({
|
|
|
1129
1547
|
/* ============================== 组件 ================================ */
|
|
1130
1548
|
|
|
1131
1549
|
/** 模型选择:硫酸纸底部的一行字,点开是一张索引卡(absolute 锚在按钮上方,不受祖先 transform 影响)。 */
|
|
1132
|
-
|
|
1550
|
+
// 两种风格共用一套逻辑,只换类名和图形
|
|
1551
|
+
const PICKER_CLS = {
|
|
1552
|
+
paper: { root: 'qt-picker', btn: 'qt-picker-btn', label: 'qt-picker-label', tag: 'qt-picker-tag', menu: 'qt-picker-menu', head: 'qt-picker-head', group: 'qt-picker-group-title', item: 'qt-picker-item', empty: 'qt-picker-empty' },
|
|
1553
|
+
field: { root: 'qt-fpick', btn: 'qt-fpick-btn', label: 'qt-fpick-label', tag: 'qt-fpick-tag', menu: 'qt-fmenu', head: 'qt-fmenu-head', group: 'qt-fmg', item: 'qt-fmi', empty: 'qt-fmenu-empty' },
|
|
1554
|
+
}
|
|
1555
|
+
function ModelPicker({ groups, defaultRoute, value, onChange, loading, disabled, t, skin }) {
|
|
1556
|
+
const field = skin === 'field'
|
|
1557
|
+
const C = PICKER_CLS[field ? 'field' : 'paper']
|
|
1133
1558
|
const [open, setOpen] = useState(false)
|
|
1134
1559
|
const btnRef = useRef(null)
|
|
1135
1560
|
const menuRef = useRef(null)
|
|
@@ -1178,39 +1603,39 @@ window.__ModuleLoader__.load({
|
|
|
1178
1603
|
const item = (key, name, id) =>
|
|
1179
1604
|
h(
|
|
1180
1605
|
'button',
|
|
1181
|
-
{ type: 'button', key: key || '__default', className:
|
|
1182
|
-
h('span', { className: 'qt-check' }, h(TickMark)),
|
|
1606
|
+
{ type: 'button', key: key || '__default', className: C.item, role: 'option', 'aria-selected': value === key ? 'true' : 'false', onClick: () => pick(key) },
|
|
1607
|
+
h('span', { className: 'qt-check' }, field ? h(CheckIcon) : h(TickMark)),
|
|
1183
1608
|
h('span', { className: 'qt-name' }, name),
|
|
1184
1609
|
id && id !== name ? h('span', { className: 'qt-id' }, id) : null,
|
|
1185
1610
|
)
|
|
1186
1611
|
|
|
1187
1612
|
return h(
|
|
1188
1613
|
'div',
|
|
1189
|
-
{ className:
|
|
1614
|
+
{ className: C.root },
|
|
1190
1615
|
h(
|
|
1191
1616
|
'button',
|
|
1192
|
-
{ ref: btnRef, type: 'button', className:
|
|
1193
|
-
h('span',
|
|
1194
|
-
h('span', { className:
|
|
1195
|
-
!selected && defaultRoute ? h('span', { className:
|
|
1196
|
-
h('span', { className: 'qt-chev', 'aria-hidden': true }, '▾'),
|
|
1617
|
+
{ ref: btnRef, type: 'button', className: C.btn, onClick: toggle, disabled: disabled || loading, 'aria-haspopup': 'listbox', 'aria-expanded': open ? 'true' : 'false', title: !selected && defaultRoute ? `${t.followDefault} · ${label}` : label },
|
|
1618
|
+
h('span', { className: field ? 'qt-fpick-k' : undefined }, field ? t.model : `${t.model}:`),
|
|
1619
|
+
h('span', { className: C.label }, label),
|
|
1620
|
+
!selected && defaultRoute ? h('span', { className: C.tag }, field ? `(${t.defaultShort})` : `[${t.defaultShort}]`) : null,
|
|
1621
|
+
field ? h(ChevronIcon) : h('span', { className: 'qt-chev', 'aria-hidden': true }, '▾'),
|
|
1197
1622
|
),
|
|
1198
1623
|
open
|
|
1199
1624
|
? h(
|
|
1200
1625
|
'div',
|
|
1201
|
-
{ ref: menuRef, className:
|
|
1202
|
-
h('div', { className:
|
|
1626
|
+
{ ref: menuRef, className: C.menu, role: 'listbox', 'aria-label': t.selectModel },
|
|
1627
|
+
h('div', { className: C.head }, h('b', null, field ? t.selectModel : t.model), h('span', null, t.modelCount(total))),
|
|
1203
1628
|
defaultRoute ? item('', `${t.followDefault}`, defaultRoute.model) : null,
|
|
1204
1629
|
groups.map((g) =>
|
|
1205
1630
|
h(
|
|
1206
1631
|
'div',
|
|
1207
1632
|
{ key: g.provider },
|
|
1208
|
-
h('div', { className:
|
|
1633
|
+
h('div', { className: C.group }, g.name),
|
|
1209
1634
|
g.models.map((m) => item(modelKey(m), m.name || m.model, m.model)),
|
|
1210
1635
|
),
|
|
1211
1636
|
),
|
|
1212
|
-
loading ? h('div', { className:
|
|
1213
|
-
!loading && groups.length === 0 && !defaultRoute ? h('div', { className:
|
|
1637
|
+
loading ? h('div', { className: C.empty }, t.loadingModels) : null,
|
|
1638
|
+
!loading && groups.length === 0 && !defaultRoute ? h('div', { className: C.empty }, t.selectModel) : null,
|
|
1214
1639
|
)
|
|
1215
1640
|
: null,
|
|
1216
1641
|
)
|
|
@@ -1307,6 +1732,92 @@ window.__ModuleLoader__.load({
|
|
|
1307
1732
|
)
|
|
1308
1733
|
}
|
|
1309
1734
|
|
|
1735
|
+
/** 色场的历史:和译文容器一样大的一张卡,盖在译文的位置上。头尾固定,中间单独滚动;日期吸顶,上下渐隐,右侧细滚动条。 */
|
|
1736
|
+
function FieldHistory({ history, currentId, query, onQuery, onPick, onDelete, onClear, onClose, clearArmed, t, lang }) {
|
|
1737
|
+
const [scroll, setScroll] = useState({ top: 0, size: 100, atTop: true, atEnd: true })
|
|
1738
|
+
const listRef = useRef(null)
|
|
1739
|
+
const q = query.trim().toLowerCase()
|
|
1740
|
+
const shown = q
|
|
1741
|
+
? history.filter((e) => e.source.toLowerCase().includes(q) || e.result.toLowerCase().includes(q) || e.modelName.toLowerCase().includes(q))
|
|
1742
|
+
: history
|
|
1743
|
+
const measure = (el) => {
|
|
1744
|
+
if (!el) return
|
|
1745
|
+
const room = el.scrollHeight - el.clientHeight
|
|
1746
|
+
const size = el.scrollHeight > 0 ? Math.min(100, (el.clientHeight / el.scrollHeight) * 100) : 100
|
|
1747
|
+
setScroll({ top: room > 0 ? (el.scrollTop / room) * (100 - size) : 0, size, atTop: el.scrollTop <= 2, atEnd: room - el.scrollTop <= 2 })
|
|
1748
|
+
}
|
|
1749
|
+
useEffect(() => measure(listRef.current), [shown.length])
|
|
1750
|
+
const rows = []
|
|
1751
|
+
let lastDay = ''
|
|
1752
|
+
for (const e of shown) {
|
|
1753
|
+
const d = dayLabel(e.at, t, lang)
|
|
1754
|
+
if (d !== lastDay) {
|
|
1755
|
+
rows.push(h('div', { key: `d-${e.id}`, className: 'qt-fhday' }, d))
|
|
1756
|
+
lastDay = d
|
|
1757
|
+
}
|
|
1758
|
+
rows.push(
|
|
1759
|
+
h(
|
|
1760
|
+
'div',
|
|
1761
|
+
{ key: e.id, role: 'listitem', className: 'qt-fhi-wrap' },
|
|
1762
|
+
h(
|
|
1763
|
+
'button',
|
|
1764
|
+
{ type: 'button', className: 'qt-fhi', 'aria-current': e.id === currentId ? 'true' : 'false', onClick: () => onPick(e), title: e.source.slice(0, 200) },
|
|
1765
|
+
h('span', { className: 'qt-fhi-time' }, fmtClock(e.at)),
|
|
1766
|
+
h('span', { className: 'qt-fhi-main' }, h('span', { className: 'qt-fhi-dst', 'data-lang': e.target }, e.result), h('span', { className: 'qt-fhi-src' }, e.source)),
|
|
1767
|
+
h('span', { className: 'qt-fhi-meta' }, h('span', null, e.target === 'zh' ? t.en2zh : t.zh2en), e.modelName ? h('span', null, e.modelName) : null),
|
|
1768
|
+
),
|
|
1769
|
+
h(
|
|
1770
|
+
'button',
|
|
1771
|
+
{ type: 'button', className: 'qt-fhi-del', title: t.historyDelete, 'aria-label': t.historyDelete, onClick: (ev) => { ev.stopPropagation(); onDelete(e.id) } },
|
|
1772
|
+
h(CloseIcon, { size: 12 }),
|
|
1773
|
+
),
|
|
1774
|
+
),
|
|
1775
|
+
)
|
|
1776
|
+
}
|
|
1777
|
+
return h(
|
|
1778
|
+
'aside',
|
|
1779
|
+
{ className: 'qt-fhist', 'aria-label': t.history },
|
|
1780
|
+
h(
|
|
1781
|
+
'div',
|
|
1782
|
+
{ className: 'qt-fhist-head' },
|
|
1783
|
+
h('b', null, t.history),
|
|
1784
|
+
h('span', null, t.historyCount(history.length)),
|
|
1785
|
+
h(
|
|
1786
|
+
'label',
|
|
1787
|
+
{ className: 'qt-fhist-search' },
|
|
1788
|
+
h(SearchIcon),
|
|
1789
|
+
h('input', { type: 'search', value: query, placeholder: t.historySearch, onChange: (e) => onQuery(e.target.value), 'aria-label': t.historySearch, disabled: history.length === 0 }),
|
|
1790
|
+
),
|
|
1791
|
+
h('button', { type: 'button', className: 'qt-ficon', title: t.historyHide, 'aria-label': t.historyHide, onClick: onClose }, h(CloseIcon, { size: 15 })),
|
|
1792
|
+
),
|
|
1793
|
+
h('div', { className: 'qt-fhist-rule', 'aria-hidden': 'true' }),
|
|
1794
|
+
h(
|
|
1795
|
+
'div',
|
|
1796
|
+
{ className: 'qt-fhist-scroll' },
|
|
1797
|
+
h(
|
|
1798
|
+
'div',
|
|
1799
|
+
{ ref: listRef, className: 'qt-fhist-list', role: 'list', onScroll: (ev) => measure(ev.currentTarget) },
|
|
1800
|
+
history.length === 0
|
|
1801
|
+
? h('div', { className: 'qt-fempty' }, t.historyEmpty)
|
|
1802
|
+
: shown.length === 0
|
|
1803
|
+
? h('div', { className: 'qt-fempty' }, t.historyEmptyFiltered)
|
|
1804
|
+
: rows,
|
|
1805
|
+
),
|
|
1806
|
+
!scroll.atTop ? h('div', { className: 'qt-ffade-top', 'aria-hidden': 'true' }) : null,
|
|
1807
|
+
!scroll.atEnd ? h('div', { className: 'qt-ffade-bot', 'aria-hidden': 'true' }) : null,
|
|
1808
|
+
scroll.size < 100 ? h('div', { className: 'qt-fthumb', 'aria-hidden': 'true' }, h('i', { style: { top: `${scroll.top}%`, height: `${scroll.size}%` } })) : null,
|
|
1809
|
+
),
|
|
1810
|
+
h(
|
|
1811
|
+
'div',
|
|
1812
|
+
{ className: 'qt-fhist-foot' },
|
|
1813
|
+
history.length
|
|
1814
|
+
? h('button', { type: 'button', className: `qt-fhist-clear ${clearArmed ? 'is-armed' : ''}`, onClick: onClear }, clearArmed ? t.historyConfirm : t.historyClear)
|
|
1815
|
+
: h('span'),
|
|
1816
|
+
h('span', null, t.historyKeep),
|
|
1817
|
+
),
|
|
1818
|
+
)
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1310
1821
|
function TranslatePanel() {
|
|
1311
1822
|
const lang = useLang()
|
|
1312
1823
|
const t = STR[lang] || STR.en
|
|
@@ -1339,6 +1850,10 @@ window.__ModuleLoader__.load({
|
|
|
1339
1850
|
const [copied, setCopied] = useState(false)
|
|
1340
1851
|
const [copyFailed, setCopyFailed] = useState(false)
|
|
1341
1852
|
const [shareData, setShareData] = useState(null)
|
|
1853
|
+
// 界面风格:paper = E 纸本(默认),field = F 色场(简洁版);记在偏好里
|
|
1854
|
+
const [skin, setSkin] = useState(prefs.skin === 'field' ? 'field' : 'paper')
|
|
1855
|
+
const [tone, setTone] = useState('light')
|
|
1856
|
+
const rootRef = useRef(null)
|
|
1342
1857
|
const boardRef = useRef(null)
|
|
1343
1858
|
// 桌面按画板 E 的 1200×690 原样搭好,再整体缩放到面板大小;面板窄于 760 时改成上下叠放、不缩放
|
|
1344
1859
|
const [fit, setFit] = useState({ scale: 1, narrow: window.innerWidth < 760 })
|
|
@@ -1349,14 +1864,35 @@ window.__ModuleLoader__.load({
|
|
|
1349
1864
|
const w = el.clientWidth
|
|
1350
1865
|
const hh = el.clientHeight
|
|
1351
1866
|
const narrow = w < 760
|
|
1352
|
-
const scale = narrow
|
|
1867
|
+
const scale = narrow
|
|
1868
|
+
? 1
|
|
1869
|
+
: skin === 'field'
|
|
1870
|
+
? Math.max(0.55, Math.min(FIELD_MAX_ZOOM, w / FIELD_W, hh / FIELD_H))
|
|
1871
|
+
: Math.max(0.55, Math.min(1.6, (w - 16) / COMP_W, (hh - 8) / COMP_H))
|
|
1353
1872
|
setFit((p) => (p.narrow === narrow && Math.abs(p.scale - scale) < 0.004 ? p : { scale, narrow }))
|
|
1354
1873
|
}
|
|
1355
1874
|
const ro = new ResizeObserver(measure)
|
|
1356
1875
|
ro.observe(el)
|
|
1357
1876
|
measure()
|
|
1358
1877
|
return () => ro.disconnect()
|
|
1359
|
-
}, [])
|
|
1878
|
+
}, [skin])
|
|
1879
|
+
// 色场的颜色跟 DSH 主题走:读 --dsw-alias-bg-base 判断明暗,暗色下品牌色场压暗一些,白字才清楚
|
|
1880
|
+
useEffect(() => {
|
|
1881
|
+
if (skin !== 'field') return undefined
|
|
1882
|
+
const el = rootRef.current
|
|
1883
|
+
if (!el || typeof getComputedStyle !== 'function') return undefined
|
|
1884
|
+
const read = () => setTone(isDarkColor(getComputedStyle(el).getPropertyValue('--dsw-alias-bg-base')) ? 'dark' : 'light')
|
|
1885
|
+
read()
|
|
1886
|
+
const mo = typeof MutationObserver === 'function' ? new MutationObserver(read) : null
|
|
1887
|
+
mo?.observe(document.documentElement, { attributes: true })
|
|
1888
|
+
if (document.body) mo?.observe(document.body, { attributes: true })
|
|
1889
|
+
const mq = window.matchMedia?.('(prefers-color-scheme: dark)')
|
|
1890
|
+
mq?.addEventListener?.('change', read)
|
|
1891
|
+
return () => {
|
|
1892
|
+
mo?.disconnect()
|
|
1893
|
+
mq?.removeEventListener?.('change', read)
|
|
1894
|
+
}
|
|
1895
|
+
}, [skin])
|
|
1360
1896
|
const [srcThumb, setSrcThumb] = useState(null)
|
|
1361
1897
|
const [resThumb, setResThumb] = useState(null)
|
|
1362
1898
|
const rulerTimers = useRef({})
|
|
@@ -1383,7 +1919,7 @@ window.__ModuleLoader__.load({
|
|
|
1383
1919
|
const id = setTimeout(() => writeJson(DRAFT_KEY, { source, result }), 400)
|
|
1384
1920
|
return () => clearTimeout(id)
|
|
1385
1921
|
}, [source, result])
|
|
1386
|
-
useEffect(() => writeJson(PREFS_KEY, { modelKey: modelKeyState, direction, historyOpen }), [modelKeyState, direction, historyOpen])
|
|
1922
|
+
useEffect(() => writeJson(PREFS_KEY, { modelKey: modelKeyState, direction, historyOpen, skin }), [modelKeyState, direction, historyOpen, skin])
|
|
1387
1923
|
useEffect(() => writeJson(HISTORY_KEY, history), [history])
|
|
1388
1924
|
|
|
1389
1925
|
// 「确认清空」3 秒后自动撤回
|
|
@@ -1465,6 +2001,8 @@ window.__ModuleLoader__.load({
|
|
|
1465
2001
|
setUsedRoute({ provider: route.provider, model: route.model, name: route.name || route.model })
|
|
1466
2002
|
setUsedTarget(to)
|
|
1467
2003
|
setCurrentId(null)
|
|
2004
|
+
// 色场的历史卡盖在译文位置上,开始翻译就收起它,免得挡住译文
|
|
2005
|
+
if (skin === 'field') setHistoryOpen(false)
|
|
1468
2006
|
let acc = ''
|
|
1469
2007
|
try {
|
|
1470
2008
|
const done = await streamTranslate({
|
|
@@ -1520,7 +2058,7 @@ window.__ModuleLoader__.load({
|
|
|
1520
2058
|
} finally {
|
|
1521
2059
|
if (abortRef.current === controller) abortRef.current = null
|
|
1522
2060
|
}
|
|
1523
|
-
}, [source, direction, selected, defaultRoute, t])
|
|
2061
|
+
}, [source, direction, selected, defaultRoute, t, skin])
|
|
1524
2062
|
|
|
1525
2063
|
const onSourceKey = (event) => {
|
|
1526
2064
|
if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {
|
|
@@ -1533,7 +2071,7 @@ window.__ModuleLoader__.load({
|
|
|
1533
2071
|
const onKey = (event) => {
|
|
1534
2072
|
// 输入法组合中按 Esc 是在取消候选词,不是取消翻译;焦点在历史搜索框时也别响应
|
|
1535
2073
|
if (event.key !== 'Escape' || event.isComposing || event.keyCode === 229) return
|
|
1536
|
-
if (event.target?.closest?.('.qt-history-search')) return
|
|
2074
|
+
if (event.target?.closest?.('.qt-history-search, .qt-fhist-search')) return
|
|
1537
2075
|
if (!abortRef.current) return
|
|
1538
2076
|
event.preventDefault()
|
|
1539
2077
|
abortRef.current.abort()
|
|
@@ -1607,7 +2145,8 @@ window.__ModuleLoader__.load({
|
|
|
1607
2145
|
setCurrentId(e.id)
|
|
1608
2146
|
if (direction === 'en2zh' && e.target === 'en') setDirection('zh2en')
|
|
1609
2147
|
else if (direction === 'zh2en' && e.target === 'zh') setDirection('en2zh')
|
|
1610
|
-
|
|
2148
|
+
// 窄屏下顺手收起抽屉;色场的历史卡盖在译文上,回看时一律收起
|
|
2149
|
+
if (window.innerWidth <= 720 || skin === 'field') setHistoryOpen(false)
|
|
1611
2150
|
}
|
|
1612
2151
|
|
|
1613
2152
|
const deleteHistory = (id) => {
|
|
@@ -1664,6 +2203,185 @@ window.__ModuleLoader__.load({
|
|
|
1664
2203
|
|
|
1665
2204
|
const narrow = fit.narrow
|
|
1666
2205
|
const compStyle = narrow ? undefined : { zoom: fit.scale }
|
|
2206
|
+
// 分享卡片的数据:两种风格共用,色场多带一个品牌色
|
|
2207
|
+
const openShare = () => {
|
|
2208
|
+
let brand = ''
|
|
2209
|
+
try {
|
|
2210
|
+
brand = rootRef.current && typeof getComputedStyle === 'function' ? getComputedStyle(rootRef.current).getPropertyValue('--dsw-alias-brand-primary').trim() : ''
|
|
2211
|
+
} catch {
|
|
2212
|
+
brand = ''
|
|
2213
|
+
}
|
|
2214
|
+
setShareData({
|
|
2215
|
+
source,
|
|
2216
|
+
result,
|
|
2217
|
+
target: usedTarget || shownTarget || resolveTarget(direction, source),
|
|
2218
|
+
modelName: usedRoute?.name || usedRoute?.model || selected?.name || defaultRoute?.model || '',
|
|
2219
|
+
elapsedMs: status === 'done' ? elapsed : 0,
|
|
2220
|
+
t,
|
|
2221
|
+
skin,
|
|
2222
|
+
brand,
|
|
2223
|
+
})
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2226
|
+
if (skin === 'field') return fieldView()
|
|
2227
|
+
|
|
2228
|
+
/** F 色场:两块大圆角容器(素色原文 + 品牌色译文),坐标照画板 F(1200×696 工作区)。 */
|
|
2229
|
+
function fieldView() {
|
|
2230
|
+
// 原文那块写成哪种语言:有字或手动方向时按预测;空白自动时按画板写 English
|
|
2231
|
+
const srcLang = target ? (target === 'zh' ? 'en' : 'zh') : direction === 'zh2en' ? 'zh' : 'en'
|
|
2232
|
+
const dstLang = shownTarget || (direction === 'zh2en' ? 'en' : 'zh')
|
|
2233
|
+
const srcHint = streaming
|
|
2234
|
+
? h('span', { className: 'qt-fhint is-locked' }, t.fieldLocked)
|
|
2235
|
+
: h('span', { className: 'qt-fhint' }, direction === 'auto' ? (hasText ? t.fieldAutoTo(target) : t.fieldAuto) : hasText ? t.autoHint(target) : '')
|
|
2236
|
+
const fieldStatus = streaming
|
|
2237
|
+
? h('span', { className: 'qt-fhint' }, t.translating)
|
|
2238
|
+
: status !== 'done'
|
|
2239
|
+
? h('span', { className: 'qt-fhint' }, status === 'error' ? '' : t.standby)
|
|
2240
|
+
: cancelled
|
|
2241
|
+
? h('span', { className: 'qt-fhint' }, h('span', { className: 'qt-fchip-warn', title: t.cancelledPartial }, t.cancelledPartial))
|
|
2242
|
+
: truncated
|
|
2243
|
+
? h('span', { className: 'qt-fhint' }, h('span', { className: 'qt-fchip-warn', title: t.truncated }, t.truncated))
|
|
2244
|
+
: h('span', { className: 'qt-fhint qt-fchip-ok' }, `${t.done} · ${fmtElapsed(elapsed, t)}`)
|
|
2245
|
+
const histOpen = historyOpen && !modelsMissing
|
|
2246
|
+
const fhb = (props, ...kids) => h('button', { type: 'button', className: 'qt-fhb', style: noDrag, ...props }, ...kids)
|
|
2247
|
+
|
|
2248
|
+
const srcBox = h(
|
|
2249
|
+
'section',
|
|
2250
|
+
{ className: 'qt-fbox qt-fsrc', 'aria-label': t.source },
|
|
2251
|
+
h(
|
|
2252
|
+
'div',
|
|
2253
|
+
{ className: 'qt-frow' },
|
|
2254
|
+
h('span', { className: 'qt-flang', 'data-lang': srcLang }, nativeName(srcLang)),
|
|
2255
|
+
srcHint,
|
|
2256
|
+
h('div', { className: 'qt-ftrack', role: 'group', 'aria-label': t.direction }, segButton('en2zh', t.en2zh), segButton('zh2en', t.zh2en), segButton('auto', t.auto)),
|
|
2257
|
+
),
|
|
2258
|
+
h('textarea', {
|
|
2259
|
+
ref: sourceRef,
|
|
2260
|
+
className: 'qt-fta',
|
|
2261
|
+
value: source,
|
|
2262
|
+
placeholder: t.sourcePlaceholder,
|
|
2263
|
+
spellCheck: false,
|
|
2264
|
+
autoFocus: true,
|
|
2265
|
+
readOnly: streaming,
|
|
2266
|
+
onKeyDown: onSourceKey,
|
|
2267
|
+
onChange: (event) => setSource(event.target.value),
|
|
2268
|
+
}),
|
|
2269
|
+
h(
|
|
2270
|
+
'div',
|
|
2271
|
+
{ className: 'qt-ffoot' },
|
|
2272
|
+
h('span', { className: 'qt-fcount' }, `${source.length} ${t.chars}`),
|
|
2273
|
+
h('button', { type: 'button', className: 'qt-fclear', onClick: clearAll, title: t.clearTitle, disabled: streaming || (!source && !result) }, t.clear),
|
|
2274
|
+
streaming
|
|
2275
|
+
? h('button', { type: 'button', className: 'qt-fgo is-stop', onClick: cancel, title: 'Esc' }, t.cancel, h('kbd', null, 'Esc'))
|
|
2276
|
+
: h('button', { type: 'button', className: 'qt-fgo qt-fgo-primary', disabled: !canTranslate, onClick: runTranslate, title: `${modKey} + Enter` }, t.translate, h('kbd', null, kbdLabel)),
|
|
2277
|
+
),
|
|
2278
|
+
)
|
|
2279
|
+
|
|
2280
|
+
const swapBtn = h('button', { type: 'button', className: 'qt-fswap', title: t.swap, 'aria-label': t.swap, disabled: !result || streaming, onClick: swap }, h(SwapIcon))
|
|
2281
|
+
|
|
2282
|
+
const fieldBox = h(
|
|
2283
|
+
'section',
|
|
2284
|
+
{ className: 'qt-fbox qt-ffield', 'aria-label': t.result },
|
|
2285
|
+
h('span', { className: 'qt-fwm', 'data-lang': dstLang, 'aria-hidden': 'true' }, dstLang === 'en' ? 'A' : '文'),
|
|
2286
|
+
streaming ? h('div', { className: 'qt-fprog', 'aria-hidden': 'true' }) : null,
|
|
2287
|
+
h('div', { className: 'qt-frow' }, h('span', { className: 'qt-flang', 'data-lang': dstLang }, nativeName(dstLang)), fieldStatus),
|
|
2288
|
+
status === 'error' && error
|
|
2289
|
+
? h('div', { className: 'qt-ferror', role: 'alert' }, h('span', { className: 'qt-error-text' }, error), h('button', { type: 'button', onClick: runTranslate }, t.retry))
|
|
2290
|
+
: null,
|
|
2291
|
+
h(
|
|
2292
|
+
'div',
|
|
2293
|
+
{ className: 'qt-fbody' },
|
|
2294
|
+
h('textarea', {
|
|
2295
|
+
ref: resultRef,
|
|
2296
|
+
className: 'qt-fta qt-fres',
|
|
2297
|
+
'data-lang': dstLang,
|
|
2298
|
+
value: result,
|
|
2299
|
+
placeholder: t.resultPlaceholder,
|
|
2300
|
+
readOnly: true,
|
|
2301
|
+
spellCheck: false,
|
|
2302
|
+
}),
|
|
2303
|
+
!result && !streaming && status !== 'error'
|
|
2304
|
+
? h('div', { className: 'qt-fwait', 'aria-hidden': 'true' }, h('b', null, t.waiting), h('span', null, t.waitingHint(modKey === 'Ctrl' ? 'Ctrl' : '⌘')))
|
|
2305
|
+
: null,
|
|
2306
|
+
),
|
|
2307
|
+
h(
|
|
2308
|
+
'div',
|
|
2309
|
+
{ className: 'qt-fstats' },
|
|
2310
|
+
h('span', null, `${t.fSrc} ${source.length} ${t.chars}`),
|
|
2311
|
+
h('span', null, `${t.fDst} ${result ? result.length : '—'} ${t.chars}`),
|
|
2312
|
+
h('span', null, `${t.statTime} ${status === 'done' && elapsed ? fmtElapsed(elapsed, t) : '—'}`),
|
|
2313
|
+
),
|
|
2314
|
+
h(
|
|
2315
|
+
'div',
|
|
2316
|
+
{ className: 'qt-ffoot' },
|
|
2317
|
+
h(ModelPicker, { groups, defaultRoute, value: modelKeyState, onChange: setModelKeyState, loading: modelsLoading, disabled: modelsMissing, t, skin: 'field' }),
|
|
2318
|
+
h('span', { className: 'qt-spacer' }),
|
|
2319
|
+
h('button', { type: 'button', className: 'qt-flink qt-share-btn', disabled: !result || streaming, onClick: openShare }, t.share),
|
|
2320
|
+
h(
|
|
2321
|
+
'button',
|
|
2322
|
+
{ type: 'button', className: `qt-fcopy ${copyFailed ? 'is-warn' : ''}`, onClick: copyResult, disabled: !result, title: copyFailed ? t.copyFailedHint.replace('{key}', modKey) : '' },
|
|
2323
|
+
copyFailed ? t.copyFailed : copied ? t.copied : t.copy,
|
|
2324
|
+
),
|
|
2325
|
+
),
|
|
2326
|
+
)
|
|
2327
|
+
|
|
2328
|
+
const hist = histOpen
|
|
2329
|
+
? h(FieldHistory, {
|
|
2330
|
+
history,
|
|
2331
|
+
currentId,
|
|
2332
|
+
query: historyQuery,
|
|
2333
|
+
onQuery: setHistoryQuery,
|
|
2334
|
+
onPick: pickHistory,
|
|
2335
|
+
onDelete: deleteHistory,
|
|
2336
|
+
onClear: clearHistory,
|
|
2337
|
+
onClose: () => setHistoryOpen(false),
|
|
2338
|
+
clearArmed,
|
|
2339
|
+
t,
|
|
2340
|
+
lang,
|
|
2341
|
+
})
|
|
2342
|
+
: null
|
|
2343
|
+
|
|
2344
|
+
return h(
|
|
2345
|
+
'div',
|
|
2346
|
+
{ ref: rootRef, className: 'qt-root qt-skin-field', 'data-state': status, 'data-tone': tone },
|
|
2347
|
+
h(
|
|
2348
|
+
'header',
|
|
2349
|
+
{ className: `qt-fhead ${narrow ? 'is-narrow' : ''}`, 'data-window-drag': '' },
|
|
2350
|
+
h('span', { className: 'qt-ftitle' }, t.deskTitle),
|
|
2351
|
+
h('span', { className: 'qt-fsub' }, `${t.title} · DSH Plugin · by ${AUTHOR}`),
|
|
2352
|
+
h(
|
|
2353
|
+
'div',
|
|
2354
|
+
{ className: 'qt-ftrack', role: 'group', 'aria-label': t.skin, style: noDrag },
|
|
2355
|
+
h('button', { type: 'button', 'aria-pressed': 'false', onClick: () => setSkin('paper') }, h('span', { className: 'qt-fsw qt-fsw-paper', 'aria-hidden': 'true' }), t.skinPaper),
|
|
2356
|
+
h('button', { type: 'button', 'aria-pressed': 'true', onClick: () => setSkin('field') }, h('span', { className: 'qt-fsw qt-fsw-field', 'aria-hidden': 'true' }), t.skinField),
|
|
2357
|
+
),
|
|
2358
|
+
fhb({ 'aria-pressed': historyOpen ? 'true' : 'false', onClick: () => setHistoryOpen((v) => !v) }, t.history, h('span', { className: 'qt-fcnt' }, `${history.length}`)),
|
|
2359
|
+
fhb({ title: modelsError || t.refresh, 'aria-label': t.refresh, disabled: modelsLoading, onClick: () => loadModels(true) }, h(RefreshIcon), modelsLoading ? t.refreshing : narrow ? t.refreshShort : t.refresh),
|
|
2360
|
+
),
|
|
2361
|
+
h(
|
|
2362
|
+
'div',
|
|
2363
|
+
{ ref: boardRef, className: `qt-fboard ${narrow ? 'is-narrow' : ''}` },
|
|
2364
|
+
modelsMissing
|
|
2365
|
+
? h(
|
|
2366
|
+
'div',
|
|
2367
|
+
{ className: 'qt-fempty-card' },
|
|
2368
|
+
h('b', null, t.noModelsTitle),
|
|
2369
|
+
h('p', null, emptyMessage),
|
|
2370
|
+
h('button', { type: 'button', className: 'qt-fgo', onClick: () => loadModels(true), disabled: modelsLoading }, t.noModelsRefresh),
|
|
2371
|
+
)
|
|
2372
|
+
: h(
|
|
2373
|
+
'div',
|
|
2374
|
+
{ className: `qt-fcomp ${narrow ? 'is-narrow' : ''} ${histOpen ? 'is-hist' : ''}`, style: compStyle },
|
|
2375
|
+
srcBox,
|
|
2376
|
+
swapBtn,
|
|
2377
|
+
narrow && hist ? hist : fieldBox,
|
|
2378
|
+
narrow ? null : hist,
|
|
2379
|
+
),
|
|
2380
|
+
),
|
|
2381
|
+
shareData ? h(ShareSheet, { data: shareData, t, onClose: () => setShareData(null) }) : null,
|
|
2382
|
+
)
|
|
2383
|
+
}
|
|
2384
|
+
|
|
1667
2385
|
|
|
1668
2386
|
const note = h(
|
|
1669
2387
|
'section',
|
|
@@ -1797,15 +2515,7 @@ window.__ModuleLoader__.load({
|
|
|
1797
2515
|
type: 'button',
|
|
1798
2516
|
className: 'qt-link qt-br qt-share-btn',
|
|
1799
2517
|
disabled: !result || streaming,
|
|
1800
|
-
onClick:
|
|
1801
|
-
setShareData({
|
|
1802
|
-
source,
|
|
1803
|
-
result,
|
|
1804
|
-
target: usedTarget || shownTarget || resolveTarget(direction, source),
|
|
1805
|
-
modelName: usedRoute?.name || usedRoute?.model || selected?.name || defaultRoute?.model || '',
|
|
1806
|
-
elapsedMs: status === 'done' ? elapsed : 0,
|
|
1807
|
-
t,
|
|
1808
|
-
}),
|
|
2518
|
+
onClick: openShare,
|
|
1809
2519
|
},
|
|
1810
2520
|
t.share,
|
|
1811
2521
|
),
|
|
@@ -1823,13 +2533,21 @@ window.__ModuleLoader__.load({
|
|
|
1823
2533
|
|
|
1824
2534
|
return h(
|
|
1825
2535
|
'div',
|
|
1826
|
-
{ className: 'qt-root', 'data-state': status },
|
|
2536
|
+
{ ref: rootRef, className: 'qt-root', 'data-state': status },
|
|
1827
2537
|
h(
|
|
1828
2538
|
'header',
|
|
1829
2539
|
{ className: 'qt-header', 'data-window-drag': '' },
|
|
1830
2540
|
h('span', { className: 'qt-title' }, t.deskTitle),
|
|
1831
2541
|
h('span', { className: 'qt-subtitle qt-mono' }, `[ ${t.title} ] DSH Plugin · by ${AUTHOR}`),
|
|
1832
2542
|
h('span', { className: 'qt-spacer' }),
|
|
2543
|
+
h(
|
|
2544
|
+
'div',
|
|
2545
|
+
{ className: 'qt-skinsw qt-mono', role: 'group', 'aria-label': t.skin, style: noDrag },
|
|
2546
|
+
h('span', { className: 'qt-skinsw-k' }, `${t.skin}:`),
|
|
2547
|
+
h('button', { type: 'button', className: 'qt-hbtn', 'aria-pressed': 'true', onClick: () => setSkin('paper') }, t.skinPaper),
|
|
2548
|
+
h('span', { className: 'qt-skinsw-sep', 'aria-hidden': 'true' }, '/'),
|
|
2549
|
+
h('button', { type: 'button', className: 'qt-hbtn', 'aria-pressed': 'false', onClick: () => setSkin('field') }, t.skinField),
|
|
2550
|
+
),
|
|
1833
2551
|
h(
|
|
1834
2552
|
'button',
|
|
1835
2553
|
{
|
package/locale/en.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "Quick translate",
|
|
4
|
-
"description": "Open Quick translate from the left sidebar to get a paper-collage desk: paste text on the grid notebook on the left, press ⌘/Ctrl+Enter (or the red Translate tape), and read the streaming translation on the tracing paper on the right. The kraft tag in the corner picks EN→ZH, ZH→EN, or Auto. The Model line at the bottom of the tracing paper lists every provider and model already configured in DSH under Settings › Models and follows the DSH default until you choose one. The Swap tab between the two sheets swaps source and translation and flips the direction; click again to swap back. Finished translations land on the History receipt, where you can search, reopen, or delete them; Share image renders the current pair as a card you can copy or save as PNG. Each request goes to the selected model's provider, so the text is sent to that service; Esc cancels. History stays in this browser only; turning the plugin off removes the entry and touches no Session."
|
|
4
|
+
"description": "Open Quick translate from the left sidebar to get a paper-collage desk: paste text on the grid notebook on the left, press ⌘/Ctrl+Enter (or the red Translate tape), and read the streaming translation on the tracing paper on the right. The kraft tag in the corner picks EN→ZH, ZH→EN, or Auto. The Model line at the bottom of the tracing paper lists every provider and model already configured in DSH under Settings › Models and follows the DSH default until you choose one. The Swap tab between the two sheets swaps source and translation and flips the direction; click again to swap back. Finished translations land on the History receipt, where you can search, reopen, or delete them; Share image renders the current pair as a card you can copy or save as PNG. The Style switch in the header toggles between this paper desk and a plain Field layout that follows the DSH light/dark theme; both have the same features. Each request goes to the selected model's provider, so the text is sent to that service; Esc cancels. History stays in this browser only; turning the plugin off removes the entry and touches no Session."
|
|
5
5
|
}
|
|
6
6
|
}
|
package/locale/zh.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "快速翻译",
|
|
4
|
-
"description": "左侧栏点「快速翻译」打开一张纸本风格的桌面:在左边的方格本上贴原文,按 ⌘/Ctrl+Enter(或点红色的「翻译」),右边的硫酸纸上边生成边显示译文。右下角的牛皮纸标签选方向:英→中、中→英或自动判断;硫酸纸底部的「模型」直接列出 DSH「设置 › 模型」里已配置的服务商和模型,默认跟随 DSH 默认模型。两张纸接缝处的「互换」签把原文和译文对调并翻转方向,再点一次换回来。完成的翻译自动进入「历史」小票,可搜索、回看、删除;「分享图片」把这次的原文和译文画成一张卡片,可复制或保存为 PNG
|
|
4
|
+
"description": "左侧栏点「快速翻译」打开一张纸本风格的桌面:在左边的方格本上贴原文,按 ⌘/Ctrl+Enter(或点红色的「翻译」),右边的硫酸纸上边生成边显示译文。右下角的牛皮纸标签选方向:英→中、中→英或自动判断;硫酸纸底部的「模型」直接列出 DSH「设置 › 模型」里已配置的服务商和模型,默认跟随 DSH 默认模型。两张纸接缝处的「互换」签把原文和译文对调并翻转方向,再点一次换回来。完成的翻译自动进入「历史」小票,可搜索、回看、删除;「分享图片」把这次的原文和译文画成一张卡片,可复制或保存为 PNG。头部的「风格」可在纸本和简洁的「色场」之间切换(色场跟随 DSH 明暗主题),功能完全相同。每次翻译都会把文本发送给所选模型的服务商;Esc 可随时取消。历史只存在本机浏览器里,关闭插件后入口消失,不改动任何会话。"
|
|
5
5
|
}
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-quick-translate",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "快速翻译 · DeepSeek Harness 插件:英译中 / 中译英,直接选用 DSH
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "快速翻译 · DeepSeek Harness 插件:英译中 / 中译英,直接选用 DSH 里已配置的模型,流式输出;两套界面风格(纸本拼贴 / 色场简洁)可在头部切换,可把译文做成分享卡片。",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh-plugin",
|
|
7
7
|
"deepseek-harness",
|