@dsh-mobile/mobile-remote 3.5.0-beta.1 → 3.5.0-beta.3

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/client.js CHANGED
@@ -25,27 +25,6 @@ window.__ModuleLoader__.load({
25
25
 
26
26
  var QR_CONFIG = "/m/api/qr-config";
27
27
 
28
- var rowStyle = {
29
- display: "flex",
30
- alignItems: "center",
31
- gap: "10px",
32
- padding: "10px 0",
33
- borderBottom: "1px solid var(--dsw-alias-divider-strong, rgba(128,128,128,.18))",
34
- fontSize: "13.5px",
35
- };
36
- var btnStyle = {
37
- marginLeft: "auto",
38
- flex: "none",
39
- padding: "4px 12px",
40
- borderRadius: "8px",
41
- border: "1px solid var(--dsw-alias-border-strong, rgba(128,128,128,.35))",
42
- background: "none",
43
- cursor: "pointer",
44
- font: "inherit",
45
- fontSize: "12px",
46
- color: "inherit",
47
- };
48
-
49
28
  function toast(text) {
50
29
  var el = document.getElementById("dsh-mr-toast");
51
30
  if (!el) {
@@ -239,7 +218,165 @@ window.__ModuleLoader__.load({
239
218
  });
240
219
  }
241
220
 
242
- var mutedStyle = { fontSize: "12px", color: "var(--dsw-alias-label-tertiary, #aaa)", lineHeight: "1.6" };
221
+
222
+
223
+
224
+
225
+
226
+ var E = jsxRuntime.jsx;
227
+ var MONO = "ui-monospace,SFMono-Regular,Menlo,Consolas,monospace";
228
+ var CSS = [
229
+ ".dshmr{display:flex;flex-direction:column;gap:12px;padding:4px 0 16px;color:var(--dsw-alias-label-primary);font-size:13px;line-height:1.5}",
230
+ ".dshmr-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:12px}",
231
+ ".dshmr-card{display:flex;flex-direction:column;gap:12px;min-width:0;padding:14px 16px;border:.5px solid var(--dsw-alias-settings-card-stroke,rgba(128,128,128,.25));background:var(--dsw-alias-settings-card-fill,transparent);border-radius:var(--dsw-radius-xl,12px)}",
232
+ ".dshmr-lan{order:1}.dshmr-remote{order:2}.dshmr-legacy{order:3}.dshmr-devices{order:4}",
233
+ ".dshmr-wide,.dshmr-legacy,.dshmr-devices{grid-column:1/-1}",
234
+ ".dshmr-grid:not(:has(.dshmr-remote)) .dshmr-lan{grid-column:1/-1}",
235
+ ".dshmr-head{display:flex;align-items:center;gap:8px;min-height:22px}",
236
+ ".dshmr-title{font-size:14px;line-height:22px;font-weight:500}",
237
+ ".dshmr-count{color:var(--dsw-alias-label-tertiary);font-weight:400;margin-left:2px}",
238
+ ".dshmr-tag{margin-left:auto;flex:none;padding:1px 7px;border:.5px solid var(--dsw-alias-border-l3,rgba(128,128,128,.3));border-radius:6px;font-size:11.5px;line-height:17px;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;white-space:nowrap}",
239
+ ".dshmr-tag-plain{margin-left:0}",
240
+ ".dshmr-chip{display:inline-flex;align-items:center;gap:5px;flex:none;margin-left:auto;padding:1px 8px;border-radius:999px;font-size:12px;line-height:18px;white-space:nowrap;background:color-mix(in srgb,currentColor 12%,transparent)}",
241
+ ".dshmr-chip::before{content:'';width:6px;height:6px;border-radius:50%;background:currentColor}",
242
+ ".dshmr-ok{color:var(--dsw-alias-state-success-primary,#30a46c)}",
243
+ ".dshmr-busy{color:var(--dsw-alias-state-warn-primary,#f5a623)}",
244
+ ".dshmr-bad{color:var(--dsw-alias-state-error-primary,#e5484d)}",
245
+ ".dshmr-idle{color:var(--dsw-alias-label-secondary,#888)}",
246
+ ".dshmr-qr{display:flex;flex-direction:column;align-items:center;gap:10px}",
247
+ ".dshmr-qr img{box-sizing:border-box;width:200px;height:200px;padding:8px;border-radius:12px;background:#fff;border:.5px solid var(--dsw-alias-border-l2,rgba(0,0,0,.1))}",
248
+ ".dshmr-fp{display:flex;flex-direction:column;align-items:center;gap:1px}",
249
+ ".dshmr-cap{font-size:12px;color:var(--dsw-alias-label-tertiary)}",
250
+ ".dshmr-fp-v{font-family:" + MONO + ";font-size:14px;letter-spacing:1px;color:var(--dsw-alias-label-primary);user-select:all}",
251
+ ".dshmr-actions{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:8px 10px}",
252
+ ".dshmr-btn{flex:none;padding:4px 12px;border-radius:8px;border:.5px solid var(--dsw-alias-border-l3,rgba(128,128,128,.35));background:none;cursor:pointer;font:inherit;font-size:12px;color:inherit}",
253
+ ".dshmr-btn:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(128,128,128,.1))}",
254
+ ".dshmr-btn:disabled{opacity:.5;cursor:default}",
255
+ ".dshmr-primary{padding:6px 18px;font-size:13px;border-color:transparent;background:var(--dsw-alias-button-primary-fill,#4d6bfe);color:var(--dsw-alias-label-primary-foreground,#fff)}",
256
+ ".dshmr-primary:hover{background:var(--dsw-alias-button-primary-fill,#4d6bfe);filter:brightness(1.08)}",
257
+ ".dshmr-quiet{margin-left:4px;border-color:transparent;color:var(--dsw-alias-label-tertiary)}",
258
+ ".dshmr-quiet:hover{color:var(--dsw-alias-state-error-primary,#e5484d);background:var(--dsw-alias-interactive-bg-hover-danger,rgba(229,72,77,.08))}",
259
+ ".dshmr-link{align-self:center;padding:0;border:0;background:none;cursor:pointer;font:inherit;font-size:12px;color:var(--dsw-alias-label-tertiary)}",
260
+ ".dshmr-link:hover{color:var(--dsw-alias-label-secondary);text-decoration:underline}",
261
+ ".dshmr-folds{margin-top:auto;display:flex;flex-direction:column;gap:4px}",
262
+ ".dshmr-help{font-size:12px}",
263
+ ".dshmr-help summary,.dshmr-fold-btn{display:inline-flex;align-items:center;gap:5px;padding:0;border:0;background:none;font:inherit;font-size:12px;cursor:pointer;list-style:none;color:var(--dsw-alias-label-tertiary);user-select:none}",
264
+ ".dshmr-help summary::-webkit-details-marker{display:none}",
265
+ ".dshmr-help summary::before,.dshmr-fold-btn::before{content:'';width:5px;height:5px;margin:0 2px 0 1px;border-right:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:rotate(-45deg);transition:transform .15s}",
266
+ ".dshmr-help[open] summary::before,.dshmr-fold-btn[aria-expanded=true]::before{transform:rotate(45deg)}",
267
+ ".dshmr-help summary:hover,.dshmr-help[open] summary,.dshmr-fold-btn:hover{color:var(--dsw-alias-label-secondary)}",
268
+ ".dshmr-help-body{margin-top:6px;line-height:1.65;color:var(--dsw-alias-label-secondary)}",
269
+ ".dshmr-help-body p{margin:0 0 4px}",
270
+ ".dshmr-help-body .dshmr-kv{display:flex;flex-wrap:wrap;gap:0 8px;margin:0 0 4px}",
271
+ ".dshmr-help-body .dshmr-box{margin:0 0 6px}",
272
+ ".dshmr-chip-time{margin-left:0;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums}",
273
+ ".dshmr-chip-time::before{display:none}",
274
+ ".dshmr-fpline{display:flex;align-items:baseline;gap:8px}",
275
+ ".dshmr-rows{display:flex;flex-direction:column}",
276
+ ".dshmr-row{display:flex;flex-wrap:wrap;align-items:center;gap:4px 8px;min-width:0;padding:9px 0;border-top:.5px solid var(--dsw-alias-border-l2,rgba(128,128,128,.18))}",
277
+ ".dshmr-row:first-child{border-top:0;padding-top:2px}",
278
+ ".dshmr-node{min-width:0;flex:1 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
279
+ ".dshmr-url{font-family:" + MONO + ";font-size:12px;word-break:break-all;color:var(--dsw-alias-label-secondary)}",
280
+ ".dshmr-name{font-size:13.5px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
281
+ ".dshmr-when{margin-left:auto;font-size:12px;color:var(--dsw-alias-label-tertiary);white-space:nowrap}",
282
+ ".dshmr-empty{padding:10px 0 4px;font-size:12.5px;color:var(--dsw-alias-label-tertiary);text-align:center}",
283
+ ".dshmr-center{display:flex;flex-direction:column;align-items:center;gap:8px;padding:6px 0}",
284
+ ".dshmr-note{font-size:12.5px;line-height:1.6;color:var(--dsw-alias-label-secondary)}",
285
+ ".dshmr-box{padding:9px 12px;border-radius:8px;font-size:12.5px;line-height:1.6}",
286
+ ".dshmr-box-warn{background:rgba(245,166,35,.12);border:1px solid rgba(245,166,35,.45)}",
287
+ ".dshmr-box-err{background:rgba(229,72,77,.12);border:1px solid rgba(229,72,77,.4);color:var(--dsw-alias-state-error-primary,#e5484d)}",
288
+ ".dshmr-pre{margin:0;padding:10px 12px;border-radius:8px;background:rgba(128,128,128,.12);font-size:12px;overflow-x:auto}",
289
+ ".dshmr-sub{font-size:13px;font-weight:500;margin-top:4px}",
290
+ ].join("\n");
291
+
292
+
293
+ function card(cls, title, headExtra, body, folds, key) {
294
+ return E(
295
+ "section",
296
+ {
297
+ className: "dshmr-card " + cls,
298
+ children: [E("div", { className: "dshmr-head", children: [E("div", { className: "dshmr-title", children: title }, "t")].concat(headExtra || []) }, "head")]
299
+ .concat(body)
300
+ .concat(folds && folds.length ? [E("div", { className: "dshmr-folds", children: folds }, "folds")] : []),
301
+ },
302
+ key
303
+ );
304
+ }
305
+
306
+
307
+
308
+
309
+ function fold(title, items, key) {
310
+ var paras = (Array.isArray(items) ? items : [items]).filter(function (p) { return p !== null && p !== undefined && p !== ""; });
311
+ return E(
312
+ "details",
313
+ {
314
+ className: "dshmr-help",
315
+ children: [
316
+ E("summary", { children: title }, "s"),
317
+ E("div", { className: "dshmr-help-body", children: paras.map(function (p, i) { return typeof p === "string" ? E("p", { children: p }, "p" + i) : p; }) }, "b"),
318
+ ],
319
+ },
320
+ key
321
+ );
322
+ }
323
+
324
+ function relayNodeName(url) {
325
+ var host = "";
326
+ try {
327
+ host = new URL(String(url).replace(/^wss?:/, "https:")).hostname;
328
+ } catch (_) {
329
+ return "";
330
+ }
331
+ if (host === "dsh.claud.ing") return "Cloudflare";
332
+ if (/^hk[-.]/.test(host)) return "香港节点";
333
+ return "";
334
+ }
335
+
336
+ function relayHost(url) {
337
+ return String(url || "").replace(/^wss?:\/\//, "").replace(/\/+$/, "");
338
+ }
339
+
340
+ function relayChip(link) {
341
+ var s = link && link.state;
342
+ if (s === "online") return { text: "已连接", tone: "dshmr-ok" };
343
+ if (s === "offline") return { text: "离线", tone: "dshmr-bad" };
344
+ if (s === "idle") return { text: "待命", tone: "dshmr-idle" };
345
+ if (s === "connecting") return { text: "连接中…", tone: "dshmr-busy" };
346
+ return { text: "未知", tone: "dshmr-idle" };
347
+ }
348
+ exports.relayNodeName = relayNodeName;
349
+ exports.relayChip = relayChip;
350
+
351
+
352
+ function fpLine(hex, key) {
353
+ return E("div", { className: "dshmr-fpline", children: [
354
+ E("span", { className: "dshmr-cap", children: "指纹" }, "l"),
355
+ E("span", { className: "dshmr-fp-v", children: formatPairingFingerprint(hex) }, "f"),
356
+ ] }, key || "fp");
357
+ }
358
+
359
+ function timeChip(countdown, title, key) {
360
+ return E("span", { className: "dshmr-chip dshmr-chip-time", title: title, children: countdown }, key || "cd");
361
+ }
362
+
363
+ var LAN_HELP = [
364
+ "配对后可以在手机上给 agent 发消息、看进度、收通知、审批决策。打开手机 App → 扫码连接 → 对准这个二维码。",
365
+ "手机和电脑在同一个 Wi-Fi 下。连接全程加密,二维码里没有访问口令;不经过任何服务器,免费。",
366
+ "「指纹」是这台电脑的公钥指纹:手机配对时会显示同一串,一致再确认。",
367
+ "二维码旁的时间是这个一次性配对码的剩余有效期:到期或有手机配对成功后自动换新。「复制配对链接」可以发到手机上,在 App 连接页粘贴使用。",
368
+ ];
369
+ var REMOTE_HELP = [
370
+ "手机不在同一个 Wi-Fi 时(4G/5G、公司或别人的网络)用它:电脑只向外连接中继,不开放端口、不用装 VPN;内容端到端加密,中继看不到。",
371
+ "配对码只能用一次、5 分钟内有效(二维码旁的时间是剩余有效期);二维码里没有长期口令。手机上会显示同一串「指纹」,一致再确认。",
372
+ "通过我们的公共中继连接需要在手机 App 里订阅;同一个 Wi-Fi 下的连接一直免费。没有已配对的手机、也没有有效配对码时,电脑不连中继(显示「待命」)。",
373
+ ];
374
+ var DEVICES_HELP = [
375
+ "这里列出和这台电脑配对过的手机,时间是它最近一次连接。",
376
+ "手机丢了或不再使用就撤销它:它会立即断开。",
377
+ "为了让它彻底连不上,撤销时电脑会同时更换中继密钥和自动生成的访问口令:其余已配对的手机也要重新扫码配对。",
378
+ ];
379
+
243
380
 
244
381
 
245
382
 
@@ -278,7 +415,8 @@ window.__ModuleLoader__.load({
278
415
  function tick() {
279
416
  return load().then(function (data) {
280
417
 
281
- if (data && data.enabled === false && h !== null) {
418
+
419
+ if (data && data.enabled === false && !data.lanNoise && h !== null) {
282
420
  clearInterval(h);
283
421
  h = null;
284
422
  }
@@ -349,7 +487,7 @@ window.__ModuleLoader__.load({
349
487
  function (res) {
350
488
  var parts = ["已撤销「" + device.name + "」"];
351
489
  if (res && res.repairRequired > 0) parts.push("另有 " + res.repairRequired + " 台手机需要重新扫码配对");
352
- if (res && res.tokenRotated) parts.push("访问口令已更换,请用下面的新二维码重新连接");
490
+ if (res && res.tokenRotated) parts.push("访问口令已更换,请用新的二维码重新连接");
353
491
  else if (res && res.tokenRotationSkipped === "configured") parts.push("访问口令是你在配置里写的,请尽快自己更换");
354
492
  if (res && res.relayKeyRotated === false) parts.push("中继密钥更换失败,请查看日志");
355
493
  toast(parts.join(";"));
@@ -368,120 +506,108 @@ window.__ModuleLoader__.load({
368
506
 
369
507
 
370
508
 
371
- return jsxRuntime.jsx(
509
+ return E(
372
510
  "div",
373
511
  {
374
- style: rowStyle,
512
+ className: "dshmr-row",
375
513
  children: [
376
- jsxRuntime.jsx("span", { children: d.name }),
514
+ E("span", { className: "dshmr-name", title: d.via === "lan" ? d.name + "(仅局域网)" : d.name, children: d.name }, "n"),
515
+
377
516
 
378
- d.via === "lan" ? jsxRuntime.jsx("span", { style: mutedStyle, children: "仅局域网" }, "via") : null,
379
- jsxRuntime.jsx("span", { style: mutedStyle, children: "最近 " + relativeTime(d.lastSeen, now) }),
380
- jsxRuntime.jsx("button", { style: btnStyle, onClick: function () { revoke(d); }, children: "撤销" }),
517
+ E("span", { className: "dshmr-when", title: "最近一次连接", children: relativeTime(d.lastSeen, now) }, "w"),
518
+ E("button", { className: "dshmr-btn dshmr-quiet", onClick: function () { revoke(d); }, children: "撤销" }, "x"),
381
519
  ],
382
520
  },
383
521
  "d:" + d.id
384
522
  );
385
523
  }
386
-
387
- var title = jsxRuntime.jsx("div", { style: { fontSize: "13px", fontWeight: 600, margin: "18px 0 2px" }, children: "远程访问(手机不在同一 Wi-Fi 时)" });
388
- var wrap = function (children) {
389
- return jsxRuntime.jsx("div", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: [title].concat(children) });
390
- };
524
+ function devicesCard(devices) {
525
+ var rows = devices.length === 0 ? [E("div", { className: "dshmr-empty", children: "还没有设备" }, "none")] : devices.map(deviceRow);
526
+ var lanOnly = devices.filter(function (d) { return d.via === "lan"; }).map(function (d) { return d.name; });
527
+ var helpItems = (devices.length === 0 ? ["在手机 App 里扫上面的配对二维码,配对好的手机会出现在这里。"] : [])
528
+ .concat(lanOnly.length ? ["仅局域网:" + lanOnly.join("、") + "。这些手机是用局域网二维码配对的,只在同一个 Wi-Fi 下连接,不经过中继。"] : [])
529
+ .concat(DEVICES_HELP);
530
+ return card("dshmr-devices", ["已连接设备", E("span", { className: "dshmr-count", children: "(" + devices.length + ")" }, "c")], null, [E("div", { className: "dshmr-rows", children: rows }, "rows")], [fold("说明", helpItems, "help")], "devices");
531
+ }
532
+ var REMOTE_TITLE = "远程配对";
391
533
 
392
534
 
393
- if (st.status === "loading") return relayUi.advertiseWhenOff ? wrap([jsxRuntime.jsx("div", { style: mutedStyle, children: "加载中…" }, "l")]) : null;
535
+ if (st.status === "loading") return relayUi.advertiseWhenOff ? card("dshmr-remote", REMOTE_TITLE, [E("span", { className: "dshmr-chip dshmr-idle", children: "加载中…" }, "chip")], [], null, "remote") : null;
394
536
  if (st.status === "error") {
395
537
  if (!relayUi.advertiseWhenOff) return null;
396
- return wrap([jsxRuntime.jsx("div", { style: mutedStyle, children: "无法读取远程访问状态:" + st.message + "(只能在这台电脑的 DSH 桌面端管理)" }, "e")]);
538
+ return card("dshmr-remote", REMOTE_TITLE, [E("span", { className: "dshmr-chip dshmr-bad", children: "无法读取" }, "chip")], [], [fold("原因", ["无法读取远程访问状态:" + st.message + "(只能在这台电脑的 DSH 桌面端管理)"], "why")], "remote");
397
539
  }
398
540
  var data = st.data;
541
+ var devices = data.devices || [];
399
542
 
400
543
 
401
- if (!data.enabled && data.lanNoise && (data.devices || []).length > 0 && !relayUi.advertiseWhenOff) {
402
- var lanRows = [jsxRuntime.jsx("div", { style: { fontSize: "13px", fontWeight: 600, margin: "18px 0 2px" }, children: "已配对的手机(" + data.devices.length + ")" }, "dh")];
403
- data.devices.forEach(function (d) {
404
- lanRows.push(deviceRow(d));
405
- });
406
- lanRows.push(jsxRuntime.jsx("div", { style: mutedStyle, children: "手机丢了或不再使用:撤销后它会立即断开,其它手机不受影响。" }, "foot"));
407
- return jsxRuntime.jsx("div", { style: { display: "flex", flexDirection: "column", gap: "6px" }, children: lanRows });
408
- }
544
+ if (!data.enabled && data.lanNoise && !relayUi.advertiseWhenOff) return devicesCard(devices);
409
545
  if (!data.enabled) {
410
546
  if (!relayUi.advertiseWhenOff) return null;
411
- return wrap([
412
- jsxRuntime.jsx(
413
- "div",
414
- {
415
- style: mutedStyle,
416
- children:
417
- "未启用。启用后手机用 4G/5G 或任何 Wi-Fi 都能连到这台电脑:电脑只向外连接中继服务,不开放端口,不需要装 VPN;内容端到端加密,中继看不到。需要先部署中继服务(见仓库 relay/README.md)。",
418
- },
419
- "d"
420
- ),
421
- jsxRuntime.jsx(
422
- "pre",
423
- { style: { margin: 0, padding: "10px 12px", borderRadius: "8px", background: "rgba(128,128,128,.12)", fontSize: "12px", overflowX: "auto" }, children: RELAY_SNIPPET },
424
- "s"
425
- ),
426
- jsxRuntime.jsx("div", { style: { display: "flex" }, children: jsxRuntime.jsx("button", { style: btnStyle, onClick: function () { copyText(RELAY_SNIPPET); }, children: "复制配置" }) }, "c"),
427
- jsxRuntime.jsx("div", { style: mutedStyle, children: "把它合并进 cordis.patch.yml 里 mobile-remote 的 config 后重启 DSH。" }, "h"),
428
- ]);
547
+ return card(
548
+ "dshmr-remote",
549
+ REMOTE_TITLE,
550
+ [E("span", { className: "dshmr-chip dshmr-idle", children: "未启用" }, "chip")],
551
+ [E("div", { className: "dshmr-actions", children: E("button", { className: "dshmr-btn", onClick: function () { copyText(RELAY_SNIPPET); }, children: "复制配置" }) }, "c")],
552
+ [
553
+ fold("怎么启用", [
554
+ "启用后手机用 4G/5G 或任何 Wi-Fi 都能连到这台电脑。需要先部署中继服务(见仓库 relay/README.md),把下面的配置合并进 cordis.patch.yml 里 mobile-remote 的 config 后重启 DSH。",
555
+ E("pre", { className: "dshmr-pre", children: RELAY_SNIPPET }, "s"),
556
+ ], "how"),
557
+ fold("说明", REMOTE_HELP, "help"),
558
+ ],
559
+ "remote"
560
+ );
429
561
  }
430
562
 
431
- var remaining = pairing ? pairing.expiresAt - now : 0;
432
- var countdown = formatCountdown(remaining);
433
- var rows = [];
434
- (data.relays || []).forEach(function (l) {
435
- rows.push(
436
- jsxRuntime.jsx(
437
- "div",
438
- {
439
- style: rowStyle,
440
- children: [
441
- jsxRuntime.jsx("span", { style: { wordBreak: "break-all", fontFamily: "monospace", fontSize: "12.5px" }, children: l.url }),
442
- jsxRuntime.jsx("span", { style: { marginLeft: "auto", flex: "none", color: l.state === "online" ? "var(--dsw-alias-text-success, #30a46c)" : "var(--dsw-alias-label-secondary, #888)" }, children: relayLinkLabel(l) }),
443
- ],
444
- },
445
- "r:" + l.url
446
- )
447
- );
448
- });
449
- rows.push(
450
- jsxRuntime.jsx(
563
+ var countdown = formatCountdown(pairing ? pairing.expiresAt - now : 0);
564
+ var relayRows = (data.relays || []).map(function (l) {
565
+ var chip = relayChip(l);
566
+ var name = relayNodeName(l.url);
567
+ return E(
451
568
  "div",
452
569
  {
453
- style: { display: "flex", flexDirection: "column", alignItems: "center", gap: "10px", padding: "12px 0" },
454
- children:
455
- pairing && countdown
456
- ? [
457
- jsxRuntime.jsx("img", { src: pairing.qr, alt: "配对二维码", style: { width: 216, height: 216, borderRadius: "12px", background: "#fff", padding: 8 } }, "img"),
458
- jsxRuntime.jsx("div", { style: mutedStyle, children: "手机 App → 连接页「粘贴配对链接」粘贴,或直接扫这个码。一次性," + countdown + " 后失效。" }, "t"),
459
-
460
-
461
- jsxRuntime.jsx("div", { style: { ...mutedStyle, textAlign: "center" }, children: [
462
- jsxRuntime.jsx("div", { children: "本机指纹(手机上会显示同一串)" }, "l"),
463
- jsxRuntime.jsx("div", { style: { fontFamily: "monospace", fontSize: "14px", letterSpacing: "1px", color: "#111", userSelect: "all" }, children: formatPairingFingerprint(pairing.fingerprint) }, "f"),
464
- ] }, "fp"),
465
- jsxRuntime.jsx("div", { style: { display: "flex", gap: "8px" }, children: [
466
- jsxRuntime.jsx("button", { style: btnStyle, onClick: function () { copyText(pairing.uri); }, children: "复制配对链接" }, "cp"),
467
- jsxRuntime.jsx("button", { style: btnStyle, onClick: function () { setPairing(null); }, children: "关闭" }, "x"),
468
- ] }, "b"),
469
- ]
470
- : [
471
- jsxRuntime.jsx("button", { style: Object.assign({}, btnStyle, { marginLeft: 0, padding: "6px 16px", fontSize: "13px" }), disabled: busy, onClick: createPairing, children: pairing ? "二维码已过期,重新生成" : "生成配对二维码" }, "gen"),
472
- jsxRuntime.jsx("div", { style: mutedStyle, children: "配对码只能用一次、5 分钟内有效;二维码里没有长期口令。" }, "hint"),
473
- ],
570
+ className: "dshmr-row",
571
+ children: [
572
+ E("span", { className: "dshmr-node", title: l.url, children: name || relayHost(l.url) }, "node"),
573
+ E("span", { className: "dshmr-chip " + chip.tone, title: relayLinkLabel(l), children: chip.text }, "chip"),
574
+ ],
474
575
  },
475
- "pair"
476
- )
477
- );
478
- rows.push(jsxRuntime.jsx("div", { style: { fontSize: "13px", fontWeight: 600, margin: "4px 0 2px" }, children: "已配对的手机(" + (data.devices || []).length + ")" }, "dh"));
479
- if ((data.devices || []).length === 0) rows.push(jsxRuntime.jsx("div", { style: mutedStyle, children: "还没有。点上面的按钮,用手机扫码即可。" }, "none"));
480
- (data.devices || []).forEach(function (d) {
481
- rows.push(deviceRow(d));
576
+ "r:" + l.url
577
+ );
482
578
  });
483
- rows.push(jsxRuntime.jsx("div", { style: mutedStyle, children: "手机丢了或不再使用:撤销后它会立即断开,其它手机不受影响。" }, "foot"));
484
- return wrap(rows);
579
+
580
+ var nodeDetails = (data.relays || []).map(function (l) {
581
+ var name = relayNodeName(l.url);
582
+ return E("div", { className: "dshmr-kv", children: [
583
+ E("span", { children: (name ? name + " · " : "") + l.url }, "u"),
584
+ E("span", { children: relayLinkLabel(l) }, "s"),
585
+ ] }, "nd:" + l.url);
586
+ });
587
+ var pairBody =
588
+ pairing && countdown
589
+ ? E(
590
+ "div",
591
+ {
592
+ className: "dshmr-qr",
593
+ children: [
594
+ E("img", { src: pairing.qr, alt: "配对二维码" }, "img"),
595
+
596
+ pairing.fingerprint ? fpLine(pairing.fingerprint) : null,
597
+ E("div", { className: "dshmr-actions", children: [
598
+ timeChip(countdown, "一次性配对码的剩余有效期"),
599
+ E("button", { className: "dshmr-btn", onClick: function () { copyText(pairing.uri); }, children: "复制配对链接" }, "cp"),
600
+ E("button", { className: "dshmr-btn", onClick: function () { setPairing(null); }, children: "关闭" }, "x"),
601
+ ] }, "b"),
602
+ ],
603
+ },
604
+ "pair"
605
+ )
606
+ : E("div", { className: "dshmr-center", children: E("button", { className: "dshmr-btn dshmr-primary", disabled: busy, onClick: createPairing, children: pairing ? "二维码已过期,重新生成" : "生成配对二维码" }, "gen") }, "pair");
607
+ return [
608
+ card("dshmr-remote", REMOTE_TITLE, null, [E("div", { className: "dshmr-rows", children: relayRows }, "relays"), pairBody], [nodeDetails.length ? fold("节点详情", nodeDetails, "nodes") : null, fold("说明", REMOTE_HELP, "help")].filter(Boolean), "remote"),
609
+ devicesCard(devices),
610
+ ];
485
611
  }
486
612
  exports.RelayPanel = RelayPanel;
487
613
 
@@ -494,6 +620,8 @@ window.__ModuleLoader__.load({
494
620
 
495
621
 
496
622
 
623
+
624
+
497
625
  function LanPairing(props) {
498
626
  var onAvailability = props && typeof props.onAvailability === "function" ? props.onAvailability : function () {};
499
627
  var stHook = useState({ status: "loading" });
@@ -576,27 +704,18 @@ window.__ModuleLoader__.load({
576
704
  [st]
577
705
  );
578
706
 
579
- if (st.status === "loading") return jsxRuntime.jsx("div", { style: { padding: "20px 0", color: "var(--dsw-alias-label-secondary, #888)" }, children: "加载中…" });
707
+ if (st.status === "loading") return E("div", { className: "dshmr-empty", children: "加载中…" });
580
708
  if (st.status !== "ready") return null;
581
709
  var countdown = formatCountdown(st.expiresAt - now) || "0:00";
582
- return jsxRuntime.jsx("div", {
583
- style: { display: "flex", flexDirection: "column", alignItems: "center", gap: "10px", padding: "14px 0" },
710
+ return E("div", {
711
+ className: "dshmr-qr",
584
712
  children: [
585
- jsxRuntime.jsx("img", { src: st.qr, alt: "加密配对二维码", style: { width: 216, height: 216, borderRadius: "12px", background: "#fff", padding: 8 } }, "img"),
586
- jsxRuntime.jsx("div", { style: { fontSize: "12px", color: "var(--dsw-alias-label-tertiary, #aaa)" }, children: "打开 App → 扫码连接 → 对准本二维码" }, "how"),
587
- jsxRuntime.jsx(
588
- "div",
589
- {
590
- style: Object.assign({}, mutedStyle, { textAlign: "center" }),
591
- children: "手机和电脑在同一个 Wi-Fi 下。连接全程加密,二维码里没有访问口令;不经过任何服务器,免费。一次性配对码," + countdown + " 后自动换新。",
592
- },
593
- "t"
594
- ),
595
- jsxRuntime.jsx("div", { style: Object.assign({}, mutedStyle, { textAlign: "center" }), children: [
596
- jsxRuntime.jsx("div", { children: "本机指纹(手机上会显示同一串)" }, "l"),
597
- jsxRuntime.jsx("div", { style: { fontFamily: "monospace", fontSize: "14px", letterSpacing: "1px", color: "#111", userSelect: "all" }, children: formatPairingFingerprint(st.fingerprint) }, "f"),
598
- ] }, "fp"),
599
- jsxRuntime.jsx("button", { style: Object.assign({}, btnStyle, { marginLeft: 0 }), onClick: function () { copyText(st.uri); }, children: "复制配对链接" }, "cp"),
713
+ E("img", { src: st.qr, alt: "加密配对二维码" }, "img"),
714
+ fpLine(st.fingerprint),
715
+ E("div", { className: "dshmr-actions", children: [
716
+ timeChip(countdown, "一次性配对码的剩余有效期,到期自动换新"),
717
+ E("button", { className: "dshmr-btn", onClick: function () { copyText(st.uri); }, children: "复制配对链接" }, "cp"),
718
+ ] }, "act"),
600
719
  ],
601
720
  });
602
721
  }
@@ -608,6 +727,7 @@ window.__ModuleLoader__.load({
608
727
 
609
728
 
610
729
 
730
+
611
731
  function MobileDeviceSection() {
612
732
  var state = useState({ status: "loading", urls: [], token: "" });
613
733
  var data = state[0];
@@ -652,159 +772,91 @@ window.__ModuleLoader__.load({
652
772
  }, [reloadKey]);
653
773
 
654
774
 
775
+
776
+
777
+
655
778
  function legacyBlock() {
656
- if (data.status === "loading") {
657
- return [jsxRuntime.jsx("div", { style: { padding: "20px 0", color: "var(--dsw-alias-label-secondary, #888)" }, children: "加载中…" }, "lg-l")];
658
- }
779
+ if (data.status === "loading") return { body: [E("div", { className: "dshmr-empty", children: "加载中…" }, "lg-l")], notes: [] };
659
780
  if (data.status === "error") {
660
- return [
661
- jsxRuntime.jsx(
662
- "div",
663
- {
664
- style: { padding: "20px 0", color: "var(--dsw-alias-text-danger, #e5484d)" },
665
- children: "无法获取连接信息:" + data.message + "(确认手机连接插件已启用,且路径为 /m)",
666
- },
667
- "lg-e"
668
- ),
669
- ];
781
+ return {
782
+ body: [E("div", { className: "dshmr-empty", children: "无法获取连接信息" }, "lg-e")],
783
+ notes: [E("div", { className: "dshmr-box dshmr-box-err", children: "无法获取连接信息:" + data.message + "(确认手机连接插件已启用,且路径为 /m)" }, "lg-e")],
784
+ };
670
785
  }
671
786
 
672
787
 
673
788
  var mount = String(data.basePath || "/m").replace(/\/+$/, "");
674
789
  var qrPayload = buildQrPayload(data);
675
790
  var qrSrc = mount + "/qr.png?text=" + encodeURIComponent(qrPayload);
676
- return [
677
- jsxRuntime.jsx(
678
- "div",
679
- {
680
- style: {
681
- padding: "10px 12px",
682
- borderRadius: "8px",
683
- background: "rgba(245,166,35,.12)",
684
- border: "1px solid rgba(245,166,35,.45)",
685
- fontSize: "12.5px",
686
- lineHeight: "1.6",
687
- },
688
- children:
689
- "⚠️ 这个二维码不加密:用它连接后,手机的每个请求都会在局域网上明文带着访问口令,同一个 Wi-Fi 里的人可以截获并控制这台电脑上的 agent。只给还不能更新的旧版 App(1.1 及更早)用;更新 App 后请改扫" +
690
- (lan ? "上面的加密二维码。" : "加密二维码(需要打开 LAN 桥)。"),
691
- },
692
- "lg-warn"
693
- ),
791
+ var body = [
792
+ E("div", { className: "dshmr-qr", children: [E("img", { src: qrSrc, alt: "连接二维码(不加密)" }, "img")] }, "lg-qr"),
793
+ E("div", {
794
+ className: "dshmr-rows",
795
+ children: data.urls
796
+ .map(function (u) {
797
+ return E("div", { className: "dshmr-row", children: [
798
+ E("span", { className: "dshmr-url", children: u }, "u"),
799
+ E("button", { className: "dshmr-btn", style: { marginLeft: "auto" }, onClick: function () { copyText(u); }, children: "复制" }, "c"),
800
+ ] }, u);
801
+ })
802
+ .concat([
803
+ E("div", { className: "dshmr-row", children: [
804
+ E("span", { children: "访问口令" }, "l"),
805
+ E("span", { className: "dshmr-url", children: data.token ? data.token.slice(0, 6) + "…" + data.token.slice(-4) : "未启用" }, "v"),
806
+ data.token ? E("button", { className: "dshmr-btn", style: { marginLeft: "auto" }, onClick: function () { copyToken(data.token); }, children: "复制" }, "c") : null,
807
+ ] }, "lg-token"),
808
+ ]),
809
+ }, "lg-rows"),
810
+ ];
811
+ var notes = [
812
+ E("div", { className: "dshmr-box dshmr-box-warn", children:
813
+ "⚠️ 这个二维码不加密:用它连接后,手机的每个请求都会在局域网上明文带着访问口令,同一个 Wi-Fi 里的人可以截获并控制这台电脑上的 agent。只给还不能更新的旧版 App(1.1 及更早)用;更新 App 后请改扫" +
814
+ (lan ? "加密的局域网配对二维码。" : "加密二维码(需要打开 LAN 桥)。") }, "lg-warn"),
694
815
  data.token
695
816
  ? null
696
- : jsxRuntime.jsx(
697
- "div",
698
- {
699
- style: {
700
- padding: "10px 12px",
701
- borderRadius: "8px",
702
- background: "rgba(229,72,77,.12)",
703
- border: "1px solid rgba(229,72,77,.4)",
704
- color: "var(--dsw-alias-text-danger, #e5484d)",
705
- fontSize: "12.5px",
706
- lineHeight: "1.6",
707
- },
708
- children:
709
- "⚠️ 访问口令为空:现在只有这台电脑能连接,手机连不上。要让手机连接,请删掉 cordis.patch.yml 里空的 authToken(默认的 \"@auto\" 会自动生成口令),或打开 lanBridge / 中继,然后重启。",
710
- },
711
- "lg-empty"
712
- ),
713
- jsxRuntime.jsx(
714
- "div",
715
- {
716
- style: { display: "flex", flexDirection: "column", alignItems: "center", gap: "10px", padding: "14px 0" },
717
- children: [
718
- jsxRuntime.jsx("img", {
719
- src: qrSrc,
720
- alt: "连接二维码(不加密)",
721
- style: { width: 216, height: 216, borderRadius: "12px", background: "#fff", padding: 8 },
722
- }, "img"),
723
- jsxRuntime.jsx("div", {
724
- style: { fontSize: "12px", color: "var(--dsw-alias-label-tertiary, #aaa)" },
725
- children: "旧版 App → 扫码连接 → 对准本二维码",
726
- }, "how"),
727
- ],
728
- },
729
- "lg-qr"
730
- ),
731
- jsxRuntime.jsx("div", { style: { fontSize: "13px", fontWeight: 600, margin: "8px 0 2px" }, children: "连接信息" }, "lg-h"),
732
- data.urls.map(function (u) {
733
- return jsxRuntime.jsx(
734
- "div",
735
- {
736
- style: rowStyle,
737
- children: [
738
- jsxRuntime.jsx("span", { style: { wordBreak: "break-all", fontFamily: "monospace", fontSize: "12.5px" }, children: u }),
739
- jsxRuntime.jsx("button", { style: btnStyle, onClick: function () { copyText(u); }, children: "复制" }),
740
- ],
741
- },
742
- u
743
- );
744
- }),
745
- jsxRuntime.jsx(
746
- "div",
747
- {
748
- style: rowStyle,
749
- children: [
750
- jsxRuntime.jsx("span", { children: "访问口令" }),
751
- jsxRuntime.jsx(
752
- "span",
753
- {
754
- style: { fontFamily: "monospace", fontSize: "12px", opacity: 0.75 },
755
- children: data.token
756
- ? data.token.slice(0, 6) + "…" + data.token.slice(-4)
757
- : "未启用(局域网/内网环境)",
758
- }
759
- ),
760
- data.token
761
- ? jsxRuntime.jsx("button", {
762
- style: btnStyle,
763
- onClick: function () { copyToken(data.token); },
764
- children: "复制",
765
- })
766
- : null,
767
- ],
768
- },
769
- "lg-token"
770
- ),
771
- jsxRuntime.jsx("div", {
772
- style: { fontSize: "12px", color: "var(--dsw-alias-label-tertiary, #aaa)", marginTop: "6px" },
773
- children: "二维码包含访问口令,仅在本机显示;请勿截屏转发。App 与手机浏览器(/m 网页)共用同一连接。",
774
- }, "lg-foot"),
817
+ : E("div", { className: "dshmr-box dshmr-box-err", children:
818
+ "⚠️ 访问口令为空(局域网/内网环境):现在只有这台电脑能连接,手机连不上。要让手机连接,请删掉 cordis.patch.yml 里空的 authToken(默认的 \"@auto\" 会自动生成口令),或打开 lanBridge / 中继,然后重启。" }, "lg-empty"),
819
+ "旧版 App → 扫码连接 → 对准这个二维码;也可以在 App 里手动填写上面的地址和访问口令。",
820
+ "二维码包含访问口令,仅在本机显示;请勿截屏转发。App 与手机浏览器(/m 网页)共用同一连接。",
775
821
  ];
822
+ return { body: body, notes: notes };
776
823
  }
777
824
 
778
- var children = [
779
- jsxRuntime.jsx("div", {
780
- style: { fontSize: "13px", color: "var(--dsw-alias-label-secondary, #888)", lineHeight: "1.6" },
781
- children: "用手机 DSH Mobile App 扫描下方二维码配对,即可远程发消息、看进度、收通知、审批决策。",
782
- }, "intro"),
783
- jsxRuntime.jsx(LanPairing, { onAvailability: setLan }, "lan"),
784
- ];
825
+ var lanBody = [E(LanPairing, { onAvailability: setLan }, "lan")];
826
+ var lanFolds = [];
827
+ var lanChip = [];
785
828
  if (lan === false) {
786
- children.push(
787
- jsxRuntime.jsx(
788
- "div",
789
- { style: mutedStyle, children: "这台电脑上局域网加密通道不可用(LAN 桥没有在监听,例如 DSH 网页版)。下面是不加密的旧二维码。" },
790
- "lan-off"
791
- )
792
- );
793
- children = children.concat(legacyBlock());
829
+ var lg = legacyBlock();
830
+ lanChip = [E("span", { className: "dshmr-chip dshmr-bad", children: "不加密" }, "chip")];
831
+ lanBody = lanBody.concat(lg.body);
832
+ lanFolds = [fold("为什么是旧二维码", ["这台电脑上局域网加密通道不可用(LAN 桥没有在监听,例如 DSH 网页版),所以这里显示的是不加密的旧二维码。"].concat(lg.notes), "why")];
794
833
  } else if (lan === true) {
795
- children.push(
796
- jsxRuntime.jsx(
797
- "div",
798
- { style: { display: "flex" }, children: jsxRuntime.jsx("button", { style: Object.assign({}, btnStyle, { marginLeft: 0 }), onClick: function () { setLegacyOpen(!legacyOpen); }, children: legacyOpen ? "收起旧版二维码" : "旧版 App(1.1 及更早)扫不了上面的码?显示旧版二维码(不加密)" }) },
799
- "lg-toggle"
834
+ lanFolds = [
835
+ E("button", { className: "dshmr-fold-btn", "aria-expanded": legacyOpen ? "true" : "false", onClick: function () { setLegacyOpen(!legacyOpen); }, children: "旧版 App(1.1 及更早)" }, "lg-toggle"),
836
+ fold("说明", LAN_HELP, "help"),
837
+ ];
838
+ }
839
+ var cards = [card("dshmr-lan" + (lan === false ? " dshmr-wide" : ""), "局域网配对", lanChip, lanBody, lanFolds, "lan-card")];
840
+ if (lan === true && legacyOpen) {
841
+ var lg2 = legacyBlock();
842
+ cards.push(
843
+ card(
844
+ "dshmr-legacy",
845
+ "旧版 App 二维码",
846
+ [
847
+ E("span", { className: "dshmr-chip dshmr-bad", children: "不加密" }, "chip"),
848
+ E("button", { className: "dshmr-btn", style: { marginLeft: "8px" }, onClick: function () { setLegacyOpen(false); }, children: "收起" }, "x"),
849
+ ],
850
+ lg2.body,
851
+ [fold("为什么不加密", lg2.notes, "why")],
852
+ "legacy-card"
800
853
  )
801
854
  );
802
- if (legacyOpen) children = children.concat(legacyBlock());
803
855
  }
804
- children.push(jsxRuntime.jsx(RelayPanel, { onCredentialsChanged: function () { setReloadKey(function (k) { return k + 1; }); } }, "relay"));
805
- return jsxRuntime.jsx("div", {
806
- style: { display: "flex", flexDirection: "column", gap: "6px", padding: "4px 0 16px" },
807
- children: children,
856
+ cards.push(E(RelayPanel, { onCredentialsChanged: function () { setReloadKey(function (k) { return k + 1; }); } }, "relay"));
857
+ return E("div", {
858
+ className: "dshmr",
859
+ children: [E("style", { children: CSS }, "css"), E("div", { className: "dshmr-grid", children: cards }, "grid")],
808
860
  });
809
861
  }
810
862