dsh-plugin-mobile-link 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cli.js +8 -9
- package/lib/client.js +972 -95
- package/lib/handoff.js +1 -1
- package/lib/history/fold-summary.js +85 -32
- package/lib/history/fold.js +11 -1
- package/lib/history/question-record.js +186 -0
- package/lib/i18n.js +177 -0
- package/lib/image-originals.js +121 -0
- package/lib/image-variants.js +315 -0
- package/lib/index.js +50 -0
- package/lib/journal.js +2 -0
- package/lib/link.js +83 -10
- package/lib/router.js +63 -2
- package/lib/session-scope.js +89 -0
- package/lib/status.js +13 -10
- package/package.json +1 -1
package/lib/cli.js
CHANGED
|
@@ -28,6 +28,7 @@ import { MobileLinkAgent } from './link.js'
|
|
|
28
28
|
import { mintPairCode } from './pairing.js'
|
|
29
29
|
import { qrTerminal } from './qr.js'
|
|
30
30
|
import { INVITE_ENV, defaultStatePath, resolveIdentity } from './state.js'
|
|
31
|
+
import { T, setLanguage } from './i18n.js'
|
|
31
32
|
|
|
32
33
|
/** Atomic status snapshot so readers never observe a half-written file. */
|
|
33
34
|
async function writeJsonAtomic(path, value) {
|
|
@@ -60,6 +61,8 @@ function parseArgs(argv) {
|
|
|
60
61
|
|
|
61
62
|
async function main() {
|
|
62
63
|
const args = parseArgs(process.argv.slice(2))
|
|
64
|
+
if (args.lang) setLanguage(args.lang)
|
|
65
|
+
else if (process.env.DSH_LANG) setLanguage(process.env.DSH_LANG)
|
|
63
66
|
if (args.help) {
|
|
64
67
|
process.stdout.write(`usage: cli.js enroll [--relay <ws url>] [--name <label>]
|
|
65
68
|
Register this computer with open enrollment in ${defaultStatePath()}. Exits non-zero on failure.
|
|
@@ -67,6 +70,7 @@ async function main() {
|
|
|
67
70
|
cli.js --relay <ws url> --agent-id <id> --agent-secret <secret>
|
|
68
71
|
[--state-file <path>] [--dsh-url <url>]
|
|
69
72
|
[--status-file <path>] [--heartbeat-ms <n>] [--log-level debug|info|warn]
|
|
73
|
+
[--lang en|zh-Hans|zh-Hant|ja|ko|es|pt-BR|fr|de]
|
|
70
74
|
|
|
71
75
|
Note: run this inside a DSH host (plugin) when you can. A standalone process has no
|
|
72
76
|
in-process context, so on the official desktop app it cannot learn the local address by
|
|
@@ -100,21 +104,16 @@ async function main() {
|
|
|
100
104
|
// 反正人已经坐在终端前、手机就在手边,索性把配对码也申请出来、画成终端二维码:
|
|
101
105
|
// 扫这一屏等于在 App 里填「中转服务器 + 配对码」,少一次开页面找端口的往返。
|
|
102
106
|
// 申请失败不算失败——登记本身已经成功,退回到"去界面里的连接入口取"的说法。
|
|
103
|
-
process.stdout.write('
|
|
104
|
-
+ ' 1. 重启 DSH,让连接器用上这个身份;\n'
|
|
105
|
-
+ ' 2. 手机 App 的「扫码配对」扫下面的二维码(与 DSH 界面左下角「移动端连接」里那张等价)。\n')
|
|
107
|
+
process.stdout.write(`${T('cli.registered')}\n ${T('cli.step1')}\n ${T('cli.step2')}\n`)
|
|
106
108
|
try {
|
|
107
109
|
const identity = await resolveIdentity({ stateFile: settled.stateFile })
|
|
108
110
|
const minted = await mintPairCode({ identity, ttlMs: 10 * 60 * 1000 })
|
|
109
111
|
const minutes = Math.round((minted.expiresAt - Date.now()) / 60000)
|
|
110
112
|
process.stdout.write('\n' + qrTerminal(minted.qrPayload) + '\n')
|
|
111
|
-
process.stdout.write(
|
|
112
|
-
process.stdout.write('
|
|
113
|
-
+ '连接器还会把带令牌地址写进 ~/.dsh/mobile-link/endpoint.json。\n')
|
|
113
|
+
process.stdout.write(`${T('cli.code', { code: minted.code, minutes })}\n`)
|
|
114
|
+
process.stdout.write(`${T('cli.hint')}\n`)
|
|
114
115
|
} catch (error) {
|
|
115
|
-
process.stdout.write('
|
|
116
|
-
+ '重启 DSH 后,在这台电脑的 DSH 界面左下角点「移动端连接」,'
|
|
117
|
-
+ '用手机 App 的「扫码配对」扫里面的二维码。\n')
|
|
116
|
+
process.stdout.write(`${T('cli.prefetchFailed', { error: error?.message ?? error })}\n${T('cli.prefetchHint')}\n`)
|
|
118
117
|
}
|
|
119
118
|
return 0
|
|
120
119
|
}
|