dsh-mobile-plugin 0.5.46 → 0.5.48
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 +179 -130
- package/lib/impl.js +9 -0
- package/lib/mobile/answer-sources.js +61 -25
- package/lib/mobile/approval-facts.js +116 -24
- package/lib/mobile/approvals.js +37 -29
- package/lib/mobile/history-derive.js +56 -57
- package/lib/mobile/live-steps.js +83 -5
- package/lib/mobile/permissions.js +1 -0
- package/lib/mobile/request-model.cjs +15 -0
- package/lib/mobile/session-cache.js +16 -0
- package/lib/mobile/session-changes.js +90 -0
- package/lib/mobile/session-snapshot.js +3 -2
- package/lib/mobile/stats-collect.cjs +75 -4
- package/lib/mobile/stats-ledger.cjs +9 -0
- package/lib/mobile/stream.js +52 -6
- package/lib/mobile/turn-facts.js +256 -0
- package/lib/mobile/uploads.js +42 -28
- package/lib/mobile/wire-cut.js +2 -0
- package/lib/mobile/workflow-live.js +74 -0
- package/lib/mobile/workflow-runs.js +194 -0
- package/lib/mobile/workspace-tools.js +594 -0
- package/lib/panel/index.html +15 -15
- package/lib/routes/control-plane.js +32 -1
- package/lib/routes/mobile-api.js +2 -0
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -41,8 +41,11 @@ window.__ModuleLoader__.load({
|
|
|
41
41
|
/* 宿主那一半没装载时:整颗转红,右上角那颗红点显出来(data-dshm-alert 是它的记号)。
|
|
42
42
|
悬停不换回普通颜色——告警态跟着鼠标变浅等于这一颗在说谎。 */
|
|
43
43
|
.dshm_footAction[data-dshm-alert],.dshm_footAction[data-dshm-alert]:hover{color:var(--dsw-alias-state-error-primary)}
|
|
44
|
+
/* 中间那一档:确实有问题、但还没到「插件坏了」的程度(中转断着、旁挂进程没在跑、
|
|
45
|
+
配了手机却一直没连上)。琥珀色 + 同一颗点,图形与尺寸一样不动。 */
|
|
46
|
+
.dshm_footAction[data-dshm-warn],.dshm_footAction[data-dshm-warn]:hover{color:var(--dsw-alias-state-warning-primary)}
|
|
44
47
|
.dshm_alertDot{display:none}
|
|
45
|
-
.dshm_footAction[data-dshm-alert] .dshm_alertDot{display:inline}
|
|
48
|
+
.dshm_footAction[data-dshm-alert] .dshm_alertDot,.dshm_footAction[data-dshm-warn] .dshm_alertDot{display:inline}
|
|
46
49
|
.dshm_overlay{position:fixed;inset:0;z-index:2147483000;display:flex;align-items:center;justify-content:center;padding:24px;background:rgba(0,0,0,.42)}
|
|
47
50
|
.dshm_dialog{box-sizing:border-box;width:100%;max-width:560px;max-height:82vh;overflow:auto;display:flex;flex-direction:column;gap:10px;padding:18px 20px;border-radius:var(--dsw-radius-xl);border:.5px solid var(--dsw-alias-settings-card-stroke);background:var(--dsw-alias-settings-card-fill);color:var(--dsw-alias-label-primary);box-shadow:0 12px 40px rgba(0,0,0,.28)}
|
|
48
51
|
/* 控制台那一窗比诊断窗宽:里面嵌的是一整页,窄了排版会挤成一列。 */
|
|
@@ -51,16 +54,6 @@ window.__ModuleLoader__.load({
|
|
|
51
54
|
.dshm_frame{flex:1;min-height:0;width:100%;border:0;border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-1)}
|
|
52
55
|
/* iframe 一直不 load 时留的那句话:盖在空白之上,撤不撤由 onload 决定。 */
|
|
53
56
|
.dshm_frameTip{position:absolute;inset:auto 0 0;margin:0;padding:8px 10px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary)}
|
|
54
|
-
/* 入口那一层:只有两块大字按钮,左「进入控制台」右「报错调试」。 */
|
|
55
|
-
.dshm_choices{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin:4px 0 2px}
|
|
56
|
-
.dshm_choice{display:flex;flex-direction:column;gap:6px;align-items:flex-start;text-align:left;min-height:96px;padding:14px 16px;border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-lg);background:transparent;color:var(--dsw-alias-label-primary);cursor:pointer;font:inherit}
|
|
57
|
-
.dshm_choice:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
58
|
-
.dshm_choice:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}
|
|
59
|
-
.dshm_choicePrimary{background:var(--dsw-alias-state-business-primary);border-color:transparent;color:var(--dsw-alias-bg-layer-1)}
|
|
60
|
-
.dshm_choicePrimary:hover{background:var(--dsw-alias-state-business-primary);opacity:.92}
|
|
61
|
-
.dshm_choicePrimary .dshm_choiceHint{color:inherit;opacity:.82}
|
|
62
|
-
.dshm_choiceTitle{font-size:15px;font-weight:600;line-height:22px}
|
|
63
|
-
.dshm_choiceHint{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary)}
|
|
64
57
|
/* 版面竖向排列的那一列(外壳里没法内嵌时用它摆读数)。 */
|
|
65
58
|
.dshm_dialogColumn{flex:1;min-height:0;overflow:auto;display:flex;flex-direction:column;gap:10px}
|
|
66
59
|
.dshm_dialogTitle{margin:0;font-size:16px;font-weight:600;line-height:24px}
|
|
@@ -447,19 +440,21 @@ window.__ModuleLoader__.load({
|
|
|
447
440
|
openFailed: '打开配置页面失败',
|
|
448
441
|
footerOpen: '打开移动端插件配置网页',
|
|
449
442
|
footerPending: '网页地址还没就绪',
|
|
443
|
+
footerNoDevice: '还没配对过手机',
|
|
444
|
+
footerDeviceCount: '{count} 台设备',
|
|
445
|
+
footerDeviceSeen: '{count} 台设备 · {ago}连过',
|
|
446
|
+
footerTunnelBad: '中转没有连上',
|
|
447
|
+
footerSidecarBad: '旁挂进程报错',
|
|
448
|
+
footerAgoNow: '刚刚',
|
|
449
|
+
footerAgoMinutes: '{count} 分钟前',
|
|
450
|
+
footerAgoHours: '{count} 小时前',
|
|
451
|
+
footerAgoDays: '{count} 天前',
|
|
450
452
|
footerPublicConfirm: '这个地址位于公网。继续后会开放移动端插件的网页管理权限 2 小时;期间任何能访问该地址的人都可以操作面板。是否继续?',
|
|
451
453
|
footerLoadMissing: '插件宿主侧没有加载:把 DSH 完整退出再打开一次;还不行就在插件市场重装一遍插件。',
|
|
452
454
|
consoleTitle: '移动端插件控制台',
|
|
453
|
-
|
|
454
|
-
consoleEntryLead: '进控制台配置配对与网络;手机连不上、或者哪儿报错了,走报错调试。',
|
|
455
|
-
consoleEntryConsole: '进入控制台',
|
|
456
|
-
consoleEntryConsoleHint: '配对、网络、插件更新都在那一页',
|
|
457
|
-
consoleEntryDebug: '报错调试',
|
|
458
|
-
consoleEntryDebugHint: '装载、链路、设备、故障账本,出问题时看这里',
|
|
459
|
-
consoleBack: '返回',
|
|
455
|
+
consoleTroubleshoot: '报错调试',
|
|
460
456
|
consolePopupBlocked: '浏览器拦掉了新窗口,允许本站弹出窗口后再点一次。',
|
|
461
|
-
|
|
462
|
-
consoleOpenBrowser: '在浏览器里打开配置页面',
|
|
457
|
+
consoleOpenBrowser: '在浏览器里打开',
|
|
463
458
|
consoleFrameless: '这一屏没载入进来(桌面壳或代理挡住了内嵌页面)。点下面那颗按钮在浏览器里打开,读数一样看得到。',
|
|
464
459
|
diagTitleLoad: '打不开移动端配置页',
|
|
465
460
|
diagTitleOpen: '开放网页管理失败',
|
|
@@ -517,19 +512,21 @@ window.__ModuleLoader__.load({
|
|
|
517
512
|
openFailed: 'Could not open the configuration page',
|
|
518
513
|
footerOpen: 'Open the mobile plugin configuration page',
|
|
519
514
|
footerPending: 'The page address is not ready yet',
|
|
515
|
+
footerNoDevice: 'No phone paired yet',
|
|
516
|
+
footerDeviceCount: '{count} devices',
|
|
517
|
+
footerDeviceSeen: '{count} devices · last seen {ago}',
|
|
518
|
+
footerTunnelBad: 'Relay is not connected',
|
|
519
|
+
footerSidecarBad: 'The sidecar reports an error',
|
|
520
|
+
footerAgoNow: 'just now',
|
|
521
|
+
footerAgoMinutes: '{count} min ago',
|
|
522
|
+
footerAgoHours: '{count} h ago',
|
|
523
|
+
footerAgoDays: '{count} d ago',
|
|
520
524
|
footerPublicConfirm: 'This address is public. Continuing opens mobile plugin web management for 2 hours; anyone who can reach this address can operate the panel during that time. Continue?',
|
|
521
525
|
footerLoadMissing: 'The plugin host half is not loaded: quit and reopen DSH; if that does not help, reinstall the plugin from the market.',
|
|
522
526
|
consoleTitle: 'Mobile plugin console',
|
|
523
|
-
|
|
524
|
-
consoleEntryLead: 'Open the console to configure pairing and networking; if the phone cannot connect or something reports an error, use troubleshooting.',
|
|
525
|
-
consoleEntryConsole: 'Open the console',
|
|
526
|
-
consoleEntryConsoleHint: 'pairing, networking and updates live there',
|
|
527
|
-
consoleEntryDebug: 'Troubleshoot',
|
|
528
|
-
consoleEntryDebugHint: 'loading, link, devices and the fault ledger',
|
|
529
|
-
consoleBack: 'Back',
|
|
527
|
+
consoleTroubleshoot: 'Troubleshoot',
|
|
530
528
|
consolePopupBlocked: 'The browser blocked the new window — allow pop-ups for this site and press again.',
|
|
531
|
-
|
|
532
|
-
consoleOpenBrowser: 'Open the configuration page in a browser',
|
|
529
|
+
consoleOpenBrowser: 'Open in a browser',
|
|
533
530
|
consoleFrameless: 'This panel did not load (the desktop shell or a proxy blocked the embedded page). Use the button below to open it in a browser — the readings are the same.',
|
|
534
531
|
diagTitleLoad: 'Cannot open the mobile configuration page',
|
|
535
532
|
diagTitleOpen: 'Could not open web management',
|
|
@@ -759,16 +756,37 @@ window.__ModuleLoader__.load({
|
|
|
759
756
|
return protocol === 'http:' || protocol === 'https:';
|
|
760
757
|
}
|
|
761
758
|
|
|
762
|
-
/** 把一份 `/status`
|
|
759
|
+
/** 把一份 `/status` 返回收成拨号要用的几样;缺的当没有。 */
|
|
763
760
|
function readStatusView(view) {
|
|
764
761
|
const value = view && typeof view === 'object' ? view : {};
|
|
765
762
|
return {
|
|
766
763
|
panelUrl: typeof value.panelUrl === 'string' ? value.panelUrl : '',
|
|
767
764
|
panelScope: typeof value.panelScope === 'string' ? value.panelScope : '',
|
|
768
765
|
webAccess: value.webAccess && typeof value.webAccess.enabled === 'boolean' ? value.webAccess : null,
|
|
766
|
+
// 图标与入口那一句要用的现场:配了几台手机、链路有没有断。与上面三样同一条 `/status`,
|
|
767
|
+
// 不多打一次接口 —— 那份读数本来就是「此刻这台宿主怎么样」。
|
|
768
|
+
devices: value.devices && typeof value.devices === 'object' ? value.devices : null,
|
|
769
|
+
fault: faultKeyOf(value),
|
|
769
770
|
};
|
|
770
771
|
}
|
|
771
772
|
|
|
773
|
+
/**
|
|
774
|
+
* 「链路有没有毛病」:只有明确报错的才算,拿不准的一律当正常。
|
|
775
|
+
*
|
|
776
|
+
* 只认两条实打实的失败:隧道 `state === 'error'`(中转连不上 / 被准入拒了)与旁挂进程
|
|
777
|
+
* 报错(`error: …`)。`starting` / `off` / 没开中转 都是正常态 —— 把「还没起来」也报成
|
|
778
|
+
* 黄点,等于每次启动都先闪一下假警。判据比调试页那套窄:那一页是给人排查用的,宁可多说;
|
|
779
|
+
* 这一颗常驻在侧边栏,只该在「现在确实坏了」的时候变脸。
|
|
780
|
+
*/
|
|
781
|
+
function faultKeyOf(view) {
|
|
782
|
+
const value = view && typeof view === 'object' ? view : {};
|
|
783
|
+
const tunnel = value.tunnel && typeof value.tunnel === 'object' ? value.tunnel : {};
|
|
784
|
+
if (value.enabled && tunnel.state === 'error') return 'footerTunnelBad';
|
|
785
|
+
const sidecar = value.sidecar && typeof value.sidecar === 'object' ? value.sidecar : {};
|
|
786
|
+
if (typeof sidecar.state === 'string' && sidecar.state.startsWith('error')) return 'footerSidecarBad';
|
|
787
|
+
return '';
|
|
788
|
+
}
|
|
789
|
+
|
|
772
790
|
/**
|
|
773
791
|
* 配置页在**这个页面自己**的同源地址上。
|
|
774
792
|
*
|
|
@@ -789,22 +807,28 @@ window.__ModuleLoader__.load({
|
|
|
789
807
|
}
|
|
790
808
|
|
|
791
809
|
/**
|
|
792
|
-
*
|
|
810
|
+
* 面板里的某一页在**这个页面自己**的同源地址上(不是宿主报的那个绝对地址)。
|
|
793
811
|
*
|
|
794
812
|
* 这里必须按 `document.baseURI` 推,**不能用面板那个绝对 http(s) 地址**:桌面版前端挂在
|
|
795
813
|
* `dsh-app://app/` 下(Electron 把 `dsh-app` 当安全协议),往里面塞一条 http 的 iframe
|
|
796
814
|
* 会被当成混合内容挡掉 —— 现场就是 `isWebPage()` 为假、退回「交给系统浏览器」,点了照旧跳走。
|
|
797
|
-
* 用相对地址推出来的是 `dsh-app://app/api/relay/panel/
|
|
815
|
+
* 用相对地址推出来的是 `dsh-app://app/api/relay/panel/console`:与页面同源,壳的协议处理器
|
|
798
816
|
* 会把 `/api/*` 转给本机宿主(客户端半边那些 `api/relay/status` 请求一直就是这么走的)。
|
|
799
817
|
* 反代挂子路径时 `baseURI` 自带前缀,这一条也顺带管住了。
|
|
818
|
+
*
|
|
819
|
+
* **2026-11-13 起地址只认这一条**:云服务器上用户是用公网 IP / 域名打开 DSH 的,而宿主
|
|
820
|
+
* 按 Host 头拼出来的 `panelUrl` 常常是 `127.0.0.1:<端口>` —— 拿它去开窗,浏览器就跑到
|
|
821
|
+
* 用户自己那台电脑上找服务,必然打不开。`baseURI` 是**用户此刻正在用的地址**,公网打开
|
|
822
|
+
* 就是公网、反代子路径自带前缀,这才是对的。`panel` 只用来决定「要不要开两小时窗口」,
|
|
823
|
+
* 不再决定「开到哪儿去」。
|
|
800
824
|
*/
|
|
801
|
-
function
|
|
825
|
+
function panelPageUrlOf(page) {
|
|
802
826
|
try {
|
|
803
827
|
const base = typeof document !== 'undefined' && document.baseURI
|
|
804
828
|
? document.baseURI
|
|
805
829
|
: (typeof location !== 'undefined' ? location.href : '');
|
|
806
830
|
if (!base) return '';
|
|
807
|
-
return new URL(
|
|
831
|
+
return new URL(`api/relay/panel${page ? `/${page}` : ''}`, base).href;
|
|
808
832
|
} catch {
|
|
809
833
|
return '';
|
|
810
834
|
}
|
|
@@ -924,6 +948,8 @@ window.__ModuleLoader__.load({
|
|
|
924
948
|
const FOOTER_MARK = 'data-dshm-mobile-web';
|
|
925
949
|
/** 告警态的记号:宿主那一半没装载(`/status` 404)时,整颗转红并显出右上角那颗红点。 */
|
|
926
950
|
const FOOTER_ALERT = 'data-dshm-alert';
|
|
951
|
+
/** 中间那一档:确实有问题但还没到「插件坏了」。同一颗点,颜色换琥珀。 */
|
|
952
|
+
const FOOTER_WARN = 'data-dshm-warn';
|
|
927
953
|
/** 还没问到网页地址时的重试间隔。取到就停,不再问。 */
|
|
928
954
|
const FOOTER_URL_RETRY_MS = 20000;
|
|
929
955
|
/**
|
|
@@ -997,25 +1023,28 @@ window.__ModuleLoader__.load({
|
|
|
997
1023
|
}
|
|
998
1024
|
|
|
999
1025
|
/**
|
|
1000
|
-
* 把「打开哪一页 /
|
|
1026
|
+
* 把「打开哪一页 / 现在是什么状态」同步到元素上。
|
|
1001
1027
|
*
|
|
1002
1028
|
* 没有地址时**不写 href**(没有地址可写,别挂死链),但**点击处理照样挂上**:那颗图标的
|
|
1003
1029
|
* 点击会自己去把两小时窗口开出来、再读一次地址(见 `openConfigurationPage`)。别把
|
|
1004
1030
|
* `onclick` 一起摘掉 —— 摘了就是「点了完全没反应」。
|
|
1005
1031
|
*
|
|
1032
|
+
* `tone` 三档:`''` 正常、`'warn'` 有问题但插件没坏(琥珀)、`'error'` 真故障(红)。
|
|
1033
|
+
* 换的只是记号与颜色,图形和尺寸一个像素都不动 —— 那一行是外壳的,动尺寸就会挤到别人。
|
|
1034
|
+
*
|
|
1006
1035
|
* 地址、网络类别和窗口状态都由 effect 往上同步,组件重渲染不会把它丢掉。
|
|
1007
1036
|
*/
|
|
1008
|
-
function syncFooterIcon(node,
|
|
1009
|
-
const label = url ? openLabel : pendingLabel;
|
|
1037
|
+
function syncFooterIcon(node, { href, label, onClick, tone }) {
|
|
1010
1038
|
node.setAttribute('aria-label', label);
|
|
1011
1039
|
node.setAttribute('title', label);
|
|
1012
1040
|
node.setAttribute('aria-disabled', 'false');
|
|
1013
|
-
|
|
1014
|
-
if (alert) node.setAttribute(FOOTER_ALERT, '');
|
|
1041
|
+
if (tone === 'error') node.setAttribute(FOOTER_ALERT, '');
|
|
1015
1042
|
else node.removeAttribute(FOOTER_ALERT);
|
|
1043
|
+
if (tone === 'warn') node.setAttribute(FOOTER_WARN, '');
|
|
1044
|
+
else node.removeAttribute(FOOTER_WARN);
|
|
1016
1045
|
// 有地址时仍然写 `href`:普通链接照旧能中键 / 新标签打开。只有「浏览器不是从本机来的」
|
|
1017
1046
|
// 那两种情况要拦下来先开窗口,见 `openPanel`。
|
|
1018
|
-
if (
|
|
1047
|
+
if (href) node.setAttribute('href', href);
|
|
1019
1048
|
else node.removeAttribute('href');
|
|
1020
1049
|
node.onclick = onClick;
|
|
1021
1050
|
}
|
|
@@ -1073,6 +1102,10 @@ window.__ModuleLoader__.load({
|
|
|
1073
1102
|
const [panelScope, setPanelScope] = useState('');
|
|
1074
1103
|
/** 最近一次读状态失败的原因(`null` = 没失败过);`status: 404` = 实现那一半没装载。 */
|
|
1075
1104
|
const [problem, setProblem] = useState(null);
|
|
1105
|
+
/** 链路报错的键(`footerTunnelBad` / `footerSidecarBad`);`''` = 没报错。 */
|
|
1106
|
+
const [fault, setFault] = useState('');
|
|
1107
|
+
/** 标题上那句「现在什么情况」(几台设备、多久没连过);读不到现场时是空串。 */
|
|
1108
|
+
const [hint, setHint] = useState('');
|
|
1076
1109
|
/** 展开态是否已经插进设置那一行。插不上就自己占一行。 */
|
|
1077
1110
|
const [anchored, setAnchored] = useState(true);
|
|
1078
1111
|
const nodeRef = useRef(null);
|
|
@@ -1112,9 +1145,12 @@ window.__ModuleLoader__.load({
|
|
|
1112
1145
|
try {
|
|
1113
1146
|
const next = await call('/status');
|
|
1114
1147
|
const view = next && typeof next === 'object' ? next : {};
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1148
|
+
const summary = readStatusView(view);
|
|
1149
|
+
setUrl(summary.panelUrl);
|
|
1150
|
+
setWebAccess(summary.webAccess);
|
|
1151
|
+
setPanelScope(summary.panelScope);
|
|
1152
|
+
setFault(summary.fault);
|
|
1153
|
+
setHint(hintOf(summary));
|
|
1118
1154
|
setProblem(null);
|
|
1119
1155
|
return { ok: true, status: view };
|
|
1120
1156
|
} catch (error) {
|
|
@@ -1123,10 +1159,64 @@ window.__ModuleLoader__.load({
|
|
|
1123
1159
|
message: String((error && error.message) || error),
|
|
1124
1160
|
};
|
|
1125
1161
|
setProblem(failed);
|
|
1162
|
+
// 读不到现场就把那句话撤掉:留着上一轮那句「2 台设备 · 3 分钟前」会让人以为
|
|
1163
|
+
// 现场还是那样,而其实这一刻我们什么都不知道。
|
|
1164
|
+
setHint('');
|
|
1126
1165
|
return { ok: false, problem: failed };
|
|
1127
1166
|
}
|
|
1128
1167
|
}
|
|
1129
1168
|
|
|
1169
|
+
/**
|
|
1170
|
+
* 标题那一句「现在是什么情况」。
|
|
1171
|
+
*
|
|
1172
|
+
* 只有读到链路现场时才说得出口;地址还没有、或者读失败时这一句是空的,标题退回
|
|
1173
|
+
* 「还没就绪」/「宿主没装载」那两句固定的。设备台数为 0 时说「还没配对过」——
|
|
1174
|
+
* 那是「去配一台」的提示,不是故障。
|
|
1175
|
+
*/
|
|
1176
|
+
function hintOf(summary) {
|
|
1177
|
+
if (!summary || !summary.panelUrl) return '';
|
|
1178
|
+
if (summary.fault) return t(summary.fault);
|
|
1179
|
+
const devices = summary.devices;
|
|
1180
|
+
if (devices) {
|
|
1181
|
+
const count = Number(devices.count) || 0;
|
|
1182
|
+
if (count === 0) return t('footerNoDevice');
|
|
1183
|
+
const ago = relativeAgo(devices.lastSeenAt);
|
|
1184
|
+
return ago ? t('footerDeviceSeen', { count, ago }) : t('footerDeviceCount', { count });
|
|
1185
|
+
}
|
|
1186
|
+
return '';
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
/**
|
|
1190
|
+
* 三档状态:正常 / 有问题(琥珀)/ 真故障(红)。
|
|
1191
|
+
*
|
|
1192
|
+
* 红只留给「点了也没用」的那一种(宿主那一半没装载);链路报错是琥珀——面板还能开,
|
|
1193
|
+
* 只是现在连不通。地址还没读到(后台重试中)与窗口关着被回 423 都算正常态:
|
|
1194
|
+
* 那种情况每开一次页面都会出现,一有它就变脸等于天天报假警。
|
|
1195
|
+
*/
|
|
1196
|
+
function footerState() {
|
|
1197
|
+
if (hostMissing) return { tone: 'error', label: loadMissingLabel };
|
|
1198
|
+
if (fault) return { tone: 'warn', label: hint ? `${t(fault)} · ${openLabel}` : openLabel };
|
|
1199
|
+
if (!url) return { tone: '', label: pendingLabel };
|
|
1200
|
+
return { tone: '', label: hint ? `${hint} · ${openLabel}` : openLabel };
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
/**
|
|
1204
|
+
* 「多久以前」:只给三个够用的颗粒度。
|
|
1205
|
+
*
|
|
1206
|
+
* 侧边栏那一句靠人一眼扫过去,精确到秒没有意义;而「3 分钟前 / 2 小时前 / 昨天」正好
|
|
1207
|
+
* 对应「刚在用 / 今天用过 / 隔了点时间」。没有时间戳(`0`)返回空串,调用方退回只说台数。
|
|
1208
|
+
*/
|
|
1209
|
+
function relativeAgo(at) {
|
|
1210
|
+
const stamp = Number(at) || 0;
|
|
1211
|
+
if (!stamp) return '';
|
|
1212
|
+
const minutes = Math.floor((Date.now() - stamp) / 60000);
|
|
1213
|
+
if (minutes < 1) return t('footerAgoNow');
|
|
1214
|
+
if (minutes < 60) return t('footerAgoMinutes', { count: minutes });
|
|
1215
|
+
const hours = Math.floor(minutes / 60);
|
|
1216
|
+
if (hours < 24) return t('footerAgoHours', { count: hours });
|
|
1217
|
+
return t('footerAgoDays', { count: Math.floor(hours / 24) });
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1130
1220
|
/**
|
|
1131
1221
|
* 点下去要做什么,取决于面板地址落在哪一类网络上(宿主在 `/status` 上算的 `panelScope`)。
|
|
1132
1222
|
*
|
|
@@ -1194,96 +1284,51 @@ window.__ModuleLoader__.load({
|
|
|
1194
1284
|
if (typeof document === 'undefined') return { ok: false, missing: false, status: 0, message: t('panelMissing') };
|
|
1195
1285
|
const outcome = await openConfigurationPage({ view, loadStatus, t, target: null, confirmed: true, navigate: false });
|
|
1196
1286
|
if (!outcome.ok) return outcome;
|
|
1197
|
-
const
|
|
1198
|
-
|
|
1287
|
+
const consolePage = panelPageUrlOf('console');
|
|
1288
|
+
const debugPage = panelPageUrlOf('debug');
|
|
1289
|
+
if (!consolePage) return { ok: false, missing: false, status: 0, message: t('panelMissing') };
|
|
1199
1290
|
const dialog = diagnosisDialog();
|
|
1200
1291
|
|
|
1201
1292
|
/**
|
|
1202
|
-
*
|
|
1293
|
+
* 点一下手机图标,**直接就是这一屏控制台**(2026-11-13 用户拍板)。
|
|
1203
1294
|
*
|
|
1204
|
-
*
|
|
1205
|
-
*
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
actions: [
|
|
1213
|
-
{
|
|
1214
|
-
label: t('consoleOpenBrowser'),
|
|
1215
|
-
primary: true,
|
|
1216
|
-
onClick: () => {
|
|
1217
|
-
if (typeof window !== 'undefined' && typeof window.open === 'function') {
|
|
1218
|
-
const opened = window.open(outcome.url, '_blank', 'noreferrer');
|
|
1219
|
-
if (opened) dialog.hide();
|
|
1220
|
-
}
|
|
1221
|
-
},
|
|
1222
|
-
},
|
|
1223
|
-
{ label: t('diagCopy'), onClick: () => void copyConsole() },
|
|
1224
|
-
{ label: t('consoleBack'), onClick: () => showEntry() },
|
|
1225
|
-
{ label: t('diagClose'), onClick: () => dialog.hide() },
|
|
1226
|
-
],
|
|
1227
|
-
});
|
|
1228
|
-
};
|
|
1229
|
-
|
|
1230
|
-
/**
|
|
1231
|
-
* 第一层:**只有一个简单入口**。
|
|
1295
|
+
* 改掉的是原先那两层:第一层「进入控制台 / 报错调试」两块大按钮、第二层才是页面。
|
|
1296
|
+
* 理由有两条:
|
|
1297
|
+
* 1. 那一层唯一的作用是让人多按一次 —— 而这一窗存在的意义就是「点进来就能扫码 /
|
|
1298
|
+
* 看手机连没连上」,中间夹一层只是把正门多砌一道门槛;
|
|
1299
|
+
* 2. 那颗「进入控制台」以前是**跳去浏览器**,用的是宿主报的 `panelUrl`。云服务器上
|
|
1300
|
+
* 用户从公网 IP 打开 DSH 时,那个地址常常是本机的 `127.0.0.1:端口`,跳过去必然
|
|
1301
|
+
* 打不开。现在整页就地嵌、地址按 `document.baseURI` 推(见 `panelPageUrlOf`),
|
|
1302
|
+
* 公网、域名、反代子路径三种都能对上。
|
|
1232
1303
|
*
|
|
1233
|
-
*
|
|
1234
|
-
*
|
|
1235
|
-
* 右边「报错调试」(才进第二层那一屏)。
|
|
1304
|
+
* 调试页没删:它退到操作栏里的「报错调试」一颗按钮(次要样式)。那一屏是排障用的,
|
|
1305
|
+
* 不该跟日常那一屏抢第一眼。
|
|
1236
1306
|
*/
|
|
1237
|
-
const
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
body: choices.body,
|
|
1243
|
-
actions: [{ label: t('diagClose'), onClick: () => dialog.hide() }],
|
|
1244
|
-
});
|
|
1245
|
-
choices.console.onclick = () => {
|
|
1246
|
-
const opened = typeof window !== 'undefined' && typeof window.open === 'function'
|
|
1247
|
-
? window.open(outcome.url, '_blank', 'noreferrer')
|
|
1248
|
-
: null;
|
|
1249
|
-
if (opened) dialog.hide();
|
|
1250
|
-
else dialog.note(t('consolePopupBlocked'));
|
|
1251
|
-
};
|
|
1252
|
-
choices.debug.onclick = () => showDebug();
|
|
1307
|
+
const openBrowser = (page) => {
|
|
1308
|
+
if (typeof window === 'undefined' || typeof window.open !== 'function') return;
|
|
1309
|
+
const opened = window.open(page || consolePage, '_blank', 'noreferrer');
|
|
1310
|
+
if (opened) dialog.hide();
|
|
1311
|
+
else dialog.note(t('consolePopupBlocked'));
|
|
1253
1312
|
};
|
|
1254
1313
|
|
|
1255
|
-
|
|
1314
|
+
dialog.open({
|
|
1315
|
+
title: t('consoleTitle'),
|
|
1316
|
+
wide: true,
|
|
1317
|
+
frame: {
|
|
1318
|
+
src: consolePage,
|
|
1319
|
+
title: t('consoleTitle'),
|
|
1320
|
+
hint: t('consoleFrameless'),
|
|
1321
|
+
},
|
|
1322
|
+
actions: [
|
|
1323
|
+
{ label: t('consoleOpenBrowser'), primary: true, onClick: () => openBrowser(consolePage) },
|
|
1324
|
+
{ label: t('consoleTroubleshoot'), onClick: () => openBrowser(debugPage) },
|
|
1325
|
+
{ label: t('diagCopy'), onClick: () => void copyConsole() },
|
|
1326
|
+
{ label: t('diagClose'), onClick: () => dialog.hide() },
|
|
1327
|
+
],
|
|
1328
|
+
});
|
|
1256
1329
|
return { ok: true, webAccess: outcome.webAccess };
|
|
1257
1330
|
}
|
|
1258
1331
|
|
|
1259
|
-
/**
|
|
1260
|
-
* 入口那两块(左「进入控制台」、右「报错调试」)。
|
|
1261
|
-
*
|
|
1262
|
-
* 命令式 DOM,不用 react:客户端半边不经构建。两块都是大按钮,图标 + 标题 + 一句说明,
|
|
1263
|
-
* 点到哪里自己负责 —— 这里只造节点、把两张卡交给调用方填 onclick。
|
|
1264
|
-
*/
|
|
1265
|
-
function makeChoiceGrid(dialog, t) {
|
|
1266
|
-
const doc = typeof document !== 'undefined' ? document : null;
|
|
1267
|
-
const make = (tag, className, text) => {
|
|
1268
|
-
const element = doc.createElement(tag);
|
|
1269
|
-
if (className) element.className = className;
|
|
1270
|
-
if (text !== undefined) element.textContent = String(text);
|
|
1271
|
-
return element;
|
|
1272
|
-
};
|
|
1273
|
-
const body = make('div', 'dshm_choices');
|
|
1274
|
-
const card = (title, hint, tone) => {
|
|
1275
|
-
const button = make('button', 'dshm_choice' + (tone ? ` ${tone}` : ''));
|
|
1276
|
-
button.setAttribute('type', 'button');
|
|
1277
|
-
button.appendChild(make('span', 'dshm_choiceTitle', title));
|
|
1278
|
-
button.appendChild(make('span', 'dshm_choiceHint', hint));
|
|
1279
|
-
body.appendChild(button);
|
|
1280
|
-
return button;
|
|
1281
|
-
};
|
|
1282
|
-
const console = card(t('consoleEntryConsole'), t('consoleEntryConsoleHint'), 'dshm_choicePrimary');
|
|
1283
|
-
const debug = card(t('consoleEntryDebug'), t('consoleEntryDebugHint'), '');
|
|
1284
|
-
return { body, console, debug };
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
1332
|
/** 把「复制诊断信息」那一套复用在控制台上:读的是嵌入页同样的几份,不另开一套。 */
|
|
1288
1333
|
async function copyConsole() {
|
|
1289
1334
|
const dialog = diagnosisDialog();
|
|
@@ -1549,9 +1594,12 @@ window.__ModuleLoader__.load({
|
|
|
1549
1594
|
setAnchored(false);
|
|
1550
1595
|
return undefined;
|
|
1551
1596
|
}
|
|
1552
|
-
//
|
|
1553
|
-
|
|
1554
|
-
const sync = () =>
|
|
1597
|
+
// 标题与颜色都由这一份状态得出:没地址时说「为什么没有」(404 = 宿主没装载,
|
|
1598
|
+
// 其余 = 还没就绪),有地址时说现场(几台设备、多久没连过、链路有没有报错)。
|
|
1599
|
+
const sync = () => {
|
|
1600
|
+
const state = footerState();
|
|
1601
|
+
syncFooterIcon(node, { href: url, label: state.label, onClick: openPanel, tone: state.tone });
|
|
1602
|
+
};
|
|
1555
1603
|
let attached = false;
|
|
1556
1604
|
try {
|
|
1557
1605
|
attached = ensureFooterIcon(doc, node);
|
|
@@ -1589,20 +1637,21 @@ window.__ModuleLoader__.load({
|
|
|
1589
1637
|
if (frame !== 0 && typeof cancelAnimationFrame === 'function') cancelAnimationFrame(frame);
|
|
1590
1638
|
if (typeof node.remove === 'function' && node.parentElement) node.remove();
|
|
1591
1639
|
};
|
|
1592
|
-
}, [wide, url, openLabel, loadMissingLabel, pendingLabel, problem, panelScope, webAccess]);
|
|
1640
|
+
}, [wide, url, openLabel, loadMissingLabel, pendingLabel, problem, panelScope, webAccess, hint, fault]);
|
|
1593
1641
|
|
|
1594
1642
|
// 窄条,或者这一版外壳里认不出那一行:自己占一行,入口不能因为认不出位置就消失。
|
|
1595
1643
|
if (!wide || !anchored) {
|
|
1596
|
-
const
|
|
1644
|
+
const state = footerState();
|
|
1597
1645
|
return h('a', {
|
|
1598
1646
|
className: 'dshm_footAction dshm_footActionRail',
|
|
1599
1647
|
href: url || undefined,
|
|
1600
1648
|
target: '_blank',
|
|
1601
1649
|
rel: 'noreferrer',
|
|
1602
|
-
'aria-label': label,
|
|
1603
|
-
title: label,
|
|
1650
|
+
'aria-label': state.label,
|
|
1651
|
+
title: state.label,
|
|
1604
1652
|
'aria-disabled': 'false',
|
|
1605
|
-
[FOOTER_ALERT]:
|
|
1653
|
+
[FOOTER_ALERT]: state.tone === 'error' ? '' : undefined,
|
|
1654
|
+
[FOOTER_WARN]: state.tone === 'warn' ? '' : undefined,
|
|
1606
1655
|
onClick: openPanel,
|
|
1607
1656
|
}, h('svg', {
|
|
1608
1657
|
viewBox: '0 0 24 24',
|
package/lib/impl.js
CHANGED
|
@@ -55,6 +55,8 @@ const { installSessionCleanup } = require('./session-cleanup.cjs')
|
|
|
55
55
|
const statsScheduler = require('./mobile/stats-scheduler.cjs')
|
|
56
56
|
// 扩展卡的宿主侧:`extension_present` 工具与卡状态账本(见 mobile/extensions.js)。
|
|
57
57
|
const { installExtensions } = require('./mobile/extensions.js')
|
|
58
|
+
// 给模型用的工作区 / 会话能力:列、读、发、停、新建与整理(见 mobile/workspace-tools.js)。
|
|
59
|
+
const { installWorkspaceTools } = require('./mobile/workspace-tools.js')
|
|
58
60
|
const { activeGuard } = require('./host-guard.cjs')
|
|
59
61
|
// 桌面端侧栏展开态的快照存储。桌面把这份状态只记在浏览器 localStorage 里,宿主必须
|
|
60
62
|
// 有一个落盘处:客户端半边(lib/client.js)上报 → 这里 → 移动端读取。
|
|
@@ -396,6 +398,13 @@ function apply(ctx) {
|
|
|
396
398
|
}
|
|
397
399
|
return undefined
|
|
398
400
|
}, `${name}: extension tool`)
|
|
401
|
+
ctx.effect(() => {
|
|
402
|
+
// 与上面两块同一口径:没有 tools 注入的 profile 只少这个工具。
|
|
403
|
+
try { installWorkspaceTools(ctx) } catch (error) {
|
|
404
|
+
if (!String(error).includes('without inject')) throw error
|
|
405
|
+
}
|
|
406
|
+
return undefined
|
|
407
|
+
}, `${name}: workspace tool`)
|
|
399
408
|
mount('统计采集', () => ctx.effect(() => statsScheduler.start(ctx), `${name}: stats collect`))
|
|
400
409
|
mount('过程播报', () => ctx.effect(() => installNarration(ctx), `${name}: process narration`))
|
|
401
410
|
|