Files
MemRelay/projects/d5a7f581-c442-4554-87b9-ee723b8b0258/Checkpoint 2026-11-06 21-29-37 UTC [785e21541f].md
T
memrelay 1c161eba7d create: Checkpoint 2026-11-06 21:29:37 UTC [785e21541f]
MemRelay-Operation: checkpoint-save:fe-host-agent-2026-11-07-a1
MemRelay-Resource: f7c5e242-e271-4172-a0eb-9767373c0974
2026-11-07 05:29:39 +08:00

42 lines
3.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: Checkpoint 2026-11-06 21:29:37 UTC [785e21541f]
type: checkpoint
permalink: main/projects/d5a7f581-c442-4554-87b9-ee723b8b0258/checkpoint-2026-11-06-21-29-37-utc-785e21541f
stable_id: f7c5e242-e271-4172-a0eb-9767373c0974
scope: project
memory_type: checkpoint
project_id: d5a7f581-c442-4554-87b9-ee723b8b0258
usage_profile_id: 0c9feb46-d06e-43cd-9ef0-c5813c84a998
status: active
revision: 1
request_id: fe-host-agent-2026-11-07-a1
created_at: '2026-11-06T21:29:37.219722+00:00'
updated_at: '2026-11-06T21:29:37.219722+00:00'
tags:
- host-agent
- frontend
- time-sync
---
# 宿主机代理计划:前端部分完成(未提交)
## 完成内容
- 分支 feat/host-agent,按计划「四、前端」和 Temp/host-agent/CONTRACT.md 实现 fe-announcements / fe-metrics / fe-timesync / fe-settings,均未提交(协调者负责提交)。
- 新模块 web/src/modules/host/:index.ts(无页面)、permissions.ts、enabled.ts(canUseHost:模块启用且有权限)、types.ts、api.ts(管理类请求带超时)、format.ts、onlineTime.ts、timeSync.ts、adapterForm.ts、adapterValidation.ts、i18n 中英文(含契约错误码、额外的 hostNtpServerInvalid/hostTimeSourceInvalid、审计动作 host.* 与目标类型)。
- 组件:HostMetricsStrip、TimeSyncButton、HostSettingsPanel 及 HostAgentSection/HostNtpSection/HostTimeSyncSection/HostAdaptersSection、AdapterEditorModal、PluginFieldsForm、HttpFlowEditor、PlaceholderPicker、AdapterTestResult。
- DashboardView:公告可收起为 52px 竖条(localStorage 键 appKey('dashboard.announcements.collapsed'),窄屏只留标题栏)、ResizeObserver 尺寸变化时重新生成粒子、服务器时间去掉时区并用往返中点、host:read 时显示性能四卡、host:time_sync 时显示同步按钮(异步组件)。
- SystemSettingsView:新增「宿主机」页签(host:manage,show:lazy),该页签隐藏底部全局保存按钮,各区块自带保存。
## 关键实现
- 同步完全静默:TimeSyncButton 只在 status.time_sync.available 时显示,requestIdleCallback(否则 3 秒)后自动同步;localStorage 键 appKey('host.timeSync.autoAt') 写入 时间戳:随机串 后短暂等待再读回,实现多标签页只有一个发起、10 分钟一次;timeSync/onlineTime 为独立懒加载 chunk。
- 网络时间:并行 fetch priority low + 3 秒超时,整秒来源 +500ms 补偿,优先毫秒精度字段;中位数、剔除偏离超 2 秒、剩余少于成功数一半视为无结果。
## 验证
- npm run typecheck、npm run test:smoke 通过;生产构建用 vite build --outDir 临时目录通过(没有写 web/dist,因为 8131 实例从本仓库 web/dist 启动并缓存 index.html,覆盖会破坏它)。
- 用临时脚本验证了响应格式识别与中位数规则。
## 下一步 / 给下个会话
- 集成联调(8133/5181):浏览器检查首页零提示、公告收起、设置页各区块、动态表单、自定义流程预览/测试。
- 契约外的前端假设:插件字段 options 为 {value,label} 或字符串;同步状态 busy/skipped 时不刷新服务器时间。
- 发布前需要正常执行 npm run build 生成 web/dist。