feat(web-ui): 重构地图设置与目标列表页面并优化实时地图导航体验

- 重构地图设置页面布局,采用 flex 替代 grid,新增导航栏、标签页
  和下载步骤组件,改善响应式断点适配
- 将目标列表管理从侧边抽屉方案改为全页面内联编辑器,包含表格视图
  与分类侧栏,支持移动端卡片式降级展示
- 为实时地图屏幕添加半透明毛玻璃导航栏样式,支持 backdrop-filter
  降级,并在地图模式下调整内容区域偏移量
- 修复地图渲染器在画布尺寸为 0 时的边界异常,增加宽高校验
- 优化 fitBounds 的 padding 计算,改为基于容器宽度的比例值并
  限制最大值,避免小屏下地图偏移过大
- 新增 B5、B6、B7 三组 SVG 壁纸资源
```
This commit is contained in:
2026-10-23 14:50:27 +08:00
parent cd1b717e74
commit 461e2c8e7f
29 changed files with 910 additions and 319 deletions
+77
View File
@@ -0,0 +1,77 @@
// Appearance preview 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-appearance-preview-'));
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={};
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({viewport:{width:1600,height:1000}});
page.on('pageerror',e=>errors.push(e.message));
await page.goto(base);await page.locator('#home-app-settings').click();
assert.equal(await page.locator('.glass-material-note').count(),0);
const caption=await page.locator('#appearance-wallpapers').boundingBox();
const heading=await page.locator('.setting-content .setting-panel-head').boundingBox();
assert.ok(caption.y-heading.y-heading.height<35);
for(const [wall,name] of [['B5','晴空流光'],['B6','晨雾青山'],['B7','暖沙光影']]){
await page.locator(`[data-wall=${wall}]`).click();
await page.locator('#wall-message').filter({hasText:'已保存到本机应用'}).waitFor();
assert.equal((await (await fetch(base+'/api/appearance')).json()).wallpaper,wall);
for(const id of ['appearance-wallpaper','workspace-wallpaper']){
assert.equal(await page.locator('#'+id).getAttribute('src'),`/wallpapers/${wall}-wallpaper.svg`);
await page.waitForFunction(id=>{const e=document.getElementById(id);return e.complete&&e.naturalWidth>0},id);
}
assert.equal(await page.locator('#appearance-wallpaper-name').innerText(),name);
}
const preview=page.locator('#desktop-sample');
await page.locator('.reference-rail [data-open=display]').click();
const before=await preview.screenshot();
await page.locator('#dim').fill('45');await page.locator('#dim').dispatchEvent('input');
await page.locator('#wall-message').filter({hasText:'已保存到本机应用'}).waitFor();
assert.equal(await page.locator('#appearance-dim-value').innerText(),'45%');
assert.notDeepEqual(await preview.screenshot(),before);
await page.locator('#blur').fill('8');await page.locator('#blur').dispatchEvent('input');
await page.locator('#wall-message').filter({hasText:'已保存到本机应用'}).waitFor();
assert.equal(await page.locator('#appearance-wallpaper').evaluate(e=>getComputedStyle(e).filter),'blur(8px)');
await page.locator('#fit').selectOption('contain');
await page.locator('#wall-message').filter({hasText:'已保存到本机应用'}).waitFor();
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.locator('#desktop-sample').waitFor();
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-blur-value').innerText(),'8 px');
assert.equal(await page.locator('#appearance-fit-value').innerText(),'完整显示');
await page.locator('.reference-rail [data-open=settings]').click();
await page.locator('[data-wall=B5]').click();
await page.locator('.reference-rail [data-open=display]').click();
await page.locator('#dim').fill('14');await page.locator('#dim').dispatchEvent('input');
await page.locator('#blur').fill('0');await page.locator('#blur').dispatchEvent('input');
await page.locator('#fit').selectOption('cover');
await page.locator('#wall-message').filter({hasText:'已保存到本机应用'}).waitFor();
await page.screenshot({path:path.join(root,'appearance-wide.png')});
for(const width of [1000,700]){
await page.setViewportSize({width,height:1000});
assert.equal(await page.locator('#desktop-sample').isVisible(),true);
assert.ok(await page.evaluate(()=>document.getElementById('appearance-view').scrollWidth<=document.getElementById('appearance-view').clientWidth+1));
}
assert.deepEqual(errors,[]);report={passed:true,root,checks:['bright wallpapers','preview pixels change','dim','blur','fit','reload persistence','responsive widths']};
} 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));
}