magpie-select-translate 0.3.0 → 0.3.2
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 +1 -0
- package/bin/helper.exe +0 -0
- package/package.json +1 -1
- package/page/index.html +14 -7
package/README.md
CHANGED
|
@@ -66,6 +66,7 @@ helper 只在 magpie 启动插件时被拉起,magpie 不开它就不会常驻
|
|
|
66
66
|
|
|
67
67
|
## 更新
|
|
68
68
|
|
|
69
|
+
- 0.3.2:浮窗里原文和译文分成两块(原文小一号灰字,中间一条细线),滚动条只在内容超高时才出现;修掉只读编辑框的灰底和滚动时文字叠在一起的问题。
|
|
69
70
|
- 0.3.0:设置页改由 helper 自己提供(能读网关模型列表,热键改完立即生效,不用重启 helper);浮窗里原文和译文合成一块可滚动内容,长原文不再被截断在 3 行;`scripts\install.ps1` 现在真的会先停掉旧 helper(之前按错的进程名杀,升级后跑的还是老版本)。
|
|
70
71
|
- 0.2.2:显示名改成包名 `magpie-select-translate`(`magpie.name` 之前是 "Select Translate",发现页卡片上看到的就是它)。
|
|
71
72
|
- 0.2.1:修安全漏洞:本地接口拒绝带浏览器 `Origin` 的请求,写请求必须是 `application/json`;术语表只接收正文(`glossary`),不再按路径读本地文件。`package.json` 去掉 BOM。
|
package/bin/helper.exe
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magpie-select-translate",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "划词翻译:选中文字按热键,鼠标旁浮窗流式显示 magpie 模型的译文。Select-to-translate popover for magpie: hit a hotkey on any selection and the translation streams next to your cursor.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.mjs",
|
package/page/index.html
CHANGED
|
@@ -13,30 +13,37 @@
|
|
|
13
13
|
p { margin: 0 0 8px; font-size: 12px; opacity: .7; }
|
|
14
14
|
code { font-family: Consolas, monospace; }
|
|
15
15
|
</style>
|
|
16
|
+
<!-- magpie 的页面桥:页面必须让它报到(hello),10 秒没报到 magpie 就当页面没响应 -->
|
|
17
|
+
<script src="_magpie/bridge.js"></script>
|
|
16
18
|
</head>
|
|
17
19
|
<body>
|
|
18
20
|
<h1>划词翻译</h1>
|
|
19
21
|
<p id="said">正在打开设置页…</p>
|
|
20
|
-
<p
|
|
21
|
-
|
|
22
|
+
<p>设置页由 helper 提供(模型列表要从本地网关读)。如果一直没跳转,说明 helper 没起来:
|
|
23
|
+
跑一次 <code>scripts\install.ps1</code>,或重开一次 magpie。</p>
|
|
22
24
|
|
|
23
25
|
<script>
|
|
24
26
|
// 带路页:页面在沙箱里(connect-src 'none'),除了解释跳转什么网都联不上,
|
|
25
27
|
// 所以不能先探活,直接跳到 helper 自己的设置页——那边能读网关模型、能写设置。
|
|
26
28
|
(async () => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
// 碰 magpie.ready 才会给 magpie 发 hello(bridge.js 里就是 call("hello")),
|
|
30
|
+
// 少了这一步 magpie 10 秒后显示“此页面已停止工作 / 页面没有响应”。
|
|
31
|
+
// 只是别被它拖住跳转:magpie 没答就自己走。
|
|
32
|
+
await Promise.race([window.magpie?.ready, new Promise((r) => setTimeout(r, 1500))])
|
|
33
|
+
|
|
34
|
+
let port = 3477
|
|
29
35
|
try {
|
|
30
36
|
const opts = await window.magpie?.options?.get?.()
|
|
31
37
|
if (opts && Number(opts.port) > 0) port = Number(opts.port)
|
|
32
38
|
} catch { /* 没有宿主就用默认端口 */ }
|
|
33
|
-
|
|
34
|
-
// WebKit/WebView2
|
|
39
|
+
|
|
40
|
+
// WebKit/WebView2 跳不过去时不报错,页面会一直停在“正在打开”:5 秒后提示一下。
|
|
35
41
|
setTimeout(() => {
|
|
36
42
|
const said = document.getElementById("said")
|
|
37
43
|
if (said) said.textContent = "没能连上 helper(127.0.0.1:" + port + ")"
|
|
38
44
|
}, 5000)
|
|
39
|
-
|
|
45
|
+
|
|
46
|
+
location.replace("http://127.0.0.1:" + port + "/")
|
|
40
47
|
})()
|
|
41
48
|
</script>
|
|
42
49
|
</body>
|