```
feat(target-lists): 切换至B方案行内编辑布局 - 名单管理页改为左侧分类导航、右侧宽表格,编辑在对应记录行下展开 - 新增条目按钮触发行内表单,筛选或分页时草稿保留在表格顶部 - 登记模块增加beforeunload保护,区分保存中与未保存状态 - 外观模块增加beforeunload保护并修复偏好拉取的竞态问题 - 地图定位面板调整底部内边距和标题间距 - 更新相关测试脚本适配新交互流程 ```
This commit is contained in:
@@ -9,6 +9,18 @@
|
|||||||
|
|
||||||
继续遵守全局目标重述、品质自检及 UI 多方案先选后改规则。涉及 UI 新设计或大幅修改时,读取 `C:/Users/20143/.codex/skills/ui-design-choice-gate/SKILL.md`,先展示多个方案并等待明确选择;不能直接改正式界面。
|
继续遵守全局目标重述、品质自检及 UI 多方案先选后改规则。涉及 UI 新设计或大幅修改时,读取 `C:/Users/20143/.codex/skills/ui-design-choice-gate/SKILL.md`,先展示多个方案并等待明确选择;不能直接改正式界面。
|
||||||
|
|
||||||
|
## UI 改动后必须运行最新项目供用户检查
|
||||||
|
|
||||||
|
- 每批正式 UI 改动完成、准备交付时,必须重新构建并运行最新项目,让用户直接检查效果;不得只修改源码、通过测试或展示独立原型后就宣布完成。适用于页面结构、菜单、文字、样式、图标、图片以及影响界面行为的 Rust/Wasm 或 JavaScript 改动。
|
||||||
|
- 先使用 `. ./scripts/rust-env.ps1`,按现有流程依次执行 `cargo xtask web` 和 `cargo build --release --locked -p fpv-rid-registry --bin fpv-rid-registry-fullstack`。前端资源嵌入后端可执行文件,只构建前端或刷新旧程序不能证明改动生效;任一步失败即停止交付并处理问题。若 Windows 下目标 EXE 被当前实例占用,先核对进程身份、确认无活动任务并保留可恢复的旧程序,再安全停止该实例后构建;构建失败时恢复可用版本并明确其仍为旧界面。
|
||||||
|
- 启动前核对 `127.0.0.1:8787` 的监听进程、实际可执行文件与 `--data-root`。使用本次构建的最新 Release 程序,保留当前业务数据目录及原有档案、照片和设置;不得误启动旧的日期预览包,或以空白测试数据库冒充用户正在使用的项目。
|
||||||
|
- 本项目的 UI HTTP 服务统一使用唯一端口 `127.0.0.1:8787`。重新运行时必须先核对并安全退出本项目旧实例,确认原端口已释放,再在同一端口启动最新版本;启动后核对监听进程,保持一个项目 UI 服务实例。发现本项目遗留的旧版或预览实例时,核实身份与活动状态后安全退出,不让它们常驻其他端口。
|
||||||
|
- 不得因端口占用而自动换端口,也不得通过 `RID_TEST_PORT`、临时代理、备用端口或额外预览服务绕开旧实例。需要启动 UI HTTP 服务的验收测试同样遵守单端口要求,采用同端口串行验证,并在完成后恢复最新正式实例;现有多端口测试脚本不能直接作为例外运行。若原端口被其他程序占用或暂时无法安全释放,应说明阻碍,不误停其他程序、不擅自增加端口。
|
||||||
|
- 本规则包含用户对必要本地构建、启动及安全重启本项目实例的持续授权,无需等待用户再次说“运行一下”。重启前检查正在保存、设备接收和地图下载等活动;不得强制打断活动任务、误停其他实例或迁移、重置、覆盖业务数据。
|
||||||
|
- 启动后确认监听进程确为最新程序,并在浏览器打开实际运行地址及本次改动页面,核对界面、关键交互、菜单切换和控制台错误。提供可点击的页面链接,说明改动具体位于哪里;视觉变化提供本地截图或直接展示页面,不能仅以进程存在或编译成功代替界面验收。
|
||||||
|
- 若原页面仍加载旧资源,应刷新并复核实际响应资源与构建产物一致。交付时简述改动位置、运行地址、实际运行版本的路径或进程标识及浏览器验证结果;构建、测试、实际运行和真实设备验证分别报告。
|
||||||
|
- 遇到工具权限拒绝、端口占用、活动任务或其他实际阻碍时,不绕过限制;明确报告“最新界面尚未运行/验证”、具体原因与必要的用户操作,不得宣称已更新运行版本。独立设计原型仍遵守先选后改规则;纯规则、文档及与 UI 无关的修改不触发本节的重新运行要求。
|
||||||
|
|
||||||
## 工具、依赖与文件夹管理
|
## 工具、依赖与文件夹管理
|
||||||
|
|
||||||
- 统一管理根目录为 `D:/Rust_Contact/util`:`cargo/` 为 CARGO_HOME,`rustup/` 为 RUSTUP_HOME,`target/Rid_Drone_Receivev/` 为本项目构建目录,`tools/` 管理独立工具,`downloads/` 保留安装包;新增原生 SDK 按 `native/<sdk>/<version>/<target>/` 存放。
|
- 统一管理根目录为 `D:/Rust_Contact/util`:`cargo/` 为 CARGO_HOME,`rustup/` 为 RUSTUP_HOME,`target/Rid_Drone_Receivev/` 为本项目构建目录,`tools/` 管理独立工具,`downloads/` 保留安装包;新增原生 SDK 按 `native/<sdk>/<version>/<target>/` 存放。
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,11 +1,11 @@
|
|||||||
/* Approved A workbench: only home, registration and appearance use this layout. */
|
/* Approved A workbench: only home, registration and appearance use this layout. */
|
||||||
body[data-screen=home] .home-launcher.homescreen {
|
body[data-screen=home] .home-launcher.homescreen {
|
||||||
inset: 48px 0 0 68px !important;
|
inset: 48px 0 0 0 !important;
|
||||||
margin: 0 !important;
|
margin: 0 !important;
|
||||||
padding: 34px 28px;
|
padding: 34px 28px;
|
||||||
container: home-workbench / inline-size;
|
container: home-workbench / inline-size;
|
||||||
}
|
}
|
||||||
body[data-screen=home][data-menu-hidden=true] .home-launcher.homescreen { left: 0 !important; }
|
body[data-screen=home] :is(.reference-rail, #toggle-menu) { display: none; }
|
||||||
.home-space { width: 100%; max-width: 1170px; }
|
.home-space { width: 100%; max-width: 1170px; }
|
||||||
.home-kicker { color: var(--work-muted); font-size: 11px; letter-spacing: .14em; margin-bottom: 10px; }
|
.home-kicker { color: var(--work-muted); font-size: 11px; letter-spacing: .14em; margin-bottom: 10px; }
|
||||||
.home-heading h1 { font-size: 27px; }
|
.home-heading h1 { font-size: 27px; }
|
||||||
@@ -188,7 +188,7 @@ body:is([data-screen=register], [data-screen=archives]) .registry-workspace #reg
|
|||||||
.setting-panel-head { padding: 0 16px; }
|
.setting-panel-head { padding: 0 16px; }
|
||||||
}
|
}
|
||||||
@media(max-width: 760px) {
|
@media(max-width: 760px) {
|
||||||
body[data-screen=home] .home-launcher.homescreen { left: 56px !important; padding: 28px 20px; }
|
body[data-screen=home] .home-launcher.homescreen { padding: 28px 20px; }
|
||||||
body[data-screen=home] .workspace-home-link > #workspace-brand { display: inline; font-size: 12px; }
|
body[data-screen=home] .workspace-home-link > #workspace-brand { display: inline; font-size: 12px; }
|
||||||
body[data-screen=home] #reference-title { display: none; }
|
body[data-screen=home] #reference-title { display: none; }
|
||||||
.home-heading h1 { font-size: 24px; }
|
.home-heading h1 { font-size: 24px; }
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
</div><nav class="pagination" aria-label="档案分页"><span id="page-status" aria-live="polite"></span><div><button id="previous-page" type="button">上一页</button><button id="next-page" type="button">下一页</button></div></nav>
|
</div><nav class="pagination" aria-label="档案分页"><span id="page-status" aria-live="polite"></span><div><button id="previous-page" type="button">上一页</button><button id="next-page" type="button">下一页</button></div></nav>
|
||||||
<p id="archive-warning" class="archive-warning" role="status" hidden><span id="archive-warning-text"></span> <button id="retry-archive" type="button">重试同步</button></p></aside>
|
<p id="archive-warning" class="archive-warning" role="status" hidden><span id="archive-warning-text"></span> <button id="retry-archive" type="button">重试同步</button></p></aside>
|
||||||
<section class="registration-editor" aria-labelledby="register-title"><header class="registration-heading"><div><h1 id="register-title">新建设备登记</h1><p>填写设备信息,生成本机登记二维码</p></div><span></span></header>
|
<section class="registration-editor" aria-labelledby="register-title"><header class="registration-heading"><div><h1 id="register-title">新建设备登记</h1><p>填写设备信息,生成本机登记二维码</p></div><span></span></header>
|
||||||
<form id="register-form" aria-labelledby="register-title"><div class="registration-fields-scroll"><section class="registry-group"><div class="registry-group-heading"><h2>设备身份</h2><span>仅模块 SN 必填</span></div><div class="registration-fields"><div class="registration-field full"><label for="serial-no">模块 SN <span aria-hidden="true">*</span></label><input id="serial-no" name="serialNo" required maxlength="40" autocomplete="off" pattern="[A-Za-z0-9-]{6,40}" placeholder="输入完整模块序列号"></div><div class="registration-field"><label for="model-name">机型 <small>选填</small></label><input id="model-name" name="modelName" maxlength="60" placeholder="例如:5 寸穿越机"></div><div class="registration-field"><label for="owner-name">登记人 / 备注 <small>选填</small></label><input id="owner-name" name="ownerName" maxlength="40" placeholder="方便后续查找"></div></div><p class="registry-help">SN 需与上位机模块一致;相同 SN 再次保存将更新原档案。</p></section>
|
<form id="register-form" aria-labelledby="register-title" novalidate><div class="registration-fields-scroll"><section class="registry-group"><div class="registry-group-heading"><h2>设备身份</h2><span>仅模块 SN 必填</span></div><div class="registration-fields"><div class="registration-field full"><label for="serial-no">模块 SN <span aria-hidden="true">*</span></label><input id="serial-no" name="serialNo" required maxlength="40" autocomplete="off" pattern="[A-Za-z0-9\-]{6,40}" aria-describedby="serial-no-hint serial-no-error" placeholder="输入完整模块序列号"><p id="serial-no-hint" class="registry-help">6–40 位英文字母、数字或半角连字符 -;请填写设备实际 SN,不支持中文名称。</p><p id="serial-no-error" class="form-message error" role="alert" hidden></p></div><div class="registration-field"><label for="model-name">机型 <small>选填</small></label><input id="model-name" name="modelName" maxlength="60" placeholder="例如:5 寸穿越机"></div><div class="registration-field"><label for="owner-name">登记人 / 备注 <small>选填</small></label><input id="owner-name" name="ownerName" maxlength="40" placeholder="方便后续查找"></div></div><p class="registry-help">SN 需与上位机模块一致;相同 SN 再次保存将更新原档案。</p></section>
|
||||||
<section class="registry-group"><div class="registry-group-heading"><h2>登记编号</h2><span>自动生成或手动填写</span></div><div class="registration-number"><div class="registration-field"><label for="uas-code">FPV 编号 <small>选填</small></label><div class="registration-prefix"><span aria-hidden="true">FPV</span><input id="uas-code" name="uasDigits" maxlength="8" inputmode="numeric" pattern="[0-9]{8}" aria-describedby="fpv-hint" placeholder="8 位数字 · 留空自动生成"></div></div><p id="fpv-hint" class="registry-help">已有编号仅填写后 8 位数字。<br>留空时,保存后自动生成。</p></div></section>
|
<section class="registry-group"><div class="registry-group-heading"><h2>登记编号</h2><span>自动生成或手动填写</span></div><div class="registration-number"><div class="registration-field"><label for="uas-code">FPV 编号 <small>选填</small></label><div class="registration-prefix"><span aria-hidden="true">FPV</span><input id="uas-code" name="uasDigits" maxlength="8" inputmode="numeric" pattern="[0-9]{8}" aria-describedby="fpv-hint uas-code-error" placeholder="8 位数字 · 留空自动生成"></div><p id="uas-code-error" class="form-message error" role="alert" hidden></p></div><p id="fpv-hint" class="registry-help">已有编号仅填写后 8 位数字。<br>留空时,保存后自动生成。</p></div></section>
|
||||||
<section class="registry-group"><div class="registry-group-heading"><h2>设备照片</h2><span>选填 · 最多 2 张</span></div><div class="registration-photos"><div class="photo-slot"><input id="photo-1" type="file" accept="image/jpeg,image/png,image/webp" data-photo-slot="0" hidden><button type="button" class="photo-pick" data-photo-choose="0" aria-label="添加照片 1"><img id="slot-preview-0" alt="照片 1预览" hidden><span class="photo-plus" aria-hidden="true">+</span><strong>添加照片 1</strong><span id="slot-name-0">点击选择本地图片</span></button><div class="photo-slot-actions"><button type="button" data-photo-remove="0" id="slot-remove-0" hidden>移除照片</button></div><button type="button" data-photo-keep="0" id="slot-keep-0" hidden>保留原选择</button><p id="slot-status-0" class="photo-status" role="status"></p></div><div class="photo-slot"><input id="photo-2" type="file" accept="image/jpeg,image/png,image/webp" data-photo-slot="1" hidden><button type="button" class="photo-pick" data-photo-choose="1" aria-label="添加照片 2"><img id="slot-preview-1" alt="照片 2预览" hidden><span class="photo-plus" aria-hidden="true">+</span><strong>添加照片 2</strong><span id="slot-name-1">点击选择本地图片</span></button><div class="photo-slot-actions"><button type="button" data-photo-remove="1" id="slot-remove-1" hidden>移除照片</button></div><button type="button" data-photo-keep="1" id="slot-keep-1" hidden>保留原选择</button><p id="slot-status-1" class="photo-status" role="status"></p></div></div><p class="registry-help">JPG、PNG、WebP · 每张不超过 5 MB · 仅保存在本机档案</p></section>
|
<section class="registry-group"><div class="registry-group-heading"><h2>设备照片</h2><span>选填 · 最多 2 张</span></div><div class="registration-photos"><div class="photo-slot"><input id="photo-1" type="file" accept="image/jpeg,image/png,image/webp" data-photo-slot="0" hidden><button type="button" class="photo-pick" data-photo-choose="0" aria-label="添加照片 1"><img id="slot-preview-0" alt="照片 1预览" hidden><span class="photo-plus" aria-hidden="true">+</span><strong>添加照片 1</strong><span id="slot-name-0">点击选择本地图片</span></button><div class="photo-slot-actions"><button type="button" data-photo-remove="0" id="slot-remove-0" hidden>移除照片</button></div><button type="button" data-photo-keep="0" id="slot-keep-0" hidden>保留原选择</button><p id="slot-status-0" class="photo-status" role="status"></p></div><div class="photo-slot"><input id="photo-2" type="file" accept="image/jpeg,image/png,image/webp" data-photo-slot="1" hidden><button type="button" class="photo-pick" data-photo-choose="1" aria-label="添加照片 2"><img id="slot-preview-1" alt="照片 2预览" hidden><span class="photo-plus" aria-hidden="true">+</span><strong>添加照片 2</strong><span id="slot-name-1">点击选择本地图片</span></button><div class="photo-slot-actions"><button type="button" data-photo-remove="1" id="slot-remove-1" hidden>移除照片</button></div><button type="button" data-photo-keep="1" id="slot-keep-1" hidden>保留原选择</button><p id="slot-status-1" class="photo-status" role="status"></p></div></div><p class="registry-help">JPG、PNG、WebP · 每张不超过 5 MB · 仅保存在本机档案</p></section>
|
||||||
<p class="form-message" id="form-message" role="status"></p></div><div class="registration-savebar"><span id="draft-state">保存时校验 SN 与编号</span><button class="primary" id="register-button" type="submit">保存登记并生成二维码 →</button></div></form></section><section class="result-panel registry-group" aria-labelledby="result-title" id="registration-result" tabindex="-1"><h2 id="result-title">二维码与核验</h2>
|
<p class="form-message" id="form-message" role="status"></p></div><div class="registration-savebar"><span id="draft-state">保存时校验 SN 与编号</span><button class="primary" id="register-button" type="submit">保存登记并生成二维码 →</button></div></form></section><section class="result-panel registry-group" aria-labelledby="result-title" id="registration-result" tabindex="-1"><h2 id="result-title">二维码与核验</h2>
|
||||||
<div id="empty-result" class="empty-state"><div class="empty-glyph"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><path d="M3 3h6v6H3z M15 3h6v6h-6z M3 15h6v6H3z M14 14h3v3h4v4h-7z"/></svg></div><div><b>等待完成登记</b><p>保存后自动生成二维码,供本地版上位机读取和核验。</p></div><ol><li>填写模块 SN</li><li>保存登记并生成二维码</li><li>在本地版上位机核验</li></ol></div><div id="record-result" class="record-result" hidden>
|
<div id="empty-result" class="empty-state"><div class="empty-glyph"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><path d="M3 3h6v6H3z M15 3h6v6h-6z M3 15h6v6H3z M14 14h3v3h4v4h-7z"/></svg></div><div><b>等待完成登记</b><p>保存后自动生成二维码,供本地版上位机读取和核验。</p></div><ol><li>填写模块 SN</li><li>保存登记并生成二维码</li><li>在本地版上位机核验</li></ol></div><div id="record-result" class="record-result" hidden>
|
||||||
|
|||||||
@@ -410,10 +410,63 @@ fn saving_controls(state: &Shared, busy: bool) {
|
|||||||
page_buttons(state);
|
page_buttons(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fn clear_field_error(id: &str) {
|
||||||
|
input(id).set_custom_validity("");
|
||||||
|
let _ = el(id).remove_attribute("aria-invalid");
|
||||||
|
text(&format!("{id}-error"), "");
|
||||||
|
hidden(&format!("{id}-error"), true);
|
||||||
|
}
|
||||||
|
fn validate_registration() -> bool {
|
||||||
|
for id in ["serial-no", "uas-code"] {
|
||||||
|
clear_field_error(id);
|
||||||
|
let field = input(id);
|
||||||
|
let value = value(id);
|
||||||
|
field.set_value(&value);
|
||||||
|
let error = if id == "serial-no" {
|
||||||
|
if value.is_empty() {
|
||||||
|
Some("请填写模块 SN(设备实际序列号),不是 FPV 编号。")
|
||||||
|
} else if !value
|
||||||
|
.bytes()
|
||||||
|
.all(|b| b.is_ascii_alphanumeric() || b == b'-')
|
||||||
|
{
|
||||||
|
Some("模块 SN 只能包含英文字母、数字或半角连字符 -,不能包含中文、空格或其他符号。")
|
||||||
|
} else if !(6..=40).contains(&value.len()) {
|
||||||
|
Some("模块 SN 长度须为 6–40 位,请核对设备实际序列号。")
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
} else if !value.is_empty()
|
||||||
|
&& (value.len() != 8 || !value.bytes().all(|b| b.is_ascii_digit()))
|
||||||
|
{
|
||||||
|
Some("FPV 编号请只填写 8 位数字;没有已有编号时请留空,保存后自动生成。")
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
if let Some(error) = error {
|
||||||
|
field.set_custom_validity(error);
|
||||||
|
let _ = field.set_attribute("aria-invalid", "true");
|
||||||
|
message(&format!("{id}-error"), error, true);
|
||||||
|
hidden(&format!("{id}-error"), false);
|
||||||
|
if let Ok(Some(container)) = field.closest(".registration-field") {
|
||||||
|
container.scroll_into_view_with_bool(true);
|
||||||
|
}
|
||||||
|
let _ = field.focus();
|
||||||
|
field.report_validity();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
async fn save(state: Shared, editing: bool) -> Result<()> {
|
async fn save(state: Shared, editing: bool) -> Result<()> {
|
||||||
if state.borrow().busy {
|
if state.borrow().busy {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
if !editing {
|
||||||
|
message("form-message", "", false);
|
||||||
|
if !validate_registration() {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
}
|
||||||
state.borrow_mut().busy = true;
|
state.borrow_mut().busy = true;
|
||||||
close_menu(&state, false);
|
close_menu(&state, false);
|
||||||
saving_controls(&state, true);
|
saving_controls(&state, true);
|
||||||
@@ -628,6 +681,12 @@ pub fn init() {
|
|||||||
{
|
{
|
||||||
state.borrow_mut().dirty = true;
|
state.borrow_mut().dirty = true;
|
||||||
text("draft-state", "有未保存的修改");
|
text("draft-state", "有未保存的修改");
|
||||||
|
message("form-message", "", false);
|
||||||
|
if let Some(target) = event.target().and_then(|t| t.dyn_into::<Element>().ok())
|
||||||
|
&& matches!(target.id().as_str(), "serial-no" | "uas-code")
|
||||||
|
{
|
||||||
|
clear_field_error(&target.id());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if event
|
if event
|
||||||
.target()
|
.target()
|
||||||
@@ -808,6 +867,9 @@ pub fn init() {
|
|||||||
}
|
}
|
||||||
state.borrow_mut().dirty = false;
|
state.borrow_mut().dirty = false;
|
||||||
text("draft-state", "保存时校验 SN 与编号");
|
text("draft-state", "保存时校验 SN 与编号");
|
||||||
|
for id in ["serial-no", "uas-code"] {
|
||||||
|
clear_field_error(id);
|
||||||
|
}
|
||||||
for id in [
|
for id in [
|
||||||
"serial-no",
|
"serial-no",
|
||||||
"model-name",
|
"model-name",
|
||||||
@@ -991,9 +1053,14 @@ pub fn init() {
|
|||||||
let state = state.clone();
|
let state = state.clone();
|
||||||
let unloading = Closure::<dyn FnMut(web_sys::BeforeUnloadEvent)>::new(
|
let unloading = Closure::<dyn FnMut(web_sys::BeforeUnloadEvent)>::new(
|
||||||
move |event: web_sys::BeforeUnloadEvent| {
|
move |event: web_sys::BeforeUnloadEvent| {
|
||||||
if state.borrow().busy {
|
let s = state.borrow();
|
||||||
|
if s.busy || s.dirty {
|
||||||
event.prevent_default();
|
event.prevent_default();
|
||||||
event.set_return_value("正在保存,请稍候");
|
event.set_return_value(if s.busy {
|
||||||
|
"正在保存,请稍候"
|
||||||
|
} else {
|
||||||
|
"登记内容尚未保存"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -176,6 +176,7 @@ fn apply(state: &Shared) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
async fn fetch_preferences(state: Shared) {
|
async fn fetch_preferences(state: Shared) {
|
||||||
|
let generation = state.borrow().generation;
|
||||||
let result = async {
|
let result = async {
|
||||||
let r = Request::get("/api/appearance")
|
let r = Request::get("/api/appearance")
|
||||||
.send()
|
.send()
|
||||||
@@ -190,7 +191,11 @@ async fn fetch_preferences(state: Shared) {
|
|||||||
match result {
|
match result {
|
||||||
Ok(p) => {
|
Ok(p) => {
|
||||||
let mut s = state.borrow_mut();
|
let mut s = state.borrow_mut();
|
||||||
if s.busy || s.dirty {
|
if s.busy
|
||||||
|
|| s.dirty
|
||||||
|
|| s.generation != generation
|
||||||
|
|| p["revision"].as_u64().unwrap_or(0) < s.prefs["revision"].as_u64().unwrap_or(0)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
s.prefs = p;
|
s.prefs = p;
|
||||||
@@ -198,7 +203,12 @@ async fn fetch_preferences(state: Shared) {
|
|||||||
drop(s);
|
drop(s);
|
||||||
apply(&state);
|
apply(&state);
|
||||||
}
|
}
|
||||||
Err(e) => message(&e, true),
|
Err(e) => {
|
||||||
|
let s = state.borrow();
|
||||||
|
if s.generation == generation && !s.busy && !s.dirty {
|
||||||
|
message(&e, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn queue_save(state: Shared) {
|
fn queue_save(state: Shared) {
|
||||||
@@ -533,6 +543,21 @@ pub fn init(realtime: bool) {
|
|||||||
dirty: false,
|
dirty: false,
|
||||||
}));
|
}));
|
||||||
apply(&state);
|
apply(&state);
|
||||||
|
let pending = state.clone();
|
||||||
|
let unloading = Closure::<dyn FnMut(web_sys::BeforeUnloadEvent)>::new(
|
||||||
|
move |event: web_sys::BeforeUnloadEvent| {
|
||||||
|
let s = pending.borrow();
|
||||||
|
if s.busy || s.dirty {
|
||||||
|
event.prevent_default();
|
||||||
|
event.set_return_value("外观尚未保存,请稍候");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if let Some(window) = web_sys::window() {
|
||||||
|
let _ = window
|
||||||
|
.add_event_listener_with_callback("beforeunload", unloading.as_ref().unchecked_ref());
|
||||||
|
}
|
||||||
|
unloading.forget();
|
||||||
if let Some(body) = document().body() {
|
if let Some(body) = document().body() {
|
||||||
let collapsed = web_sys::window()
|
let collapsed = web_sys::window()
|
||||||
.and_then(|w| w.session_storage().ok().flatten())
|
.and_then(|w| w.session_storage().ok().flatten())
|
||||||
|
|||||||
@@ -10,9 +10,9 @@
|
|||||||
|
|
||||||
## 界面与告警
|
## 界面与告警
|
||||||
|
|
||||||
采用新选定的 A 完整页面方案:左侧菜单“黑白名单管理”进入独立工作区,左侧表格、右侧独立编辑区。地图内“名单管理”也进入同一页面;目标详情仍保留快捷标记。该页在登记、设置和围栏等页面均可进入,返回工作区恢复原页面,并保留名单草稿、搜索和分类条件。可用 `/?app=target-lists` 直接进入。
|
采用用户最终选定的 B 完整页面方案:左侧菜单“黑白名单管理”进入独立工作区,左侧分类导航、右侧宽表格;编辑在对应记录行下展开,新增在表格顶部展开。地图内“名单管理”也进入同一页面;目标详情仍保留快捷标记。该页在登记、设置和围栏等页面均可进入,返回工作区恢复原页面,并保留名单草稿、搜索和分类条件。可用 `/?app=target-lists` 直接进入。
|
||||||
|
|
||||||
名单表格每页50条,表头及分页与滚动区分离。窄屏按表格、编辑区顺序排列,表格内部滚动。实时目录顶部控件减少占用,新默认收起底部事件区;已保存的布局偏好继续生效。
|
名单表格每页50条,表头及分页与滚动区分离。窄屏将分类改为横向按钮、记录改为卡片,编辑表单仍紧随记录展开;筛选或分页暂时隐藏被编辑记录时,草稿保留在表格顶部。实时目录顶部控件减少占用,新默认收起底部事件区;已保存的布局偏好继续生效。
|
||||||
|
|
||||||
目标目录和地图使用同一名单筛选;筛选只影响显示,原始接收数量与数据流不变。名单加载失败时显示“名单未知”,已有快照同步失败时明确提示暂用上次名单,不把读取失败解释为空名单。
|
目标目录和地图使用同一名单筛选;筛选只影响显示,原始接收数量与数据流不变。名单加载失败时显示“名单未知”,已有快照同步失败时明确提示暂用上次名单,不把读取失败解释为空名单。
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ try {
|
|||||||
await page.locator('#fit').selectOption('contain');
|
await page.locator('#fit').selectOption('contain');
|
||||||
await page.locator('#wall-message').filter({hasText:'已保存到本机应用'}).waitFor();
|
await page.locator('#wall-message').filter({hasText:'已保存到本机应用'}).waitFor();
|
||||||
assert.equal(await page.locator('#appearance-wallpaper').evaluate(e=>getComputedStyle(e).objectFit),'contain');
|
assert.equal(await page.locator('#appearance-wallpaper').evaluate(e=>getComputedStyle(e).objectFit),'contain');
|
||||||
await page.reload();if(await page.locator('#home-app-settings').isVisible())await page.locator('#home-app-settings').click();
|
await page.reload();await page.locator('#home-app-settings').click();
|
||||||
await page.locator('#desktop-sample').waitFor();
|
await page.locator('#desktop-sample').waitFor();
|
||||||
assert.equal(await page.locator('#appearance-wallpaper-name').innerText(),'暖沙光影');
|
assert.equal(await page.locator('#appearance-wallpaper-name').innerText(),'暖沙光影');
|
||||||
assert.equal(await page.locator('#appearance-dim-value').innerText(),'45%');
|
assert.equal(await page.locator('#appearance-dim-value').innerText(),'45%');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Appearance preview acceptance with an isolated database; no physical transports opened.
|
// Module navigation acceptance with an isolated database; no physical transports opened.
|
||||||
import {mkdtemp} from 'node:fs/promises';
|
import {mkdtemp} from 'node:fs/promises';
|
||||||
import {tmpdir} from 'node:os';
|
import {tmpdir} from 'node:os';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
@@ -18,7 +18,7 @@ const wait=ms=>new Promise(r=>setTimeout(r,ms));
|
|||||||
function start(){child=spawn(exe,['--data-root',root,'--simulation-api'],{env:{...process.env,RID_TEST_PORT:String(backend),PATH:'C:\\Windows\\System32'},windowsHide:true,stdio:['ignore','pipe','pipe']});child.stdout.on('data',b=>output+=b);child.stderr.on('data',b=>output+=b);child.on('error',e=>output+=e.message)}
|
function start(){child=spawn(exe,['--data-root',root,'--simulation-api'],{env:{...process.env,RID_TEST_PORT:String(backend),PATH:'C:\\Windows\\System32'},windowsHide:true,stdio:['ignore','pipe','pipe']});child.stdout.on('data',b=>output+=b);child.stderr.on('data',b=>output+=b);child.on('error',e=>output+=e.message)}
|
||||||
async function stop(){if(child&&child.exitCode===null){const done=new Promise(r=>child.once('exit',r));child.kill();await done}}
|
async function stop(){if(child&&child.exitCode===null){const done=new Promise(r=>child.once('exit',r));child.kill();await done}}
|
||||||
async function ready(){for(let i=0;i<150;i++){if(child.exitCode!==null)throw Error(output);try{if((await fetch(base+'/api/appearance')).ok)return}catch{}await wait(100)}throw Error('server timeout '+output)}
|
async function ready(){for(let i=0;i<150;i++){if(child.exitCode!==null)throw Error(output);try{if((await fetch(base+'/api/appearance')).ok)return}catch{}await wait(100)}throw Error('server timeout '+output)}
|
||||||
let report={};
|
let report={root};
|
||||||
try {
|
try {
|
||||||
await new Promise(r=>proxy.listen(0,'127.0.0.1',r));base='http://127.0.0.1:'+proxy.address().port;start();await ready();
|
await new Promise(r=>proxy.listen(0,'127.0.0.1',r));base='http://127.0.0.1:'+proxy.address().port;start();await ready();
|
||||||
browser=await chromium.launch({headless:true,channel:'msedge'});
|
browser=await chromium.launch({headless:true,channel:'msedge'});
|
||||||
@@ -27,8 +27,11 @@ try {
|
|||||||
const menu=()=>page.locator('.reference-rail button:visible');
|
const menu=()=>page.locator('.reference-rail button:visible');
|
||||||
const open=async name=>page.locator(`.reference-rail [data-open="${name}"]`).click();
|
const open=async name=>page.locator(`.reference-rail [data-open="${name}"]`).click();
|
||||||
const home=async()=>page.locator('.reference-rail [data-home]').click();
|
const home=async()=>page.locator('.reference-rail [data-home]').click();
|
||||||
const labels=async expected=>assert.deepEqual(await menu().evaluateAll(es=>es.map(e=>e.getAttribute('aria-label'))),['应用总览',...expected]);
|
const labels=async expected=>assert.deepEqual(await menu().evaluateAll(es=>es.map(e=>e.getAttribute('aria-label'))),expected.length?['应用总览',...expected]:[]);
|
||||||
await page.goto(base);await page.locator('#home-app-settings').waitFor();await labels([]);
|
await page.goto(base);await page.locator('#home-app-settings').waitFor();await labels([]);
|
||||||
|
for(const width of [1600,1000,700,390]){await page.setViewportSize({width,height:1000});assert.equal(await page.locator('.reference-rail').isVisible(),false);assert.equal(await page.locator('#toggle-menu').isVisible(),false);const bounds=await page.locator('.homescreen').boundingBox();assert.equal(bounds.x,0);assert.equal(bounds.width,width);assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth>innerWidth),false);}
|
||||||
|
await page.setViewportSize({width:1600,height:1000});await page.screenshot({path:path.join(root,'home-no-sidebar.png')});
|
||||||
|
const iconShapes=await page.locator('.reference-rail [data-module=settings] svg,.reference-rail [data-module=register] svg').evaluateAll(es=>es.map(e=>e.innerHTML));assert.equal(new Set(iconShapes).size,5);
|
||||||
await page.locator('#home-app-settings').click();await labels(['壁纸与外观','显示方式','地图配置']);
|
await page.locator('#home-app-settings').click();await labels(['壁纸与外观','显示方式','地图配置']);
|
||||||
assert.equal(await page.locator('.settings-sidebar,.map-settings-nav').count(),0);
|
assert.equal(await page.locator('.settings-sidebar,.map-settings-nav').count(),0);
|
||||||
assert.equal(await page.locator('#choose-wallpaper').isVisible(),true);
|
assert.equal(await page.locator('#choose-wallpaper').isVisible(),true);
|
||||||
@@ -43,7 +46,7 @@ try {
|
|||||||
await page.locator('#register-button').click();await page.locator('#record-result').waitFor();
|
await page.locator('#register-button').click();await page.locator('#record-result').waitFor();
|
||||||
await open('archives');await page.locator('#history-query').fill('NAV-123456');await page.locator('.archive-card').waitFor();
|
await open('archives');await page.locator('#history-query').fill('NAV-123456');await page.locator('.archive-card').waitFor();
|
||||||
await page.locator('[data-action=view]').click();assert.equal(await page.locator('#reference-title').innerText(),'设备登记');assert.equal(await page.locator('#record-result').isVisible(),true);
|
await page.locator('[data-action=view]').click();assert.equal(await page.locator('#reference-title').innerText(),'设备登记');assert.equal(await page.locator('#record-result').isVisible(),true);
|
||||||
await open('archives');await page.locator('[data-action=more]').click();await page.locator('[data-action=edit]').click();await page.locator('#edit-dialog').waitFor();await page.locator('#edit-owner').fill('导航编辑验证');await page.locator('#edit-save').click();await page.locator('#edit-dialog').waitFor({state:'hidden'});assert.equal(await page.locator('#reference-title').innerText(),'本地档案');
|
await open('archives');await page.locator('[data-action=more]').click();await page.locator('[data-action=edit]').click();await page.locator('#edit-dialog').waitFor();await page.locator('#edit-owner').fill('导航编辑验证');await page.locator('#edit-save').click();await page.locator('#edit-dialog').waitFor({state:'hidden'});await page.locator('body[data-screen=archives]').waitFor();assert.equal(await page.locator('#reference-title').innerText(),'本地档案');
|
||||||
await page.locator('#selection-toggle').click();await page.locator('[data-action=select]').check();await page.locator('#export-toggle').click();
|
await page.locator('#selection-toggle').click();await page.locator('[data-action=select]').check();await page.locator('#export-toggle').click();
|
||||||
const download=page.waitForEvent('download');await page.locator('#export-excel').click();assert.ok((await download).suggestedFilename().endsWith('.xlsx'));
|
const download=page.waitForEvent('download');await page.locator('#export-excel').click();assert.ok((await download).suggestedFilename().endsWith('.xlsx'));
|
||||||
await page.locator('#new-registration').click();assert.equal(await page.locator('#serial-no').inputValue(),'');
|
await page.locator('#new-registration').click();assert.equal(await page.locator('#serial-no').inputValue(),'');
|
||||||
@@ -55,9 +58,10 @@ try {
|
|||||||
for(const name of ['geofences','target-lists','realtime']) {await open(name);await labels(['实时工作台','电子围栏','黑白名单管理']);assert.equal(await page.locator('.reference-rail [aria-current=page]').getAttribute('data-menu'),name);}
|
for(const name of ['geofences','target-lists','realtime']) {await open(name);await labels(['实时工作台','电子围栏','黑白名单管理']);assert.equal(await page.locator('.reference-rail [aria-current=page]').getAttribute('data-menu'),name);}
|
||||||
await page.locator('#toggle-menu').click();assert.equal(await page.locator('.reference-rail').isVisible(),false);await page.locator('#toggle-menu').click();
|
await page.locator('#toggle-menu').click();assert.equal(await page.locator('.reference-rail').isVisible(),false);await page.locator('#toggle-menu').click();
|
||||||
await home();await page.locator('#home-app-settings').focus();await page.keyboard.press('Enter');await labels(['壁纸与外观','显示方式','地图配置']);
|
await home();await page.locator('#home-app-settings').focus();await page.keyboard.press('Enter');await labels(['壁纸与外观','显示方式','地图配置']);
|
||||||
|
await page.locator('#toggle-menu').click();await page.locator('.workspace-home-link').click();await labels([]);assert.equal(await page.locator('#toggle-menu').isVisible(),false);await page.locator('#home-app-settings').click();assert.equal(await page.locator('.reference-rail').isVisible(),false);assert.equal(await page.locator('#toggle-menu').isVisible(),true);await page.locator('#toggle-menu').click();await labels(['壁纸与外观','显示方式','地图配置']);
|
||||||
await page.setViewportSize({width:700,height:1000});await page.screenshot({path:path.join(root,'module-settings-narrow.png')});
|
await page.setViewportSize({width:700,height:1000});await page.screenshot({path:path.join(root,'module-settings-narrow.png')});
|
||||||
await page.setViewportSize({width:1600,height:1000});await page.screenshot({path:path.join(root,'module-settings.png')});
|
await page.setViewportSize({width:1600,height:1000});await page.screenshot({path:path.join(root,'module-settings.png')});
|
||||||
assert.deepEqual(errors,[]);report={passed:true,root,checks:['archive export','module menus','settings split','archive split','draft retention','create and view record','edit return','new registration','responsive widths','realtime return','collapse','keyboard']};
|
assert.deepEqual(errors,[]);report={passed:true,root,checks:['home without rail or gutter','five distinct A icons','module collapse preference retained','archive export','module menus','settings split','archive split','draft retention','create and view record','edit return','new registration','responsive widths','realtime return','collapse','keyboard']};
|
||||||
} finally {
|
} finally {
|
||||||
await browser?.close();await stop();for(const s of sockets)s.destroy();await new Promise(r=>proxy.close(r));console.log(JSON.stringify(report));
|
await browser?.close();await stop();for(const s of sockets)s.destroy();await new Promise(r=>proxy.close(r));console.log(JSON.stringify(report));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
// Module navigation acceptance with an isolated database; no physical transports opened.
|
||||||
|
import {mkdtemp} from 'node:fs/promises';
|
||||||
|
import {tmpdir} from 'node:os';
|
||||||
|
import path from 'node:path';
|
||||||
|
import http from 'node:http';
|
||||||
|
import net from 'node:net';
|
||||||
|
import {spawn} from 'node:child_process';
|
||||||
|
import {createRequire} from 'node:module';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
const {chromium}=createRequire(import.meta.url)('playwright');
|
||||||
|
const root=await mkdtemp(path.join(tmpdir(),'RID-navigation-edges-'));
|
||||||
|
const exe=process.argv[2]||'D:/Rust_Contact/util/target/Rid_Drone_Receivev/release/fpv-rid-registry-fullstack.exe';
|
||||||
|
const probe=net.createServer();await new Promise(r=>probe.listen(0,'127.0.0.1',r));const backend=probe.address().port;await new Promise(r=>probe.close(r));
|
||||||
|
let base,child,browser,output='';const errors=[],sockets=new Set();
|
||||||
|
const proxy=http.createServer((req,res)=>{const headers={...req.headers,host:'127.0.0.1:8787'};if(headers.origin===base)headers.origin='http://127.0.0.1:8787';const upstream=http.request({hostname:'127.0.0.1',port:backend,path:req.url,method:req.method,headers},r=>{res.writeHead(r.statusCode,r.headers);r.pipe(res)});upstream.on('error',()=>{res.writeHead(502);res.end()});req.pipe(upstream)});
|
||||||
|
proxy.on('upgrade',(req,socket,head)=>{const upstream=net.connect(backend,'127.0.0.1');sockets.add(socket);sockets.add(upstream);upstream.on('connect',()=>{const headers={...req.headers,host:'127.0.0.1:8787'};if(headers.origin===base)headers.origin='http://127.0.0.1:8787';const nl=String.fromCharCode(13,10);upstream.write(['GET '+req.url+' HTTP/1.1',...Object.entries(headers).map(([k,v])=>k+': '+v),'',''].join(nl));if(head.length)upstream.write(head);socket.pipe(upstream);upstream.pipe(socket)});upstream.on('error',()=>socket.destroy());socket.on('error',()=>upstream.destroy());socket.on('close',()=>{upstream.destroy();sockets.delete(socket);sockets.delete(upstream)})});
|
||||||
|
const wait=ms=>new Promise(r=>setTimeout(r,ms));
|
||||||
|
function start(){child=spawn(exe,['--data-root',root,'--simulation-api'],{env:{...process.env,RID_TEST_PORT:String(backend),PATH:'C:\\Windows\\System32'},windowsHide:true,stdio:['ignore','pipe','pipe']});child.stdout.on('data',b=>output+=b);child.stderr.on('data',b=>output+=b);child.on('error',e=>output+=e.message)}
|
||||||
|
async function stop(){if(child&&child.exitCode===null){const done=new Promise(r=>child.once('exit',r));child.kill();await done}}
|
||||||
|
async function ready(){for(let i=0;i<150;i++){if(child.exitCode!==null)throw Error(output);try{if((await fetch(base+'/api/appearance')).ok)return}catch{}await wait(100)}throw Error('server timeout '+output)}
|
||||||
|
let report={root};
|
||||||
|
try {
|
||||||
|
await new Promise(r=>proxy.listen(0,'127.0.0.1',r));base='http://127.0.0.1:'+proxy.address().port;start();await ready();
|
||||||
|
browser=await chromium.launch({headless:true,channel:'msedge'});
|
||||||
|
const page=await browser.newPage();page.on('pageerror',e=>errors.push(e.message));
|
||||||
|
await page.goto(base);await page.locator('#home-app-settings').click();
|
||||||
|
await page.waitForFunction(()=>document.querySelector('[data-wall=B4]').getAttribute('aria-pressed')==='true');
|
||||||
|
let release,seen;const hold=new Promise(r=>release=r),started=new Promise(r=>seen=r);let intercepted=false;
|
||||||
|
await page.route('**/api/appearance',async route=>{
|
||||||
|
if(route.request().method()!=='GET'||intercepted)return route.continue();
|
||||||
|
intercepted=true;const response=await route.fetch();const body=await response.text();seen();await hold;await route.fulfill({response,body});
|
||||||
|
});
|
||||||
|
await page.locator('.reference-rail [data-open=display]').click();await started;
|
||||||
|
await page.locator('#dim').fill('45');await page.locator('#dim').dispatchEvent('input');
|
||||||
|
await page.waitForFunction(()=>document.getElementById('wall-message').textContent.includes('已保存到本机应用'));
|
||||||
|
const delayed=page.waitForResponse(r=>r.url().endsWith('/api/appearance')&&r.request().method()==='GET');release();await delayed;await page.waitForTimeout(100);
|
||||||
|
const staleReadProtected=await page.locator('#dim').inputValue()==='45';
|
||||||
|
await page.locator('.reference-rail [data-open=settings]').click();await page.locator('.reference-rail [data-open=display]').click();await page.waitForFunction(()=>document.getElementById('dim').value==='45');
|
||||||
|
const pendingAppearanceProtected=await page.evaluate(()=>{const input=document.getElementById('dim');input.value='46';input.dispatchEvent(new Event('input',{bubbles:true}));const e=new Event('beforeunload',{cancelable:true});window.dispatchEvent(e);return e.defaultPrevented;});
|
||||||
|
await page.waitForFunction(()=>document.getElementById('wall-message').textContent.includes('已保存到本机应用'));
|
||||||
|
await page.unroute('**/api/appearance');await page.goto(base+'/?app=register');await page.locator('#owner-name').fill('未保存草稿');
|
||||||
|
const draftProtected=await page.evaluate(()=>{const e=new Event('beforeunload',{cancelable:true});window.dispatchEvent(e);return e.defaultPrevented;});
|
||||||
|
// Same-document navigation retains the draft and must not prompt.
|
||||||
|
await page.locator('.reference-rail [data-open=archives]').click();await page.locator('.reference-rail [data-open=register]').click();assert.equal(await page.locator('#owner-name').inputValue(),'未保存草稿');
|
||||||
|
await page.locator('.reference-rail [data-home]').click();
|
||||||
|
const dismiss=()=>page.waitForEvent('dialog').then(async dialog=>{assert.equal(dialog.type(),'beforeunload');await dialog.dismiss();});
|
||||||
|
assert.equal(draftProtected,true,'leaving the registration document can silently discard the draft');
|
||||||
|
await Promise.all([dismiss(),page.locator('#home-app-realtime').click()]);assert.equal(page.url(),base+'/?app=register');await page.locator('#home-app-register').click();
|
||||||
|
await page.locator('#serial-no').fill('EDGE-123456');
|
||||||
|
let releaseSave,saveSeen;const saveHold=new Promise(r=>releaseSave=r),saveStarted=new Promise(r=>saveSeen=r);
|
||||||
|
await page.route('**/api/records',async route=>{if(route.request().method()!=='POST')return route.continue();saveSeen();await saveHold;await route.continue();});
|
||||||
|
await page.locator('#register-button').click();await saveStarted;await page.locator('.reference-rail [data-open=archives]').click();assert.equal(await page.locator('body').getAttribute('data-screen'),'register');await page.locator('.reference-rail [data-home]').click();assert.equal(await page.locator('body').getAttribute('data-screen'),'register');releaseSave();await page.locator('#record-result').waitFor();await page.waitForFunction(()=>document.body.getAttribute('data-registry-busy')==='false');
|
||||||
|
const cleanAfterSave=await page.evaluate(()=>{const e=new Event('beforeunload',{cancelable:true});window.dispatchEvent(e);return !e.defaultPrevented;});assert.equal(cleanAfterSave,true);
|
||||||
|
report={root,staleReadProtected,pendingAppearanceProtected,draftProtected,cleanAfterSave,errors};console.log(JSON.stringify(report));
|
||||||
|
assert.equal(staleReadProtected,true,'late appearance GET overwrote a newer saved change');
|
||||||
|
assert.equal(pendingAppearanceProtected,true,'leaving during appearance debounce can lose changes');
|
||||||
|
assert.equal(draftProtected,true,'leaving the registration document can silently discard the draft');
|
||||||
|
assert.deepEqual(errors,[]);
|
||||||
|
} finally {await browser?.close();await stop();for(const s of sockets)s.destroy();await new Promise(r=>proxy.close(r));}
|
||||||
@@ -30,7 +30,7 @@ try{
|
|||||||
const nav=page.getByRole('navigation',{name:'模块菜单'});assert.equal(await nav.locator('button:visible').count(),4);assert.equal(await nav.locator('#rt-blacklist-menu').getAttribute('aria-label'),'黑白名单管理');
|
const nav=page.getByRole('navigation',{name:'模块菜单'});assert.equal(await nav.locator('button:visible').count(),4);assert.equal(await nav.locator('#rt-blacklist-menu').getAttribute('aria-label'),'黑白名单管理');
|
||||||
assert.deepEqual(await nav.locator('button:visible').evaluateAll(es=>es.map(e=>e.getAttribute('aria-label'))),['应用总览','实时工作台','电子围栏','黑白名单管理']);
|
assert.deepEqual(await nav.locator('button:visible').evaluateAll(es=>es.map(e=>e.getAttribute('aria-label'))),['应用总览','实时工作台','电子围栏','黑白名单管理']);
|
||||||
await page.getByRole('button',{name:'黑白名单管理',exact:true}).click();await page.locator('#rt-list-manager').waitFor();await page.getByRole('heading',{name:'黑白名单管理',exact:true}).waitFor();
|
await page.getByRole('button',{name:'黑白名单管理',exact:true}).click();await page.locator('#rt-list-manager').waitFor();await page.getByRole('heading',{name:'黑白名单管理',exact:true}).waitFor();
|
||||||
const managerTabs=page.getByRole('group',{name:'管理名单分类'});assert.equal(await managerTabs.getByRole('button',{name:/^全部/}).getAttribute('aria-pressed'),'true');await page.locator('.rt-list-row[data-target-id="MENU-BLACK"]').waitFor();assert.equal(await page.locator('.rt-list-row[data-target-id="MENU-WHITE"]').count(),1);assert.equal(await page.locator('#rt-list-entry-kind').inputValue(),'black');
|
const managerTabs=page.getByRole('group',{name:'管理名单分类'});assert.equal(await managerTabs.getByRole('button',{name:/^全部/}).getAttribute('aria-pressed'),'true');await page.locator('.rt-list-row[data-target-id="MENU-BLACK"]').waitFor();assert.equal(await page.locator('.rt-list-row[data-target-id="MENU-WHITE"]').count(),1);await page.getByRole('button',{name:'新增条目',exact:true}).click();assert.equal(await page.locator('#rt-list-entry-kind').inputValue(),'black');
|
||||||
await page.keyboard.press('Escape');await page.locator('#rt-list-manager').waitFor({state:'hidden'});await page.waitForFunction(()=>document.activeElement.id==='rt-blacklist-menu');assert.equal(await page.locator('#rt-blacklist-menu').getAttribute('aria-current'),null);
|
await page.keyboard.press('Escape');await page.locator('#rt-list-manager').waitFor({state:'hidden'});await page.waitForFunction(()=>document.activeElement.id==='rt-blacklist-menu');assert.equal(await page.locator('#rt-blacklist-menu').getAttribute('aria-current'),null);
|
||||||
await page.getByRole('button',{name:'黑白名单管理',exact:true}).press('Enter');await page.locator('#rt-list-manager').waitFor();await page.getByRole('button',{name:'返回工作区'}).click();await page.locator('#rt-list-manager').waitFor({state:'hidden'});
|
await page.getByRole('button',{name:'黑白名单管理',exact:true}).press('Enter');await page.locator('#rt-list-manager').waitFor();await page.getByRole('button',{name:'返回工作区'}).click();await page.locator('#rt-list-manager').waitFor({state:'hidden'});
|
||||||
async function corner(){const result=await page.evaluate(()=>{const root=document.getElementById('rt-layout'),e=root.querySelector('.mc-map-infobar'),r=root.getBoundingClientRect(),b=e.getBoundingClientRect(),scale=r.width/root.clientWidth;return {right:(r.right-b.right)/scale,bottom:(r.bottom-b.bottom)/scale,z:Number(getComputedStyle(e).zIndex),pointer:getComputedStyle(e).pointerEvents,rootOverflow:document.documentElement.scrollWidth>innerWidth}});assert.ok(Math.abs(result.right-16)<1,JSON.stringify(result));assert.ok(Math.abs(result.bottom-16)<1,JSON.stringify(result));assert.ok(result.z>10);assert.equal(result.pointer,'none');assert.equal(result.rootOverflow,false);return result;}
|
async function corner(){const result=await page.evaluate(()=>{const root=document.getElementById('rt-layout'),e=root.querySelector('.mc-map-infobar'),r=root.getBoundingClientRect(),b=e.getBoundingClientRect(),scale=r.width/root.clientWidth;return {right:(r.right-b.right)/scale,bottom:(r.bottom-b.bottom)/scale,z:Number(getComputedStyle(e).zIndex),pointer:getComputedStyle(e).pointerEvents,rootOverflow:document.documentElement.scrollWidth>innerWidth}});assert.ok(Math.abs(result.right-16)<1,JSON.stringify(result));assert.ok(Math.abs(result.bottom-16)<1,JSON.stringify(result));assert.ok(result.z>10);assert.equal(result.pointer,'none');assert.equal(result.rootOverflow,false);return result;}
|
||||||
|
|||||||
@@ -26,15 +26,15 @@ try{
|
|||||||
for(let i=0;i<115;i++)await save('PAGE-'+String(i).padStart(3,'0'),i%2?'white':'black','演示备注 '+i);
|
for(let i=0;i<115;i++)await save('PAGE-'+String(i).padStart(3,'0'),i%2?'white':'black','演示备注 '+i);
|
||||||
browser=await chromium.launch({headless:true,channel:'msedge'});const context=await browser.newContext({viewport:{width:1366,height:768}});const page=await context.newPage();page.on('pageerror',e=>errors.push(e.message));page.on('console',m=>{if(/violates.*Content Security|Refused.*policy/i.test(m.text()))csp.push(m.text())});
|
browser=await chromium.launch({headless:true,channel:'msedge'});const context=await browser.newContext({viewport:{width:1366,height:768}});const page=await context.newPage();page.on('pageerror',e=>errors.push(e.message));page.on('console',m=>{if(/violates.*Content Security|Refused.*policy/i.test(m.text()))csp.push(m.text())});
|
||||||
await page.goto(base+'/realtime');await page.locator('.rt-status').filter({hasText:'已连接'}).waitFor();assert.equal(await page.locator('#rt-dock').isVisible(),false);const fullHeight=await page.locator('.live-list-body').evaluate(e=>e.clientHeight);assert.ok(fullHeight>=240,String(fullHeight));await page.locator('#rt-dock-restore').click();await wait(200);const dockHeight=await page.locator('.live-list-body').evaluate(e=>e.clientHeight);assert.ok(fullHeight-dockHeight>100);await page.getByRole('button',{name:'隐藏事件面板',exact:true}).click();
|
await page.goto(base+'/realtime');await page.locator('.rt-status').filter({hasText:'已连接'}).waitFor();assert.equal(await page.locator('#rt-dock').isVisible(),false);const fullHeight=await page.locator('.live-list-body').evaluate(e=>e.clientHeight);assert.ok(fullHeight>=240,String(fullHeight));await page.locator('#rt-dock-restore').click();await wait(200);const dockHeight=await page.locator('.live-list-body').evaluate(e=>e.clientHeight);assert.ok(fullHeight-dockHeight>100);await page.getByRole('button',{name:'隐藏事件面板',exact:true}).click();
|
||||||
await page.getByRole('button',{name:'黑白名单管理',exact:true}).click();await page.locator('body[data-screen=target-lists]').waitFor();await page.getByRole('heading',{name:'黑白名单管理',exact:true}).waitFor();assert.equal(await page.locator('#workspace-content').isVisible(),false);assert.equal(await page.locator('#rt-list-manager .rt-list-row').count(),50);
|
await page.getByRole('button',{name:'黑白名单管理',exact:true}).click();await page.locator('body[data-screen=target-lists]').waitFor();await page.getByRole('heading',{name:'黑白名单管理',exact:true}).waitFor();assert.equal(await page.locator('#workspace-content').isVisible(),false);assert.equal(await page.locator('.rt-list-category-panel').isVisible(),true);assert.equal(await page.locator('.rt-list-editor-panel').count(),0);assert.equal(await page.locator('#rt-list-entry-form').count(),0);assert.equal(await page.locator('#rt-list-manager .rt-list-row').count(),50);
|
||||||
const bounds=await page.locator('#rt-list-manager').boundingBox();assert.ok(bounds.width>1200&&bounds.x<90&&bounds.y<=50);assert.equal(await page.locator('[aria-modal=true]').count(),0);await page.locator('#rt-list-manager .rt-list-pagination').getByRole('button',{name:'下一页',exact:true}).click();await page.locator('.rt-list-row[data-target-id="PAGE-050"]').waitFor();
|
const bounds=await page.locator('#rt-list-manager').boundingBox();assert.ok(bounds.width>1200&&bounds.x<90&&bounds.y<=50);assert.equal(await page.locator('[aria-modal=true]').count(),0);await page.locator('#rt-list-manager .rt-list-pagination').getByRole('button',{name:'下一页',exact:true}).click();await page.locator('.rt-list-row[data-target-id="PAGE-050"]').waitFor();
|
||||||
await page.getByRole('group',{name:'管理名单分类'}).getByRole('button',{name:/^白名单/}).click();await page.locator('.rt-list-row[data-target-id="PAGE-001"]').waitFor();assert.equal(await page.locator('.rt-list-row[data-target-id="PAGE-000"]').count(),0);
|
await page.getByRole('group',{name:'管理名单分类'}).getByRole('button',{name:/^白名单/}).click();await page.locator('.rt-list-row[data-target-id="PAGE-001"]').waitFor();assert.equal(await page.locator('.rt-list-row[data-target-id="PAGE-000"]').count(),0);
|
||||||
await page.locator('.rt-list-search input').fill('PAGE-001');await page.locator('.rt-list-row').getByRole('button',{name:'编辑',exact:true}).click();await page.locator('#rt-list-entry-note').fill('保留草稿');await page.getByRole('button',{name:'电子围栏',exact:true}).click();await page.locator('body[data-screen=geofences]').waitFor();await page.getByRole('button',{name:'黑白名单管理',exact:true}).click();assert.equal(await page.locator('#rt-list-entry-note').inputValue(),'保留草稿');assert.equal(await page.locator('.rt-list-search input').inputValue(),'PAGE-001');
|
await page.locator('.rt-list-search input').fill('PAGE-001');await page.locator('.rt-list-row').getByRole('button',{name:'编辑',exact:true}).click();await page.locator('#rt-list-entry-note').fill('保留草稿');assert.equal(await page.locator('.rt-list-row[data-target-id="PAGE-001"]').evaluate(e=>e.nextElementSibling?.classList.contains('rt-inline-editor-row')),true);assert.equal(await page.locator('#rt-list-entry-form').count(),1);await page.locator('.rt-list-search input').fill('no-match');assert.equal(await page.locator('#rt-list-entry-note').inputValue(),'保留草稿');assert.equal(await page.locator('#rt-list-entry-form').count(),1);await page.locator('.rt-list-search input').fill('PAGE-001');await page.getByRole('button',{name:'电子围栏',exact:true}).click();await page.locator('body[data-screen=geofences]').waitFor();await page.getByRole('button',{name:'黑白名单管理',exact:true}).click();assert.equal(await page.locator('#rt-list-entry-note').inputValue(),'保留草稿');assert.equal(await page.locator('.rt-list-search input').inputValue(),'PAGE-001');
|
||||||
for(const [width,height]of [[1600,1000],[1366,768],[900,700],[390,844],[1200,540]]){await page.setViewportSize({width,height});await page.locator('#rt-list-entry-form .primary').scrollIntoViewIfNeeded();assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth>innerWidth),false);const box=await page.locator('#rt-list-entry-form .primary').boundingBox();assert.ok(box.x>=0&&box.x+box.width<=width+1&&box.y>=48&&box.y+box.height<=height+1);await page.screenshot({path:path.join(root,'manager-'+width+'x'+height+'.png'),fullPage:true});}
|
for(const [width,height]of [[1600,1000],[1366,768],[900,700],[390,844],[1200,540]]){await page.setViewportSize({width,height});await page.locator('#rt-list-entry-form .primary').scrollIntoViewIfNeeded();assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth>innerWidth),false);const box=await page.locator('#rt-list-entry-form .primary').boundingBox();assert.ok(box.x>=0&&box.x+box.width<=width+1&&box.y>=48&&box.y+box.height<=height+1);await page.screenshot({path:path.join(root,'manager-'+width+'x'+height+'.png'),fullPage:true});}
|
||||||
await page.setViewportSize({width:1280,height:720});await page.evaluate(()=>document.documentElement.style.zoom='2');await page.locator('#rt-list-entry-form .primary').scrollIntoViewIfNeeded();assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth>innerWidth),false);await page.evaluate(()=>document.documentElement.style.zoom='');
|
await page.setViewportSize({width:1280,height:720});await page.evaluate(()=>document.documentElement.style.zoom='2');await page.locator('#rt-list-entry-form .primary').scrollIntoViewIfNeeded();assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth>innerWidth),false);await page.evaluate(()=>document.documentElement.style.zoom='');
|
||||||
await page.keyboard.press('Escape');await page.locator('body[data-screen=geofences]').waitFor();await page.setViewportSize({width:1366,height:768});await page.getByRole('button',{name:'黑白名单管理',exact:true}).click();await page.getByRole('button',{name:'返回工作区',exact:true}).click();await page.locator('body[data-screen=geofences]').waitFor();
|
await page.keyboard.press('Escape');await page.locator('body[data-screen=geofences]').waitFor();await page.setViewportSize({width:1366,height:768});await page.getByRole('button',{name:'黑白名单管理',exact:true}).click();await page.getByRole('button',{name:'返回工作区',exact:true}).click();await page.locator('body[data-screen=geofences]').waitFor();
|
||||||
// Full page is also available without mounting the realtime app; preserve registration draft.
|
// Registration owns its menu; switching settings preserves its in-document draft.
|
||||||
await page.goto(base+'/?app=register');await page.locator('body[data-screen=register]').waitFor();const originalUrl=page.url();await page.getByRole('button',{name:'黑白名单管理',exact:true}).click();await page.locator('body[data-screen=target-lists]').waitFor();assert.equal(page.url(),originalUrl);await page.getByRole('button',{name:'返回工作区',exact:true}).click();await page.locator('body[data-screen=register]').waitFor();
|
await page.goto(base+'/?app=register');await page.locator('body[data-screen=register]').waitFor();await page.locator('#owner-name').fill('保留登记草稿');const originalUrl=page.url();assert.equal(await page.locator('#rt-blacklist-menu').isVisible(),false);await page.getByRole('button',{name:'打开壁纸与外观',exact:true}).click();await page.locator('body[data-screen=settings]').waitFor();await page.locator('.reference-rail [data-home]').click();await page.locator('#home-app-register').click();await page.locator('body[data-screen=register]').waitFor();assert.equal(page.url(),originalUrl);assert.equal(await page.locator('#owner-name').inputValue(),'保留登记草稿');
|
||||||
await page.goto(base+'/?app=target-lists');await page.locator('body[data-screen=target-lists]').waitFor();await page.locator('.rt-list-row').first().waitFor();
|
page.once('dialog',dialog=>dialog.accept());await page.goto(base+'/?app=target-lists');await page.locator('body[data-screen=target-lists]').waitFor();await page.locator('.rt-list-row').first().waitFor();await page.getByRole('button',{name:'新增条目',exact:true}).click();await page.locator('#rt-list-entry-id').fill('PAGE-NEW');await page.locator('#rt-list-entry-note').fill('B方案行内新增');await page.locator('#rt-list-entry-form .primary').click();await page.locator('.rt-list-manager-footer').filter({hasText:'已将 PAGE-NEW 保存'}).waitFor();assert.ok((await snapshot()).entries.some(e=>e.target_id==='PAGE-NEW'));await page.locator('.rt-list-search input').fill('PAGE-NEW');await page.locator('.rt-list-row[data-target-id="PAGE-NEW"]').waitFor();assert.equal(await page.locator('#rt-list-entry-form').count(),1);await page.getByRole('button',{name:'收起编辑',exact:true}).click();assert.equal(await page.locator('#rt-list-entry-form').count(),0);
|
||||||
assert.deepEqual(errors,[]);assert.deepEqual(csp,[]);report={status:'PASS',root,exe,fullHeight,dockHeight,checks:['left menu complete page','map hidden; not a dialog','both kinds and search','115 entries pagination','independent editor','draft and filter across pages','five sizes and 200percent','return to origin workspace','registration route retains document','direct bookmark','directory height expanded','default dock collapsed'],errors,csp};console.log(JSON.stringify(report));
|
assert.deepEqual(errors,[]);assert.deepEqual(csp,[]);report={status:'PASS',root,exe,fullHeight,dockHeight,checks:['left menu complete page','map hidden; not a dialog','both kinds and search','115 entries pagination','B category navigation and inline editing','draft and filter across pages','five sizes and 200percent','return to origin workspace','module isolation and registration draft','direct bookmark','directory height expanded','default dock collapsed'],errors,csp};console.log(JSON.stringify(report));
|
||||||
}catch(error){console.log('FAILED ROOT',root,error.stack,JSON.stringify(errors));if(browser){const page=browser.contexts()[0]?.pages()[0];if(page)await page.screenshot({path:path.join(root,'failure.png'),fullPage:true}).catch(()=>{});}throw error;}finally{if(browser)await browser.close();await stop();for(const socket of sockets)socket.destroy();proxy.closeAllConnections();await new Promise(r=>proxy.close(r));await writeFile(path.join(root,'report.json'),JSON.stringify(report,null,2));await writeFile(path.join(root,'server.log'),output);}
|
}catch(error){console.log('FAILED ROOT',root,error.stack,JSON.stringify(errors));if(browser){const page=browser.contexts()[0]?.pages()[0];if(page)await page.screenshot({path:path.join(root,'failure.png'),fullPage:true}).catch(()=>{});}throw error;}finally{if(browser)await browser.close();await stop();for(const socket of sockets)socket.destroy();proxy.closeAllConnections();await new Promise(r=>proxy.close(r));await writeFile(path.join(root,'report.json'),JSON.stringify(report,null,2));await writeFile(path.join(root,'server.log'),output);}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ try{
|
|||||||
await page.locator('.live-events li[data-alert=true]').filter({hasText:'LIST-WHITE'}).waitFor();
|
await page.locator('.live-events li[data-alert=true]').filter({hasText:'LIST-WHITE'}).waitFor();
|
||||||
assert.equal(await page.locator('.live-events li[data-alert=true]').filter({hasText:'LIST-WHITE'}).count(),1);
|
assert.equal(await page.locator('.live-events li[data-alert=true]').filter({hasText:'LIST-WHITE'}).count(),1);
|
||||||
await page.getByRole('button',{name:'管理黑白名单',exact:true}).click();await page.locator('#rt-list-manager').waitFor();assert.equal((await page.locator('#rt-list-manager').innerText()).includes('rows.get'),false);assert.equal(await page.locator('.rt-list-pagination').getByRole('button',{name:'下一页',exact:true}).isDisabled(),true);
|
await page.getByRole('button',{name:'管理黑白名单',exact:true}).click();await page.locator('#rt-list-manager').waitFor();assert.equal((await page.locator('#rt-list-manager').innerText()).includes('rows.get'),false);assert.equal(await page.locator('.rt-list-pagination').getByRole('button',{name:'下一页',exact:true}).isDisabled(),true);
|
||||||
await page.locator('#rt-list-entry-id').fill('OFFLINE_002');await page.locator('#rt-list-entry-kind').selectOption('white');await page.locator('#rt-list-entry-note').fill('离线条目');await page.locator('#rt-list-entry-form .primary').click();
|
await page.getByRole('button',{name:'新增条目',exact:true}).click();await page.locator('#rt-list-entry-id').fill('OFFLINE_002');await page.locator('#rt-list-entry-kind').selectOption('white');await page.locator('#rt-list-entry-note').fill('离线条目');await page.locator('#rt-list-entry-form .primary').click();
|
||||||
await page.locator('.rt-list-manager-footer').filter({hasText:'已将 OFFLINE_002 保存为白名单'}).waitFor();assert.equal(await page.evaluate(()=>window.ridMap.metrics().targets),3);
|
await page.locator('.rt-list-manager-footer').filter({hasText:'已将 OFFLINE_002 保存为白名单'}).waitFor();assert.equal(await page.evaluate(()=>window.ridMap.metrics().targets),3);
|
||||||
assert.equal((await(await fetch(base+'/api/records?page=1')).json()).total,0);
|
assert.equal((await(await fetch(base+'/api/records?page=1')).json()).total,0);
|
||||||
const offline=page.locator('.rt-list-row[data-target-id=OFFLINE_002]');await offline.getByRole('button',{name:'编辑',exact:true}).click();assert.equal(await page.locator('#rt-list-entry-id').isEditable(),false);
|
const offline=page.locator('.rt-list-row[data-target-id=OFFLINE_002]');await offline.getByRole('button',{name:'编辑',exact:true}).click();assert.equal(await page.locator('#rt-list-entry-id').isEditable(),false);
|
||||||
|
|||||||
Reference in New Issue
Block a user