```
feat(web-ui): 重构地图设置与目标列表页面并优化实时地图导航体验 - 重构地图设置页面布局,采用 flex 替代 grid,新增导航栏、标签页 和下载步骤组件,改善响应式断点适配 - 将目标列表管理从侧边抽屉方案改为全页面内联编辑器,包含表格视图 与分类侧栏,支持移动端卡片式降级展示 - 为实时地图屏幕添加半透明毛玻璃导航栏样式,支持 backdrop-filter 降级,并在地图模式下调整内容区域偏移量 - 修复地图渲染器在画布尺寸为 0 时的边界异常,增加宽高校验 - 优化 fitBounds 的 padding 计算,改为基于容器宽度的比例值并 限制最大值,避免小屏下地图偏移过大 - 新增 B5、B6、B7 三组 SVG 壁纸资源 ```
This commit is contained in:
@@ -102,3 +102,30 @@ body.b[data-custom-wallpaper="true"] .home-launcher.homescreen { background: non
|
|||||||
/* Restore collapsed panels without bringing back the removed map toolbar. */
|
/* Restore collapsed panels without bringing back the removed map toolbar. */
|
||||||
.live-panel-restores { position: absolute; top: 16px; left: 16px; display: flex; gap: 8px; z-index: 6; }
|
.live-panel-restores { position: absolute; top: 16px; left: 16px; display: flex; gap: 8px; z-index: 6; }
|
||||||
body.b .live-panel-restores button { background: var(--glass-solid); border-color: var(--work-line); color: var(--work-text); font-size: 12px; padding: 7px 12px; }
|
body.b .live-panel-restores button { background: var(--glass-solid); border-color: var(--work-line); color: var(--work-text); font-size: 12px; padding: 7px 12px; }
|
||||||
|
|
||||||
|
/* Keep navigation dark while allowing the realtime map to show through it. */
|
||||||
|
body.b :is(.reference-top, .reference-rail) {
|
||||||
|
background: rgba(6, 18, 33, .72);
|
||||||
|
backdrop-filter: blur(18px) saturate(120%);
|
||||||
|
-webkit-backdrop-filter: blur(18px) saturate(120%);
|
||||||
|
}
|
||||||
|
body.b[data-screen=realtime] #workspace-content {
|
||||||
|
--navigation-width: 68px;
|
||||||
|
inset: 0;
|
||||||
|
padding: 48px 0 0 var(--navigation-width);
|
||||||
|
box-sizing: border-box;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
body.b[data-screen=realtime][data-menu-hidden=true] #workspace-content { --navigation-width: 0px; }
|
||||||
|
body.b[data-screen=realtime] #workspace-content .rt-page,
|
||||||
|
body.b[data-screen=realtime] .mc-layout-b { overflow: visible; }
|
||||||
|
body.b[data-screen=realtime] .mc-layout-b .mc-map-area-top {
|
||||||
|
inset: -48px 0 0 calc(0px - var(--navigation-width));
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
@media (max-width: 760px) {
|
||||||
|
body.b[data-screen=realtime] #workspace-content { --navigation-width: 56px; }
|
||||||
|
}
|
||||||
|
@supports not ((backdrop-filter: blur(18px)) or (-webkit-backdrop-filter: blur(18px))) {
|
||||||
|
body.b :is(.reference-top, .reference-rail) { background: var(--glass-solid); }
|
||||||
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ function create(container,initialBasemap="imagery",preferences=null) {
|
|||||||
gl.bindVertexArray(null);this.count=0;this.matrix=gl.getUniformLocation(this.program,'matrix');this.pixel=gl.getUniformLocation(this.program,'pixel');this.bearing=gl.getUniformLocation(this.program,'bearing');
|
gl.bindVertexArray(null);this.count=0;this.matrix=gl.getUniformLocation(this.program,'matrix');this.pixel=gl.getUniformLocation(this.program,'pixel');this.bearing=gl.getUniformLocation(this.program,'bearing');
|
||||||
},
|
},
|
||||||
render(gl,args){
|
render(gl,args){
|
||||||
if (!this.count) return;
|
if (!this.count || !this.map.getCanvas().clientWidth || !this.map.getCanvas().clientHeight) return;
|
||||||
const source=args.defaultProjectionData?.mainMatrix || args.modelViewProjectionMatrix;
|
const source=args.defaultProjectionData?.mainMatrix || args.modelViewProjectionMatrix;
|
||||||
if (!source) return;
|
if (!source) return;
|
||||||
const m=new Float32Array(source);for(let r=0;r<4;r++)m[12+r]=source[r]*this.origin.x+source[4+r]*this.origin.y+source[12+r];
|
const m=new Float32Array(source);for(let r=0;r<4;r++)m[12+r]=source[r]*this.origin.x+source[4+r]*this.origin.y+source[12+r];
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export function configure(p){if(!map)return;setBasemap(p.basemap);map.jumpTo({ce
|
|||||||
export function setBasemap(value){if(!map)return;const next=value==='road'?'road':'imagery';if(next===kind)return;kind=next;for(const [i,k]of ['base','labels'].entries())map.getSource(k)?.setTiles([urls(i)]);}
|
export function setBasemap(value){if(!map)return;const next=value==='road'?'road':'imagery';if(next===kind)return;kind=next;for(const [i,k]of ['base','labels'].entries())map.getSource(k)?.setTiles([urls(i)]);}
|
||||||
export function refresh(){revision++;for(const [i,k]of ['base','labels'].entries())map?.getSource(k)?.setTiles([urls(i)]);tileBuffer?.schedule();}
|
export function refresh(){revision++;for(const [i,k]of ['base','labels'].entries())map?.getSource(k)?.setTiles([urls(i)]);tileBuffer?.schedule();}
|
||||||
export function tool(value){mode=value;start=null;box=null;if(!map)return;if(mode==='box')map.dragPan.disable();else map.dragPan.enable();map.getCanvas().style.cursor=mode?'crosshair':'';if(mode)map.getCanvas().focus();}
|
export function tool(value){mode=value;start=null;box=null;if(!map)return;if(mode==='box')map.dragPan.disable();else map.dragPan.enable();map.getCanvas().style.cursor=mode?'crosshair':'';if(mode)map.getCanvas().focus();}
|
||||||
export function bounds(value){if(!map)return;map.fitBounds([[value.west,value.south],[value.east,value.north]],{padding:{left:60,right:Math.min(430,map.getContainer().clientWidth/2),top:70,bottom:60},duration:400});}
|
export function bounds(value){if(!map)return;map.fitBounds([[value.west,value.south],[value.east,value.north]],{padding:{left:Math.min(60,map.getContainer().clientWidth/5),right:Math.min(60,map.getContainer().clientWidth/5),top:70,bottom:60},duration:400});}
|
||||||
export function current(){if(!map)return;const p=map.getCenter();emit('rid-map-point',{longitude:p.lng,latitude:p.lat,zoom:map.getZoom()});marker?.setLngLat(p);}
|
export function current(){if(!map)return;const p=map.getCenter();emit('rid-map-point',{longitude:p.lng,latitude:p.lat,zoom:map.getZoom()});marker?.setLngLat(p);}
|
||||||
export function metrics(){return map?{tileBuffer:tileBuffer?.metrics(),ready:map.loaded(),camera:{longitude:map.getCenter().lng,latitude:map.getCenter().lat,zoom:map.getZoom()},basemap:kind}:null;}
|
export function metrics(){return map?{tileBuffer:tileBuffer?.metrics(),ready:map.loaded(),camera:{longitude:map.getCenter().lng,latitude:map.getCenter().lat,zoom:map.getZoom()},basemap:kind}:null;}
|
||||||
export function close(){tileBuffer?.destroy();tileBuffer=null;observer?.disconnect();observer=null;map?.remove();map=null;marker=null;boxElement=null;mode='';start=null;box=null;}
|
export function close(){tileBuffer?.destroy();tileBuffer=null;observer?.disconnect();observer=null;map?.remove();map=null;marker=null;boxElement=null;mode='';start=null;box=null;}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,4 +1,4 @@
|
|||||||
/* Approved A: manual target classification and an on-demand management drawer. */
|
/* Approved B: category navigation and an inline editor within the full-page table. */
|
||||||
.rt-list-badge { display: inline-flex; align-items: center; flex: none; border: 1px solid #b5c6d946; border-radius: 4px; padding: 3px 5px; font-size: 10px; line-height: 1.3; color: #c2d0df; background: #b5c6d90b; white-space: nowrap; }
|
.rt-list-badge { display: inline-flex; align-items: center; flex: none; border: 1px solid #b5c6d946; border-radius: 4px; padding: 3px 5px; font-size: 10px; line-height: 1.3; color: #c2d0df; background: #b5c6d90b; white-space: nowrap; }
|
||||||
.rt-list-badge::before { content: '○'; margin-right: 4px; }
|
.rt-list-badge::before { content: '○'; margin-right: 4px; }
|
||||||
.rt-list-badge[data-kind=white] { color: #9edac1; border-color: #9edac14a; background: #69bd9712; }
|
.rt-list-badge[data-kind=white] { color: #9edac1; border-color: #9edac14a; background: #69bd9712; }
|
||||||
@@ -28,51 +28,35 @@
|
|||||||
.rt-target-label[data-list-kind=white] { color: #9edac1 !important; border-color: #9edac17a; }
|
.rt-target-label[data-list-kind=white] { color: #9edac1 !important; border-color: #9edac17a; }
|
||||||
.rt-list-sync-error { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; color: #ffb1a9; font-size: 11px; line-height: 1.8; margin: 10px 0; }
|
.rt-list-sync-error { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; color: #ffb1a9; font-size: 11px; line-height: 1.8; margin: 10px 0; }
|
||||||
.mc-layout-b .rt-list-sync-error button { font-size: 11px; padding: 4px 7px; }
|
.mc-layout-b .rt-list-sync-error button { font-size: 11px; padding: 4px 7px; }
|
||||||
#rt-list-manager { position: absolute; top: 76px; right: 16px; bottom: 16px; width: 420px; max-width: calc(100% - 32px); z-index: 10; border: 1px solid var(--work-line); border-radius: 12px; background: #081625ed; backdrop-filter: var(--glass-filter); -webkit-backdrop-filter: var(--glass-filter); box-shadow: 0 12px 35px #0005; display: flex; flex-direction: column; color: var(--work-text); overflow: hidden; }
|
#target-lists-view{background:var(--work-panel);backdrop-filter:none;overflow:hidden}
|
||||||
.mc-layout-b[data-lists-open=true] .live-detail { visibility: hidden; pointer-events: none; }
|
#rt-list-manager{position:absolute;inset:0;width:auto;max-width:none;z-index:auto;display:flex;flex-direction:column;padding:24px 28px;gap:18px;color:var(--work-text);background:transparent;overflow:hidden}
|
||||||
.rt-list-manager-head { display: flex; align-items: center; gap: 8px; padding: 0 16px; height: 54px; min-height: 54px; border-bottom: 1px solid var(--work-line); background: var(--glass-solid); }
|
.rt-list-manager-head{display:flex;align-items:center;gap:10px;flex:none;background:none;border:0;padding:0;min-height:60px}
|
||||||
.rt-list-manager-head h2 { font-size: 16px; margin-right: auto; }
|
.rt-list-manager-head>div{margin-right:auto;min-width:0}.rt-list-manager-head h2{font-size:24px;margin:0 0 8px}.rt-list-manager-head p{font-size:12px;color:var(--work-muted);line-height:1.8;margin:0}
|
||||||
.rt-list-manager button { font-size: 12px; border: 1px solid var(--work-line); border-radius: 6px; padding: 7px 9px; color: var(--work-text); background: #8bbdff0b; box-shadow: none; }
|
.rt-list-manager button{font:inherit;font-size:12px;border:1px solid var(--work-line);border-radius:7px;padding:9px 12px;color:var(--work-text);background:var(--work-input);box-shadow:none;cursor:pointer;white-space:nowrap}.rt-list-manager button:hover:not(:disabled){background:#8bbdff24}.rt-list-manager button:disabled{opacity:.45;cursor:default}
|
||||||
.rt-list-manager button:hover:not(:disabled) { background: #8bbdff24; }
|
.rt-list-manager :focus-visible{outline:2px solid #91c9ff;outline-offset:2px}
|
||||||
.rt-list-manager button:disabled { opacity: .45; cursor: default; }
|
.rt-list-manager-body{display:grid;grid-template-columns:200px minmax(0,1fr);gap:20px;flex:1;min-height:0;overflow:hidden;padding:0}
|
||||||
.rt-list-manager-body { flex: 1; min-height: 0; overflow: auto; padding: 16px; scrollbar-width: thin; }
|
.rt-list-table-panel,.rt-list-category-panel{background:var(--glass-surface);backdrop-filter:blur(7px);border:1px solid var(--work-line);border-radius:14px;min-width:0;min-height:0}
|
||||||
.rt-list-help { font-size: 11px; color: var(--work-muted); line-height: 1.8; }
|
.rt-list-table-panel{display:flex;flex-direction:column;overflow:hidden}.rt-list-table-toolbar{padding:18px;display:flex;align-items:center;gap:15px;flex-wrap:wrap;border-bottom:1px solid var(--work-line)}
|
||||||
.rt-list-tabs { display: flex; flex-wrap: wrap; gap: 7px; margin: 13px 0; }
|
.rt-list-tabs{display:flex;flex-wrap:wrap;gap:8px;margin:0}.rt-list-tabs button[aria-pressed=true]{background:#245d9d;border-color:#83b9ed}.rt-list-search{display:block;margin-left:auto;min-width:180px;flex:1;max-width:300px}.rt-list-search-label{display:block;font-size:11px;margin-bottom:6px;color:var(--work-muted)}
|
||||||
.rt-list-search { display: block; }
|
.rt-list-manager :is(input,select,textarea){width:100%;min-width:0;padding:10px;background:var(--work-input);border:1px solid var(--work-line);border-radius:7px;color:var(--work-text);font:inherit;font-size:12px;box-shadow:none}.rt-list-manager input::placeholder{color:var(--work-muted)}.rt-list-manager input,.rt-list-manager select{height:40px}
|
||||||
.rt-list-search > span { display: block; font-size: 11px; color: var(--work-muted); margin-bottom: 7px; }
|
.rt-list-rows{flex:1;min-height:160px;max-height:none;overflow:auto;scrollbar-width:thin;margin:0}.rt-list-rows table{border-collapse:collapse;text-align:left;width:100%;table-layout:fixed}.rt-list-rows th{position:sticky;top:0;z-index:1;background:#0a1d30;color:var(--work-muted);font-size:11px;font-weight:400}.rt-list-rows th:nth-child(1){width:26%}.rt-list-rows th:nth-child(2){width:17%}.rt-list-rows th:nth-child(4){width:135px}.rt-list-rows th,.rt-list-rows td{padding:16px;border-bottom:1px solid var(--work-line)}
|
||||||
.rt-list-manager :is(input, select, textarea) { width: 100%; min-width: 0; padding: 9px 10px; background: var(--work-input); border: 1px solid var(--work-line); border-radius: 7px; color: var(--work-text); font-size: 12px; box-shadow: none; }
|
.rt-list-row{display:table-row}.rt-list-row:hover,.rt-list-row.selected{background:#245d9d22}.rt-list-row-main strong{font-size:12px;overflow-wrap:anywhere}.rt-list-row p{margin:0;font-size:11px;line-height:1.8;overflow-wrap:anywhere;color:var(--work-muted)}.rt-list-row-actions{white-space:nowrap}.rt-list-row-actions button{font-size:11px;padding:6px 9px;margin-right:5px}.rt-list-help{padding:10px 18px;font-size:12px;color:var(--work-muted);line-height:1.8}.rt-list-table-panel>.rt-list-sync-error{margin:0;padding:10px 18px;flex:none}
|
||||||
.rt-list-manager input, .rt-list-manager select { height: 38px; }
|
.rt-list-pagination{display:flex;justify-content:space-between;align-items:center;gap:10px;margin:0;padding:14px 18px;border-top:1px solid var(--work-line);color:var(--work-muted);font-size:12px;flex:none}
|
||||||
.rt-list-manager input::placeholder { color: var(--work-muted); }
|
.rt-list-category-panel{padding:20px;overflow:auto;scrollbar-width:thin}.rt-list-category-panel>h3{font-size:16px;margin:0 0 22px}.rt-list-category-panel .rt-list-tabs{flex-direction:column}.rt-list-category-panel .rt-list-tabs button{text-align:left;width:100%;padding:12px}.rt-list-policy{margin-top:26px;border-top:1px solid var(--work-line);padding-top:20px}.rt-list-policy h3{font-size:12px;margin:0 0 10px}.rt-list-policy p{font-size:12px;line-height:1.9;color:var(--work-muted)}
|
||||||
.rt-list-rows { max-height: 180px; overflow: auto; scrollbar-width: thin; margin-top: 6px; }
|
.rt-list-rows .rt-inline-editor-row>td{padding:18px;background:#0a2339a8;border-top:1px solid #8bbdff50;border-bottom:1px solid #8bbdff50}
|
||||||
.rt-list-row { display: flex; gap: 7px; align-items: center; border-bottom: 1px solid var(--work-line); padding: 13px 0; }
|
#rt-list-entry-form{display:grid;grid-template-columns:minmax(150px,1fr) 130px minmax(180px,2fr) 120px;gap:14px;align-items:end;padding:0;border:0;min-width:0}.rt-inline-editor-heading{grid-column:1/-1;display:flex;align-items:center;justify-content:space-between;gap:15px}.rt-inline-editor-heading button{font-size:11px;padding:6px 10px}#rt-list-entry-form h3{font-size:14px;margin:0}#rt-list-entry-form label{display:block;font-size:12px;color:var(--work-muted);margin:0;min-width:0}#rt-list-entry-form :is(input,select,textarea){margin-top:8px}#rt-list-entry-form textarea{height:70px;resize:vertical;max-height:200px}#rt-list-entry-form .primary{width:100%;background:#245d9d;color:#fff;margin:0;min-height:40px}.rt-inline-editor-actions{align-self:end}
|
||||||
.rt-list-row-main { flex: 1; min-width: 0; }
|
.rt-list-manager-footer{background:none;border:0;padding:0;flex:none;display:block}.rt-list-manager-footer p{font-size:12px;line-height:1.8;color:#9edac1;margin:0 0 6px;overflow-wrap:anywhere}.rt-list-manager-footer p:empty{display:none}.rt-list-manager-footer p.error{color:#ffb1a9}.rt-list-manager-footer small{font-size:11px;color:var(--work-muted)}
|
||||||
.rt-list-row strong { font-size: 12px; overflow-wrap: anywhere; }
|
/* Increase usable target-directory space independently of the management page. */
|
||||||
.rt-list-row p { font-size: 11px; color: var(--work-muted); line-height: 1.7; overflow-wrap: anywhere; margin-top: 6px; }
|
.mc-layout-b .live-list-controls{padding:10px 14px;gap:6px}.mc-layout-b .rt-target-list-filters{margin-top:4px}.mc-layout-b .live-target-list button{padding:10px 8px;min-height:42px}
|
||||||
.rt-list-row p:empty { display: none; }
|
@media(max-width:1199px){#rt-list-manager{padding:20px;gap:14px}.rt-list-manager-body{grid-template-columns:175px minmax(0,1fr);gap:14px}.rt-list-rows th,.rt-list-rows td{padding:12px}.rt-list-category-panel{padding:18px}}
|
||||||
.rt-list-row button { font-size: 11px; padding: 5px 7px; flex-shrink: 0; }
|
@media(max-width:900px),(max-height:570px){#target-lists-view{overflow:auto}#rt-list-manager{position:relative;inset:auto;min-height:100%;overflow:visible;height:auto;padding:16px}.rt-list-manager-body{display:flex;flex-direction:column;overflow:visible;flex:none}.rt-list-table-panel{min-height:380px}.rt-list-rows{max-height:420px}.rt-list-rows table{min-width:580px}.rt-list-search{margin-left:0;max-width:none;flex-basis:100%}.rt-list-category-panel{overflow:visible}.rt-list-manager-head{flex-wrap:wrap}.rt-list-manager-head>div{flex-basis:100%;margin-bottom:4px}.rt-list-manager-head h2{font-size:21px}.rt-list-manager-head p{font-size:11px}}
|
||||||
.rt-list-pagination { display: flex; justify-content: space-between; align-items: center; gap: 9px; margin: 12px 0 18px; font-size: 11px; color: var(--work-muted); }
|
@supports not (backdrop-filter:blur(7px)){.rt-list-table-panel,.rt-list-category-panel{background:#061221f5}}
|
||||||
#rt-list-entry-form { border-top: 1px solid var(--work-line); padding-top: 18px; }
|
|
||||||
#rt-list-entry-form h3 { font-size: 14px; }
|
|
||||||
#rt-list-entry-form label { display: block; font-size: 12px; margin: 14px 0 7px; }
|
|
||||||
#rt-list-entry-form textarea { height: 65px; resize: vertical; max-height: 180px; }
|
|
||||||
.rt-list-manager #rt-list-entry-form .primary { width: 100%; background: var(--glass-action); color: white; margin-top: 14px; }
|
|
||||||
.rt-list-manager-footer { display: block; background: var(--glass-solid); border-top: 1px solid var(--work-line); padding: 11px 16px; flex-shrink: 0; }
|
|
||||||
.rt-list-manager-footer p { font-size: 12px; line-height: 1.8; margin-bottom: 5px; color: #9edac1; overflow-wrap: anywhere; }
|
|
||||||
.rt-list-manager-footer p:empty { display: none; }
|
|
||||||
.rt-list-manager-footer p.error { color: #ffb1a9; }
|
|
||||||
.rt-list-manager-footer small { color: var(--work-muted); font-size: 10px; line-height: 1.8; }
|
|
||||||
.mc-layout-b.compact #rt-list-manager { left: 16px; right: 16px; width: auto; max-width: none; }
|
|
||||||
.mc-layout-b.compact[data-lists-open=true] :is(#rt-directory, #rt-details, #rt-dock) { visibility: hidden; pointer-events: none; }
|
|
||||||
.mc-layout-b.compact .rt-blacklist-alert { top: 61px; left: 16px; right: 16px; justify-content: space-between; }
|
|
||||||
.mc-layout-b.compact .rt-blacklist-alert span { font-size: 11px; }
|
|
||||||
@container(max-width: 500px) {
|
|
||||||
.rt-list-row { flex-wrap: wrap; }
|
|
||||||
.rt-list-row-main { flex-basis: calc(100% - 80px); }
|
|
||||||
.rt-list-rows { max-height: 180px; }
|
|
||||||
.rt-list-manager-head { padding: 0 13px; }
|
|
||||||
.rt-list-manager-head h2 { font-size: 14px; }
|
|
||||||
.rt-list-manager-body { padding: 14px; }
|
|
||||||
.rt-blacklist-alert span { display: none; }
|
|
||||||
}
|
|
||||||
|
|
||||||
.mc-layout-b.compact[data-lists-open=true] .rt-blacklist-alert { visibility: hidden; }
|
.mc-layout-b.compact .rt-blacklist-alert{top:61px;left:16px;right:16px;justify-content:space-between}.mc-layout-b.compact .rt-blacklist-alert span{display:none}
|
||||||
|
|
||||||
|
/* The map bleeds beneath the global header; its restore buttons stay in the usable workspace. */
|
||||||
|
body.b[data-screen=realtime] .live-panel-restores{top:64px;left:calc(var(--navigation-width,68px) + 16px)}
|
||||||
|
|
||||||
|
@media(max-width:1199px){#rt-list-entry-form{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}#rt-list-entry-form .rt-inline-note{grid-column:1/-1}#rt-list-entry-form .rt-inline-editor-actions{grid-column:1/-1;text-align:right}#rt-list-entry-form .primary{width:auto;min-width:150px}}
|
||||||
|
@media(max-width:900px),(max-height:570px){.rt-list-category-panel{padding:12px}.rt-list-category-panel>h3,.rt-list-category-panel .rt-list-policy{display:none}.rt-list-category-panel .rt-list-tabs{flex-direction:row}.rt-list-category-panel .rt-list-tabs button{width:auto}.rt-list-table-panel{min-height:380px}}
|
||||||
|
@media(max-width:767px){.rt-list-rows table{min-width:0;table-layout:auto;display:block}.rt-list-rows thead{display:none}.rt-list-rows tbody{display:block}.rt-list-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;padding:14px;border-bottom:1px solid var(--work-line)}.rt-list-rows .rt-list-row td{display:block;border:0;padding:0;min-width:0}.rt-list-row-note{grid-column:1/-1}.rt-list-row-actions{grid-column:1/-1;display:flex!important;justify-content:flex-end}.rt-inline-editor-row,.rt-inline-editor-row>td{display:block;width:100%}.rt-list-rows .rt-inline-editor-row>td{padding:14px}#rt-list-entry-form{display:flex;flex-direction:column;align-items:stretch;gap:14px}.rt-inline-editor-heading{width:100%}#rt-list-entry-form .primary{width:100%}.rt-list-rows{max-height:600px}.rt-list-category-panel .rt-list-tabs{gap:5px}.rt-list-category-panel .rt-list-tabs button{font-size:11px;padding:9px}.rt-list-search{flex-basis:auto;width:100%;max-width:none}}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1600 1000"><defs><linearGradient id="sky" x2="1" y2="1"><stop stop-color="#e5f4ff"/><stop offset=".5" stop-color="#a3cde9"/><stop offset="1" stop-color="#eff4ff"/></linearGradient><linearGradient id="ribbon" x2="0" y2="1"><stop stop-color="#fff" stop-opacity=".85"/><stop offset="1" stop-color="#79a5db" stop-opacity=".15"/></linearGradient></defs><rect width="1600" height="1000" fill="url(#sky)"/><g fill="none" stroke="url(#ribbon)"><path d="M-200 920C380 1000 350-260 1800 70" stroke-width="190"/><path d="M-100 1120C640 1130 550-90 1800 280" stroke-width="100"/><path d="M-200 720C330 780 320-400 1800-90" stroke-width="25"/></g></svg>
|
||||||
|
After Width: | Height: | Size: 694 B |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1600 1000"><defs><linearGradient id="mist" x2="0" y2="1"><stop stop-color="#eef8ed"/><stop offset="1" stop-color="#a9cec6"/></linearGradient><linearGradient id="ridge" x2="0" y2="1"><stop stop-color="#72aaa5"/><stop offset="1" stop-color="#d2e5d9"/></linearGradient></defs><rect width="1600" height="1000" fill="url(#mist)"/><circle cx="1170" cy="250" r="110" fill="#fff9dd" opacity=".8"/><path d="M0 650Q220 380 470 530T1000 490T1600 420V1000H0Z" fill="#c0d9ce"/><path d="M0 840Q280 460 620 690T1140 620T1600 610V1000H0Z" fill="url(#ridge)"/><path d="M0 910Q380 740 710 880T1260 800T1600 820V1000H0Z" fill="#659d99" opacity=".45"/></svg>
|
||||||
|
After Width: | Height: | Size: 692 B |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1600 1000"><defs><linearGradient id="sand" x2="1" y2="1"><stop stop-color="#fff4e1"/><stop offset=".55" stop-color="#e9cfb4"/><stop offset="1" stop-color="#e2b8a7"/></linearGradient><linearGradient id="light" x2="0" y2="1"><stop stop-color="#fffdf4" stop-opacity=".85"/><stop offset="1" stop-color="#e1b799" stop-opacity=".2"/></linearGradient></defs><rect width="1600" height="1000" fill="url(#sand)"/><path d="M-200 840Q320 160 940 570T1800 280V1000H-200Z" fill="url(#light)"/><path d="M-100 990Q500 410 1080 760T1800 530" fill="none" stroke="#fff2df" stroke-width="90" opacity=".65"/><path d="M-80 1020Q560 530 1170 860T1740 740" fill="none" stroke="#cb9e8e" stroke-width="3" opacity=".4"/></svg>
|
||||||
|
After Width: | Height: | Size: 753 B |
@@ -15,22 +15,22 @@ body[data-screen=home][data-menu-hidden=true] .home-launcher.homescreen { left:
|
|||||||
.home-card-desc { min-height: 52px; }
|
.home-card-desc { min-height: 52px; }
|
||||||
.home-card-preview { margin-bottom: 8px; }
|
.home-card-preview { margin-bottom: 8px; }
|
||||||
.home-card-open { margin-top: auto; }
|
.home-card-open { margin-top: auto; }
|
||||||
body[data-screen=register] #workspace-content,
|
body:is([data-screen=register], [data-screen=archives]) #workspace-content,
|
||||||
#appearance-view { container: workbench / inline-size; overflow: auto; }
|
#appearance-view { container: workbench / inline-size; overflow: auto; }
|
||||||
body[data-screen=register] #workspace-content > div { height: 100%; min-height: 0; }
|
body:is([data-screen=register], [data-screen=archives]) #workspace-content > div { height: 100%; min-height: 0; }
|
||||||
body[data-screen=register] .registry-workspace {
|
body:is([data-screen=register], [data-screen=archives]) .registry-workspace {
|
||||||
height: 100%; min-height: 0; max-height: 100%; padding: 24px;
|
height: 100%; min-height: 0; max-height: 100%; padding: 24px;
|
||||||
grid-template-columns: 240px minmax(0, 1fr) 280px;
|
grid-template-columns: 240px minmax(0, 1fr) 280px;
|
||||||
grid-template-rows: minmax(0, 1fr); gap: 18px;
|
grid-template-rows: minmax(0, 1fr); gap: 18px;
|
||||||
}
|
}
|
||||||
.workbench-panel,
|
.workbench-panel,
|
||||||
body[data-screen=register] .registry-workspace :is(.history-panel, .registration-editor, #registration-result) {
|
body:is([data-screen=register], [data-screen=archives]) .registry-workspace :is(.history-panel, .registration-editor, #registration-result) {
|
||||||
min-width: 0; min-height: 0; border: 1px solid var(--work-line); border-radius: 12px;
|
min-width: 0; min-height: 0; border: 1px solid var(--work-line); border-radius: 12px;
|
||||||
background: var(--work-panel); color: var(--work-text);
|
background: var(--work-panel); color: var(--work-text);
|
||||||
backdrop-filter: var(--glass-filter); -webkit-backdrop-filter: var(--glass-filter);
|
backdrop-filter: var(--glass-filter); -webkit-backdrop-filter: var(--glass-filter);
|
||||||
box-shadow: 0 12px 28px #0003, inset 0 1px 0 #ffffff0b;
|
box-shadow: 0 12px 28px #0003, inset 0 1px 0 #ffffff0b;
|
||||||
}
|
}
|
||||||
body[data-screen=register] .registry-workspace .history-panel {
|
body:is([data-screen=register], [data-screen=archives]) .registry-workspace .history-panel {
|
||||||
display: flex; flex-direction: column; gap: 0; padding: 0; overflow: hidden;
|
display: flex; flex-direction: column; gap: 0; padding: 0; overflow: hidden;
|
||||||
}
|
}
|
||||||
.registry-workspace .history-heading {
|
.registry-workspace .history-heading {
|
||||||
@@ -45,7 +45,7 @@ body[data-screen=register] .registry-workspace .history-panel {
|
|||||||
.registry-workspace .pagination { margin: 0; padding: 14px 16px; flex-shrink: 0; }
|
.registry-workspace .pagination { margin: 0; padding: 14px 16px; flex-shrink: 0; }
|
||||||
.registry-workspace #archive-warning:not([hidden]) { padding: 10px 16px; flex-shrink: 0; }
|
.registry-workspace #archive-warning:not([hidden]) { padding: 10px 16px; flex-shrink: 0; }
|
||||||
.registry-workspace .export-controls .registry-popup { left: 10px; right: 10px; }
|
.registry-workspace .export-controls .registry-popup { left: 10px; right: 10px; }
|
||||||
body[data-screen=register] .registry-workspace .registration-editor { display: flex; flex-direction: column; overflow: hidden; }
|
body:is([data-screen=register], [data-screen=archives]) .registry-workspace .registration-editor { display: flex; flex-direction: column; overflow: hidden; }
|
||||||
.registry-workspace .registration-editor .registration-heading {
|
.registry-workspace .registration-editor .registration-heading {
|
||||||
padding: 17px 20px; margin: 0; min-height: 70px; flex-shrink: 0; border-bottom: 1px solid var(--work-line);
|
padding: 17px 20px; margin: 0; min-height: 70px; flex-shrink: 0; border-bottom: 1px solid var(--work-line);
|
||||||
}
|
}
|
||||||
@@ -53,22 +53,22 @@ body[data-screen=register] .registry-workspace .registration-editor { display: f
|
|||||||
.registry-workspace .registration-editor .registration-heading p { font-size: 12px; }
|
.registry-workspace .registration-editor .registration-heading p { font-size: 12px; }
|
||||||
.registry-workspace #register-form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
|
.registry-workspace #register-form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
|
||||||
.registry-workspace .registration-fields-scroll { flex: 1; min-height: 0; overflow: auto; padding: 22px 20px; scroll-padding-block: 18px; scrollbar-width: thin; }
|
.registry-workspace .registration-fields-scroll { flex: 1; min-height: 0; overflow: auto; padding: 22px 20px; scroll-padding-block: 18px; scrollbar-width: thin; }
|
||||||
body[data-screen=register] .registry-workspace #register-form .registry-group {
|
body:is([data-screen=register], [data-screen=archives]) .registry-workspace #register-form .registry-group {
|
||||||
border: 0; border-radius: 0; border-bottom: 1px solid var(--work-line);
|
border: 0; border-radius: 0; border-bottom: 1px solid var(--work-line);
|
||||||
background: none; backdrop-filter: none; -webkit-backdrop-filter: none;
|
background: none; backdrop-filter: none; -webkit-backdrop-filter: none;
|
||||||
padding: 0 0 23px; margin: 0 0 23px; box-shadow: none;
|
padding: 0 0 23px; margin: 0 0 23px; box-shadow: none;
|
||||||
}
|
}
|
||||||
body[data-screen=register] .registry-workspace #register-form .registry-group:last-of-type { border-bottom: 0; padding-bottom: 10px; margin-bottom: 0; }
|
body:is([data-screen=register], [data-screen=archives]) .registry-workspace #register-form .registry-group:last-of-type { border-bottom: 0; padding-bottom: 10px; margin-bottom: 0; }
|
||||||
.registry-workspace .registration-number { grid-template-columns: 1fr; gap: 8px; }
|
.registry-workspace .registration-number { grid-template-columns: 1fr; gap: 8px; }
|
||||||
.registry-workspace .registration-number #fpv-hint { margin-top: 0; }
|
.registry-workspace .registration-number #fpv-hint { margin-top: 0; }
|
||||||
body[data-screen=register] .registry-workspace .registration-savebar {
|
body:is([data-screen=register], [data-screen=archives]) .registry-workspace .registration-savebar {
|
||||||
position: static; flex-shrink: 0; margin: 0; padding: 15px 20px;
|
position: static; flex-shrink: 0; margin: 0; padding: 15px 20px;
|
||||||
background: var(--glass-solid); box-shadow: none; backdrop-filter: none;
|
background: var(--glass-solid); box-shadow: none; backdrop-filter: none;
|
||||||
-webkit-backdrop-filter: none; gap: 12px;
|
-webkit-backdrop-filter: none; gap: 12px;
|
||||||
}
|
}
|
||||||
.registry-workspace .registration-savebar #draft-state { font-size: 11px; }
|
.registry-workspace .registration-savebar #draft-state { font-size: 11px; }
|
||||||
.registry-workspace #register-button { font-size: 12px; }
|
.registry-workspace #register-button { font-size: 12px; }
|
||||||
body[data-screen=register] .registry-workspace #registration-result {
|
body:is([data-screen=register], [data-screen=archives]) .registry-workspace #registration-result {
|
||||||
padding: 0; margin: 0; overflow: auto; scroll-padding-top: 60px; scrollbar-width: thin;
|
padding: 0; margin: 0; overflow: auto; scroll-padding-top: 60px; scrollbar-width: thin;
|
||||||
}
|
}
|
||||||
#registration-result > h2 {
|
#registration-result > h2 {
|
||||||
@@ -91,7 +91,7 @@ body[data-screen=register] .registry-workspace #registration-result {
|
|||||||
.registry-workspace #registration-result .result-tip { font-size: 12px; }
|
.registry-workspace #registration-result .result-tip { font-size: 12px; }
|
||||||
#appearance-view .settings-layout {
|
#appearance-view .settings-layout {
|
||||||
height: 100%; min-height: 0; max-width: none; width: 100%; padding: 24px;
|
height: 100%; min-height: 0; max-width: none; width: 100%; padding: 24px;
|
||||||
display: grid; grid-template-columns: 190px minmax(0, 1fr) 285px;
|
display: grid; grid-template-columns: minmax(0, 1fr) 285px;
|
||||||
grid-template-rows: minmax(0, 1fr); align-items: start; gap: 18px; overflow: hidden;
|
grid-template-rows: minmax(0, 1fr); align-items: start; gap: 18px; overflow: hidden;
|
||||||
}
|
}
|
||||||
#appearance-view .settings-sidebar { padding: 20px 12px; height: auto; }
|
#appearance-view .settings-sidebar { padding: 20px 12px; height: auto; }
|
||||||
@@ -107,6 +107,7 @@ body[data-screen=register] .registry-workspace #registration-result {
|
|||||||
#appearance-view .glass-material-note { padding: 14px 0 20px; border: 0; border-radius: 0; background: none; border-bottom: 1px solid var(--work-line); margin: 0; }
|
#appearance-view .glass-material-note { padding: 14px 0 20px; border: 0; border-radius: 0; background: none; border-bottom: 1px solid var(--work-line); margin: 0; }
|
||||||
#appearance-view .glass-material-note p { font-size: 12px; }
|
#appearance-view .glass-material-note p { font-size: 12px; }
|
||||||
#appearance-view .section-caption { margin: 23px 0 13px; }
|
#appearance-view .section-caption { margin: 23px 0 13px; }
|
||||||
|
#appearance-view #appearance-wallpapers { margin-top: 0 !important; }
|
||||||
#appearance-view .wall-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
|
#appearance-view .wall-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
|
||||||
#appearance-view .wall-choice { padding: 0; border-radius: 8px; border: 1px solid var(--work-line); background: #07152544; }
|
#appearance-view .wall-choice { padding: 0; border-radius: 8px; border: 1px solid var(--work-line); background: #07152544; }
|
||||||
#appearance-view .wall-choice img { height: 80px !important; }
|
#appearance-view .wall-choice img { height: 80px !important; }
|
||||||
@@ -126,7 +127,7 @@ body[data-screen=register] .registry-workspace #registration-result {
|
|||||||
#desktop-sample::before, #desktop-sample::after { display: none; }
|
#desktop-sample::before, #desktop-sample::after { display: none; }
|
||||||
#appearance-wallpaper { position: absolute; inset: 0; width: 100%; height: 100%; filter: blur(var(--preview-blur, 0px)); }
|
#appearance-wallpaper { position: absolute; inset: 0; width: 100%; height: 100%; filter: blur(var(--preview-blur, 0px)); }
|
||||||
.preview-shade { position: absolute; inset: 0; background: linear-gradient(var(--glass-workspace), var(--glass-workspace)), rgba(0, 0, 0, var(--preview-shade, .14)); }
|
.preview-shade { position: absolute; inset: 0; background: linear-gradient(var(--glass-workspace), var(--glass-workspace)), rgba(0, 0, 0, var(--preview-shade, .14)); }
|
||||||
.preview-material { position: absolute; inset: 20px 16px; border: 1px solid var(--work-line); border-radius: 8px; padding: 17px 14px; display: flex; flex-direction: column; gap: 10px; background: var(--work-panel); backdrop-filter: var(--glass-filter); -webkit-backdrop-filter: var(--glass-filter); }
|
.preview-material { position: absolute; inset: auto 12px 12px 36%; border: 1px solid var(--work-line); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 7px; background: var(--work-panel); backdrop-filter: var(--glass-filter); -webkit-backdrop-filter: var(--glass-filter); }
|
||||||
.preview-material span, .preview-material small { font-size: 10px; color: var(--work-muted); }
|
.preview-material span, .preview-material small { font-size: 10px; color: var(--work-muted); }
|
||||||
.preview-material strong { font-size: 14px; font-weight: 600; }
|
.preview-material strong { font-size: 14px; font-weight: 600; }
|
||||||
.preview-values { display: grid; grid-template-columns: 1fr 1fr; gap: 21px 12px; margin: 0 0 23px; }
|
.preview-values { display: grid; grid-template-columns: 1fr 1fr; gap: 21px 12px; margin: 0 0 23px; }
|
||||||
@@ -147,32 +148,32 @@ body[data-screen=register] .registry-workspace #registration-result {
|
|||||||
.home-card-open svg { position: static; }
|
.home-card-open svg { position: static; }
|
||||||
}
|
}
|
||||||
@container workbench (max-width: 1199px) {
|
@container workbench (max-width: 1199px) {
|
||||||
body[data-screen=register] .registry-workspace { height: auto; min-height: 100%; max-height: none; overflow: visible; grid-template-columns: 224px minmax(0, 1fr); grid-template-rows: auto auto; }
|
body:is([data-screen=register], [data-screen=archives]) .registry-workspace { height: auto; min-height: 100%; max-height: none; overflow: visible; grid-template-columns: 224px minmax(0, 1fr); grid-template-rows: auto auto; }
|
||||||
body[data-screen=register] .registry-workspace .history-panel { grid-row: 1/3; max-height: calc(100dvh - 96px); position: sticky; top: 24px; }
|
body:is([data-screen=register], [data-screen=archives]) .registry-workspace .history-panel { grid-row: 1/3; max-height: calc(100dvh - 96px); position: sticky; top: 24px; }
|
||||||
body[data-screen=register] .registry-workspace .registration-editor { height: max(480px, calc(100dvh - 96px)); }
|
body:is([data-screen=register], [data-screen=archives]) .registry-workspace .registration-editor { height: max(480px, calc(100dvh - 96px)); }
|
||||||
body[data-screen=register] .registry-workspace #registration-result { grid-column: 2; max-height: none; }
|
body:is([data-screen=register], [data-screen=archives]) .registry-workspace #registration-result { grid-column: 2; max-height: none; }
|
||||||
#appearance-view .settings-layout { height: auto; min-height: 100%; overflow: visible; grid-template-columns: 160px minmax(0, 1fr); grid-template-rows: auto auto; }
|
#appearance-view .settings-layout { height: auto; min-height: 100%; overflow: visible; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; }
|
||||||
#appearance-view .settings-sidebar { grid-row: 1/3; }
|
#appearance-view .settings-sidebar { grid-row: 1/3; }
|
||||||
#appearance-view .setting-content { height: auto; max-height: none; }
|
#appearance-view .setting-content { height: auto; max-height: none; }
|
||||||
#appearance-view .settings-scroll { overflow: visible; }
|
#appearance-view .settings-scroll { overflow: visible; }
|
||||||
#appearance-view .settings-preview { grid-column: 2; max-height: none; }
|
#appearance-view .settings-preview { grid-column: auto; max-height: none; }
|
||||||
}
|
}
|
||||||
/* The container itself scrolls at narrower sizes; descendants control the columns. */
|
/* The container itself scrolls at narrower sizes; descendants control the columns. */
|
||||||
@media(max-width: 1267px) {
|
@media(max-width: 1267px) {
|
||||||
body[data-screen=register] #workspace-content, #appearance-view { overflow: auto; }
|
body:is([data-screen=register], [data-screen=archives]) #workspace-content, #appearance-view { overflow: auto; }
|
||||||
}
|
}
|
||||||
@container workbench (max-width: 767px) {
|
@container workbench (max-width: 767px) {
|
||||||
body[data-screen=register] .registry-workspace { display: flex; flex-direction: column; gap: 16px; padding: 16px; }
|
body:is([data-screen=register], [data-screen=archives]) .registry-workspace { display: flex; flex-direction: column; gap: 16px; padding: 16px; }
|
||||||
body[data-screen=register] .registry-workspace .history-panel { order: 0; height: 280px; max-height: 280px; flex-shrink: 0; position: relative; top: auto; }
|
body:is([data-screen=register], [data-screen=archives]) .registry-workspace .history-panel { order: 0; height: 280px; max-height: 280px; flex-shrink: 0; position: relative; top: auto; }
|
||||||
.registry-workspace .history-content { padding: 13px 15px; }
|
.registry-workspace .history-content { padding: 13px 15px; }
|
||||||
.registry-workspace .pagination { padding: 10px 15px; gap: 6px; }
|
.registry-workspace .pagination { padding: 10px 15px; gap: 6px; }
|
||||||
body[data-screen=register] .registry-workspace .registration-editor { order: 1; height: auto; min-height: 0; overflow: visible; flex-shrink: 0; }
|
body:is([data-screen=register], [data-screen=archives]) .registry-workspace .registration-editor { order: 1; height: auto; min-height: 0; overflow: visible; flex-shrink: 0; }
|
||||||
.registry-workspace #register-form { display: block; }
|
.registry-workspace #register-form { display: block; }
|
||||||
.registry-workspace .registration-fields-scroll { overflow: visible; padding: 20px 16px 30px; }
|
.registry-workspace .registration-fields-scroll { overflow: visible; padding: 20px 16px 30px; }
|
||||||
.registry-workspace .registration-fields { grid-template-columns: 1fr; }
|
.registry-workspace .registration-fields { grid-template-columns: 1fr; }
|
||||||
body[data-screen=register] .registry-workspace .registration-savebar { position: sticky; bottom: 0; padding: 14px 16px; z-index: 3; }
|
body:is([data-screen=register], [data-screen=archives]) .registry-workspace .registration-savebar { position: sticky; bottom: 0; padding: 14px 16px; z-index: 3; }
|
||||||
.registry-workspace #register-button { width: 100%; }
|
.registry-workspace #register-button { width: 100%; }
|
||||||
body[data-screen=register] .registry-workspace #registration-result { order: 2; flex-shrink: 0; overflow: visible; }
|
body:is([data-screen=register], [data-screen=archives]) .registry-workspace #registration-result { order: 2; flex-shrink: 0; overflow: visible; }
|
||||||
#registration-result > h2 { position: static; }
|
#registration-result > h2 { position: static; }
|
||||||
.registry-workspace #registration-result .empty-state { flex-direction: column; }
|
.registry-workspace #registration-result .empty-state { flex-direction: column; }
|
||||||
#appearance-view .settings-layout { display: flex; flex-direction: column; padding: 16px; gap: 16px; }
|
#appearance-view .settings-layout { display: flex; flex-direction: column; padding: 16px; gap: 16px; }
|
||||||
@@ -192,3 +193,19 @@ body[data-screen=register] .registry-workspace #registration-result {
|
|||||||
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; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Module pages share one navigation rail; archives occupy their own view. */
|
||||||
|
body[data-screen=register] .registry-workspace { grid-template-columns: minmax(0, 1fr) 280px; }
|
||||||
|
body[data-screen=archives] .registry-workspace { grid-template-columns: minmax(0, 1fr); }
|
||||||
|
body[data-screen=archives] .history-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 16px; align-content: start; }
|
||||||
|
body[data-screen=archives] .archive-card { margin: 0; }
|
||||||
|
@container workbench (max-width: 760px) {
|
||||||
|
body[data-screen=register] .registry-workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; height: auto; max-height: none; }
|
||||||
|
#appearance-view .settings-layout { grid-template-columns: minmax(0, 1fr); height: auto; overflow: visible; }
|
||||||
|
}
|
||||||
|
|
||||||
|
body[data-screen=archives] .registry-workspace .history-panel { grid-row: auto; height: calc(100dvh - 96px); max-height: none; position: static; }
|
||||||
|
@container workbench (max-width: 767px) {
|
||||||
|
body[data-screen=register] .registry-workspace #registration-result { grid-column: auto; }
|
||||||
|
body[data-screen=archives] .registry-workspace .history-panel { min-height: 420px; }
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ body[data-menu-hidden=true] .workspace-pane{left:0}body[data-menu-hidden=true] .
|
|||||||
.mc-layout-b{--dock-height:170px;--live-gap:16px;--list-width:260px;--detail-width:300px;--left-space:calc(var(--list-width) + 28px);--right-space:calc(var(--detail-width) + 28px);--dock-space:calc(var(--dock-height) + 56px);position:relative;height:100%;min-height:0;container-type:inline-size;overflow:hidden}
|
.mc-layout-b{--dock-height:170px;--live-gap:16px;--list-width:260px;--detail-width:300px;--left-space:calc(var(--list-width) + 28px);--right-space:calc(var(--detail-width) + 28px);--dock-space:calc(var(--dock-height) + 56px);position:relative;height:100%;min-height:0;container-type:inline-size;overflow:hidden}
|
||||||
.mc-layout-b.list-hidden{--left-space:16px}
|
.mc-layout-b.list-hidden{--left-space:16px}
|
||||||
.mc-layout-b.detail-hidden{--right-space:16px}
|
.mc-layout-b.detail-hidden{--right-space:16px}
|
||||||
.mc-layout-b.dock-hidden{--dock-space:104px}
|
.mc-layout-b.dock-hidden{--dock-space:76px}
|
||||||
.mc-layout-b .mc-map-area-top{position:absolute;inset:0;height:100%;min-height:0}
|
.mc-layout-b .mc-map-area-top{position:absolute;inset:0;height:100%;min-height:0}
|
||||||
.mc-layout-b .mc-floating-panel{position:absolute;top:76px;bottom:var(--dock-space);padding:0!important;display:flex;flex-direction:column;min-height:0;overflow:hidden;background:var(--work-panel);border:1px solid var(--work-line);backdrop-filter:blur(24px);border-radius:12px;color:var(--work-text);box-shadow:0 12px 35px #0002;z-index:5}
|
.mc-layout-b .mc-floating-panel{position:absolute;top:76px;bottom:var(--dock-space);padding:0!important;display:flex;flex-direction:column;min-height:0;overflow:hidden;background:var(--work-panel);border:1px solid var(--work-line);backdrop-filter:blur(24px);border-radius:12px;color:var(--work-text);box-shadow:0 12px 35px #0002;z-index:5}
|
||||||
.mc-layout-b .live-targets{left:var(--live-gap);width:var(--list-width)}
|
.mc-layout-b .live-targets{left:var(--live-gap);width:var(--list-width)}
|
||||||
@@ -114,6 +114,4 @@ body[data-menu-hidden=true] .workspace-pane{left:0}body[data-menu-hidden=true] .
|
|||||||
.mc-layout-b .live-basemap option{background:var(--mc-bg);color:var(--work-text)}
|
.mc-layout-b .live-basemap option{background:var(--mc-bg);color:var(--work-text)}
|
||||||
.theme-white .mc-layout-b .live-basemap option{background:#f4f8ff;color:#243b57}
|
.theme-white .mc-layout-b .live-basemap option{background:#f4f8ff;color:#243b57}
|
||||||
|
|
||||||
/* Realtime owns one business menu; other applications retain their navigation. */
|
|
||||||
body[data-screen=realtime] .reference-rail button:not(#rt-blacklist-menu):not(#geofence-menu),body[data-screen=realtime] .reference-rail .rail-rule{display:none!important}
|
|
||||||
.reference-rail #rt-blacklist-menu[aria-expanded=true]{background:#8bbdff24;color:var(--work-text)}
|
.reference-rail #rt-blacklist-menu[aria-expanded=true]{background:#8bbdff24;color:var(--work-text)}
|
||||||
|
|||||||
@@ -16,12 +16,14 @@ fn main() {
|
|||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
== "/realtime";
|
== "/realtime";
|
||||||
mount_to_body(move || {
|
mount_to_body(move || {
|
||||||
|
let lists = target_lists::Lists::new();
|
||||||
view! {
|
view! {
|
||||||
<div inner_html=include_str!("workspace.html")/>
|
<div inner_html=include_str!("workspace.html")/>
|
||||||
<section id="geofence-view" class="workspace-pane" tabindex="-1" aria-label="电子围栏" hidden inner_html=include_str!("geofences.html")/>
|
<section id="geofence-view" class="workspace-pane" tabindex="-1" aria-label="电子围栏" hidden inner_html=include_str!("geofences.html")/>
|
||||||
<section id="map-settings-view" class="workspace-pane" tabindex="-1" aria-label="地图配置" hidden inner_html=include_str!("map_settings.html")/>
|
<section id="map-settings-view" class="workspace-pane" tabindex="-1" aria-label="地图配置" hidden inner_html=include_str!("map_settings.html")/>
|
||||||
|
<section id="target-lists-view" class="workspace-pane" tabindex="-1" aria-label="黑白名单管理" hidden><target_lists::Manager lists=lists/></section>
|
||||||
<section id="workspace-content" class="workspace-pane">
|
<section id="workspace-content" class="workspace-pane">
|
||||||
{if realtime { view! { <realtime_ui::Realtime/> }.into_any() }
|
{if realtime { view! { <realtime_ui::Realtime lists=lists/> }.into_any() }
|
||||||
else { view! { <Registry/> }.into_any() }}
|
else { view! { <Registry/> }.into_any() }}
|
||||||
</section>
|
</section>
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -8,7 +8,21 @@ use wasm_bindgen::{JsCast, closure::Closure};
|
|||||||
use wasm_bindgen_futures::spawn_local;
|
use wasm_bindgen_futures::spawn_local;
|
||||||
use web_sys::{Element, Event, HtmlInputElement, HtmlSelectElement};
|
use web_sys::{Element, Event, HtmlInputElement, HtmlSelectElement};
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
|
enum Tab {
|
||||||
|
Location,
|
||||||
|
Downloads,
|
||||||
|
}
|
||||||
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
|
enum Step {
|
||||||
|
Region,
|
||||||
|
Layers,
|
||||||
|
Review,
|
||||||
|
}
|
||||||
struct State {
|
struct State {
|
||||||
|
tab: Tab,
|
||||||
|
step: Step,
|
||||||
|
regions_dirty: bool,
|
||||||
prefs: Option<Preferences>,
|
prefs: Option<Preferences>,
|
||||||
estimate: Option<DownloadRequest>,
|
estimate: Option<DownloadRequest>,
|
||||||
available: bool,
|
available: bool,
|
||||||
@@ -100,24 +114,181 @@ fn visible() -> bool {
|
|||||||
.body()
|
.body()
|
||||||
.is_some_and(|b| b.get_attribute("data-screen").as_deref() == Some("maps"))
|
.is_some_and(|b| b.get_attribute("data-screen").as_deref() == Some("maps"))
|
||||||
}
|
}
|
||||||
fn drawer(show: bool) {
|
fn hidden(id: &str, hide: bool) {
|
||||||
if let Some(e) = el("map-settings-drawer") {
|
if let Some(e) = el(id) {
|
||||||
if show {
|
if hide {
|
||||||
let _ = e.remove_attribute("hidden");
|
|
||||||
} else {
|
|
||||||
let _ = e.set_attribute("hidden", "");
|
let _ = e.set_attribute("hidden", "");
|
||||||
}
|
} else {
|
||||||
}
|
let _ = e.remove_attribute("hidden");
|
||||||
if let Ok(buttons) = document().query_selector_all("[data-map-action=drawer]") {
|
|
||||||
for i in 0..buttons.length() {
|
|
||||||
if let Some(e) = buttons.item(i).and_then(|n| n.dyn_into::<Element>().ok()) {
|
|
||||||
let _ = e.set_attribute("aria-expanded", if show { "true" } else { "false" });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn update_buttons(s: &Shared) {
|
fn focus(id: &str) {
|
||||||
|
if let Some(e) = el(id).and_then(|e| e.dyn_into::<web_sys::HtmlElement>().ok()) {
|
||||||
|
let _ = e.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn render_navigation(s: &Shared) {
|
||||||
let state = s.borrow();
|
let state = s.borrow();
|
||||||
|
let downloads = state.tab == Tab::Downloads;
|
||||||
|
hidden("map-location-panel", downloads);
|
||||||
|
hidden("map-download-panel", !downloads);
|
||||||
|
for (id, selected) in [
|
||||||
|
("map-tab-location", !downloads),
|
||||||
|
("map-tab-downloads", downloads),
|
||||||
|
] {
|
||||||
|
if let Some(e) = el(id) {
|
||||||
|
let _ = e.set_attribute("aria-selected", if selected { "true" } else { "false" });
|
||||||
|
let _ = e.set_attribute("tabindex", if selected { "0" } else { "-1" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (step, id, action) in [
|
||||||
|
(Step::Region, "map-step-region", "step-region"),
|
||||||
|
(Step::Layers, "map-step-layers", "step-layers"),
|
||||||
|
(Step::Review, "map-step-review", "step-review"),
|
||||||
|
] {
|
||||||
|
hidden(id, step != state.step);
|
||||||
|
if let Ok(Some(e)) = document().query_selector(&format!("[data-map-action={action}]")) {
|
||||||
|
if step == state.step {
|
||||||
|
let _ = e.set_attribute("aria-current", "step");
|
||||||
|
} else {
|
||||||
|
let _ = e.remove_attribute("aria-current");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hidden("map-step-back", state.step == Step::Region || state.running);
|
||||||
|
hidden("map-step-next", state.step == Step::Review);
|
||||||
|
hidden(
|
||||||
|
"map-download-start",
|
||||||
|
state.step != Step::Review || state.running,
|
||||||
|
);
|
||||||
|
hidden("map-download-cancel", !state.running);
|
||||||
|
}
|
||||||
|
fn select_tab(s: &Shared, tab: Tab) {
|
||||||
|
map("tool", &json!(""));
|
||||||
|
{
|
||||||
|
let mut state = s.borrow_mut();
|
||||||
|
state.tab = tab;
|
||||||
|
if tab == Tab::Downloads && state.running {
|
||||||
|
state.step = Step::Review;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
render_navigation(s);
|
||||||
|
}
|
||||||
|
fn summary() {
|
||||||
|
let b = bounds();
|
||||||
|
let label = if b.valid() {
|
||||||
|
format!(
|
||||||
|
"经度 {:.6} → {:.6}\n纬度 {:.6} → {:.6}",
|
||||||
|
b.west, b.east, b.south, b.north
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
"尚未选择有效范围,请框选或输入四侧坐标。".into()
|
||||||
|
};
|
||||||
|
text("map-bounds-summary", &label);
|
||||||
|
text(
|
||||||
|
"map-download-summary",
|
||||||
|
&format!(
|
||||||
|
"{label}\n层级 {}–{} · {}{}",
|
||||||
|
value("map-min-zoom"),
|
||||||
|
value("map-max-zoom"),
|
||||||
|
if checked("map-download-road") {
|
||||||
|
"路网与标注 "
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
},
|
||||||
|
if checked("map-download-imagery") {
|
||||||
|
"影像与标注"
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
fn go_step(s: &Shared, step: Step) {
|
||||||
|
if s.borrow().running || s.borrow().busy {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let error = if step != Step::Region && !bounds().valid() {
|
||||||
|
Some("请先框选有效范围,或填写正确的四侧坐标。".to_owned())
|
||||||
|
} else if step == Step::Review {
|
||||||
|
request().err()
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
if let Some(error) = error {
|
||||||
|
message("map-step-message", &error, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
map("tool", &json!(""));
|
||||||
|
s.borrow_mut().step = step;
|
||||||
|
message("map-step-message", "", false);
|
||||||
|
summary();
|
||||||
|
render_navigation(s);
|
||||||
|
focus(match step {
|
||||||
|
Step::Region => "map-step-region",
|
||||||
|
Step::Layers => "map-step-layers",
|
||||||
|
Step::Review => "map-step-review",
|
||||||
|
});
|
||||||
|
if step == Step::Review && s.borrow().estimate.is_none() {
|
||||||
|
estimate(s.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn estimate(s: Shared) {
|
||||||
|
if s.borrow().busy || s.borrow().running {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let r = match request() {
|
||||||
|
Ok(r) => r,
|
||||||
|
Err(e) => {
|
||||||
|
message("map-download-message", &e, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
s.borrow_mut().busy = true;
|
||||||
|
s.borrow_mut().estimate = None;
|
||||||
|
text("map-estimate-message", "正在核算下载范围…");
|
||||||
|
update_buttons(&s);
|
||||||
|
spawn_local(async move {
|
||||||
|
let result = post("/api/maps/downloads/estimate", &json!(r)).await;
|
||||||
|
s.borrow_mut().busy = false;
|
||||||
|
match result {
|
||||||
|
Ok(v) => {
|
||||||
|
text(
|
||||||
|
"map-estimate-message",
|
||||||
|
&format!(
|
||||||
|
"共 {} 张瓦片,估计约 {:.1} MiB(实际大小可能不同)。",
|
||||||
|
v["tiles"],
|
||||||
|
v["estimatedBytes"].as_u64().unwrap_or(0) as f64 / 1048576.0
|
||||||
|
),
|
||||||
|
);
|
||||||
|
message(
|
||||||
|
"map-step-message",
|
||||||
|
"核算完成,点击开始下载才会创建任务。",
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
s.borrow_mut().estimate = Some(r);
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
text("map-estimate-message", "核算失败,可点击重新核算重试。");
|
||||||
|
message("map-step-message", &e, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
update_buttons(&s);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
fn update_buttons(s: &Shared) {
|
||||||
|
render_navigation(s);
|
||||||
|
let state = s.borrow();
|
||||||
|
disabled(
|
||||||
|
"map-region-persist",
|
||||||
|
state.prefs.is_none() || state.busy || !state.regions_dirty,
|
||||||
|
);
|
||||||
|
disabled(
|
||||||
|
"map-step-next",
|
||||||
|
state.busy || state.running || state.prefs.is_none(),
|
||||||
|
);
|
||||||
|
disabled("map-step-back", state.busy || state.running);
|
||||||
disabled("map-save", state.prefs.is_none() || state.busy);
|
disabled("map-save", state.prefs.is_none() || state.busy);
|
||||||
disabled("map-estimate", state.running || state.busy);
|
disabled("map-estimate", state.running || state.busy);
|
||||||
disabled(
|
disabled(
|
||||||
@@ -151,13 +322,19 @@ fn update_buttons(s: &Shared) {
|
|||||||
"reload",
|
"reload",
|
||||||
"region-save",
|
"region-save",
|
||||||
"region-delete",
|
"region-delete",
|
||||||
|
"step-region",
|
||||||
|
"step-layers",
|
||||||
|
"step-review",
|
||||||
"point",
|
"point",
|
||||||
"current",
|
"current",
|
||||||
"box",
|
"box",
|
||||||
] {
|
] {
|
||||||
let lock = state.busy
|
let lock = state.busy
|
||||||
|| (state.prefs.is_none() && action != "reload")
|
|| (state.prefs.is_none() && action != "reload")
|
||||||
|| (action == "box" && state.running);
|
|| (matches!(
|
||||||
|
action,
|
||||||
|
"box" | "region-save" | "region-delete" | "step-region" | "step-layers"
|
||||||
|
) && state.running);
|
||||||
if let Ok(buttons) = document().query_selector_all(&format!("[data-map-action={action}]")) {
|
if let Ok(buttons) = document().query_selector_all(&format!("[data-map-action={action}]")) {
|
||||||
for i in 0..buttons.length() {
|
for i in 0..buttons.length() {
|
||||||
if let Some(button) = buttons.item(i).and_then(|e| e.dyn_into::<Element>().ok()) {
|
if let Some(button) = buttons.item(i).and_then(|e| e.dyn_into::<Element>().ok()) {
|
||||||
@@ -237,6 +414,7 @@ fn request() -> Result<DownloadRequest, String> {
|
|||||||
Ok(r)
|
Ok(r)
|
||||||
}
|
}
|
||||||
fn invalidate(s: &Shared) {
|
fn invalidate(s: &Shared) {
|
||||||
|
summary();
|
||||||
s.borrow_mut().estimate = None;
|
s.borrow_mut().estimate = None;
|
||||||
text(
|
text(
|
||||||
"map-estimate-message",
|
"map-estimate-message",
|
||||||
@@ -284,6 +462,7 @@ async fn load(s: Shared) {
|
|||||||
Ok(p) => {
|
Ok(p) => {
|
||||||
s.borrow_mut().prefs = Some(p.clone());
|
s.borrow_mut().prefs = Some(p.clone());
|
||||||
s.borrow_mut().dirty = false;
|
s.borrow_mut().dirty = false;
|
||||||
|
s.borrow_mut().regions_dirty = false;
|
||||||
paint(&s);
|
paint(&s);
|
||||||
message(
|
message(
|
||||||
"map-save-message",
|
"map-save-message",
|
||||||
@@ -298,20 +477,23 @@ async fn load(s: Shared) {
|
|||||||
}
|
}
|
||||||
update_buttons(&s);
|
update_buttons(&s);
|
||||||
}
|
}
|
||||||
async fn save(s: Shared) {
|
async fn save(s: Shared, regions_only: bool) {
|
||||||
let Some(mut p) = s.borrow().prefs.clone() else {
|
let Some(mut p) = s.borrow().prefs.clone() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
let message_id = if regions_only {
|
||||||
|
"map-region-message"
|
||||||
|
} else {
|
||||||
|
"map-save-message"
|
||||||
|
};
|
||||||
|
if !regions_only {
|
||||||
p.basemap = value("map-basemap");
|
p.basemap = value("map-basemap");
|
||||||
p.longitude = number("map-longitude");
|
p.longitude = number("map-longitude");
|
||||||
p.latitude = number("map-latitude");
|
p.latitude = number("map-latitude");
|
||||||
p.zoom = number("map-zoom");
|
p.zoom = number("map-zoom");
|
||||||
|
}
|
||||||
if !p.valid() {
|
if !p.valid() {
|
||||||
message(
|
message(message_id, "请输入有效经纬度和 0–18 的缩放级别。", true);
|
||||||
"map-save-message",
|
|
||||||
"请输入有效经纬度和 0–18 的缩放级别。",
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
s.borrow_mut().busy = true;
|
s.borrow_mut().busy = true;
|
||||||
@@ -331,18 +513,25 @@ async fn save(s: Shared) {
|
|||||||
Ok(v) => match serde_json::from_value::<Preferences>(v) {
|
Ok(v) => match serde_json::from_value::<Preferences>(v) {
|
||||||
Ok(p) => {
|
Ok(p) => {
|
||||||
s.borrow_mut().prefs = Some(p.clone());
|
s.borrow_mut().prefs = Some(p.clone());
|
||||||
|
s.borrow_mut().regions_dirty = false;
|
||||||
|
if !regions_only {
|
||||||
s.borrow_mut().dirty = false;
|
s.borrow_mut().dirty = false;
|
||||||
paint(&s);
|
paint(&s);
|
||||||
map("configure", &json!(p));
|
map("configure", &json!(p));
|
||||||
|
}
|
||||||
message(
|
message(
|
||||||
"map-save-message",
|
message_id,
|
||||||
"已保存。实时地图下次打开将使用此起始点与底图。",
|
if regions_only {
|
||||||
|
"区域更改已保存到本机。地图定位草稿保持未保存。"
|
||||||
|
} else {
|
||||||
|
"已保存。实时地图下次打开将使用此起始点与底图。"
|
||||||
|
},
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Err(_) => message("map-save-message", "保存响应无效,请重新加载核实。", true),
|
Err(_) => message(message_id, "保存响应无效,请重新加载核实。", true),
|
||||||
},
|
},
|
||||||
Err(e) => message("map-save-message", &e, true),
|
Err(e) => message(message_id, &e, true),
|
||||||
}
|
}
|
||||||
update_buttons(&s);
|
update_buttons(&s);
|
||||||
}
|
}
|
||||||
@@ -388,6 +577,9 @@ async fn poll(s: Shared) {
|
|||||||
let j = &v["job"];
|
let j = &v["job"];
|
||||||
let was_running = s.borrow().running;
|
let was_running = s.borrow().running;
|
||||||
s.borrow_mut().running = j["state"] == "running";
|
s.borrow_mut().running = j["state"] == "running";
|
||||||
|
if s.borrow().running && s.borrow().tab == Tab::Downloads {
|
||||||
|
s.borrow_mut().step = Step::Review;
|
||||||
|
}
|
||||||
if was_running && j["state"] == "completed" {
|
if was_running && j["state"] == "completed" {
|
||||||
map("refresh", &Value::Null);
|
map("refresh", &Value::Null);
|
||||||
}
|
}
|
||||||
@@ -419,7 +611,7 @@ async fn poll(s: Shared) {
|
|||||||
pub fn open() {
|
pub fn open() {
|
||||||
STATE.with(|slot| {
|
STATE.with(|slot| {
|
||||||
if let Some(s) = slot.borrow().clone() {
|
if let Some(s) = slot.borrow().clone() {
|
||||||
drawer(true);
|
render_navigation(&s);
|
||||||
if s.borrow().prefs.is_none() {
|
if s.borrow().prefs.is_none() {
|
||||||
if !s.borrow().busy {
|
if !s.borrow().busy {
|
||||||
s.borrow_mut().busy = true;
|
s.borrow_mut().busy = true;
|
||||||
@@ -457,6 +649,7 @@ pub fn open() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
pub fn close() {
|
pub fn close() {
|
||||||
|
map("tool", &json!(""));
|
||||||
map("close", &Value::Null);
|
map("close", &Value::Null);
|
||||||
}
|
}
|
||||||
fn listen(name: &str, f: impl FnMut(Event) + 'static) {
|
fn listen(name: &str, f: impl FnMut(Event) + 'static) {
|
||||||
@@ -466,6 +659,9 @@ fn listen(name: &str, f: impl FnMut(Event) + 'static) {
|
|||||||
}
|
}
|
||||||
pub fn init() {
|
pub fn init() {
|
||||||
let s = Rc::new(RefCell::new(State {
|
let s = Rc::new(RefCell::new(State {
|
||||||
|
tab: Tab::Location,
|
||||||
|
step: Step::Region,
|
||||||
|
regions_dirty: false,
|
||||||
prefs: None,
|
prefs: None,
|
||||||
estimate: None,
|
estimate: None,
|
||||||
available: false,
|
available: false,
|
||||||
@@ -491,16 +687,35 @@ pub fn init() {
|
|||||||
}
|
}
|
||||||
let s = state.clone();
|
let s = state.clone();
|
||||||
match action.as_str() {
|
match action.as_str() {
|
||||||
"drawer" => {
|
"location" => select_tab(&s, Tab::Location),
|
||||||
drawer(el("map-settings-drawer").is_some_and(|e| e.has_attribute("hidden")))
|
"downloads" => select_tab(&s, Tab::Downloads),
|
||||||
}
|
"step-region" => go_step(&s, Step::Region),
|
||||||
"downloads" => {
|
"step-layers" => go_step(&s, Step::Layers),
|
||||||
drawer(true);
|
"step-review" => go_step(&s, Step::Review),
|
||||||
if let Some(e) = el("map-download-section") {
|
"next" => {
|
||||||
e.scroll_into_view();
|
let step = s.borrow().step;
|
||||||
|
go_step(
|
||||||
|
&s,
|
||||||
|
if step == Step::Region {
|
||||||
|
Step::Layers
|
||||||
|
} else {
|
||||||
|
Step::Review
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
"previous" => {
|
||||||
|
let step = s.borrow().step;
|
||||||
|
go_step(
|
||||||
|
&s,
|
||||||
|
if step == Step::Review {
|
||||||
|
Step::Layers
|
||||||
|
} else {
|
||||||
|
Step::Region
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
"point" => {
|
"point" => {
|
||||||
|
select_tab(&s, Tab::Location);
|
||||||
map("tool", &json!("point"));
|
map("tool", &json!("point"));
|
||||||
text(
|
text(
|
||||||
"map-tool-hint",
|
"map-tool-hint",
|
||||||
@@ -508,6 +723,8 @@ pub fn init() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
"box" => {
|
"box" => {
|
||||||
|
select_tab(&s, Tab::Downloads);
|
||||||
|
go_step(&s, Step::Region);
|
||||||
map("tool", &json!("box"));
|
map("tool", &json!("box"));
|
||||||
text(
|
text(
|
||||||
"map-tool-hint",
|
"map-tool-hint",
|
||||||
@@ -520,9 +737,9 @@ pub fn init() {
|
|||||||
spawn_local(load(s));
|
spawn_local(load(s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"save" => {
|
"save" | "save-regions" => {
|
||||||
if !s.borrow().busy {
|
if !s.borrow().busy {
|
||||||
spawn_local(save(s));
|
spawn_local(save(s, action == "save-regions"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"region-save" => {
|
"region-save" => {
|
||||||
@@ -530,7 +747,7 @@ pub fn init() {
|
|||||||
let b = bounds();
|
let b = bounds();
|
||||||
if name.is_empty() || name.chars().count() > 40 || !b.valid() {
|
if name.is_empty() || name.chars().count() > 40 || !b.valid() {
|
||||||
message(
|
message(
|
||||||
"map-save-message",
|
"map-region-message",
|
||||||
"请填写有效区域范围和 1–40 字名称。",
|
"请填写有效区域范围和 1–40 字名称。",
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
@@ -543,14 +760,15 @@ pub fn init() {
|
|||||||
} else if p.regions.len() < 30 {
|
} else if p.regions.len() < 30 {
|
||||||
p.regions.push(Region { name, bounds: b })
|
p.regions.push(Region { name, bounds: b })
|
||||||
} else {
|
} else {
|
||||||
message("map-save-message", "最多保存 30 个常用区域。", true);
|
message("map-region-message", "最多保存 30 个常用区域。", true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
paint_regions(p);
|
paint_regions(p);
|
||||||
state.dirty = true;
|
state.dirty = true;
|
||||||
|
state.regions_dirty = true;
|
||||||
message(
|
message(
|
||||||
"map-save-message",
|
"map-region-message",
|
||||||
"常用区域已加入草稿,请点击保存地图设置。",
|
"常用区域已加入草稿,请点击保存区域更改。",
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -564,44 +782,16 @@ pub fn init() {
|
|||||||
p.regions.remove(index);
|
p.regions.remove(index);
|
||||||
paint_regions(p);
|
paint_regions(p);
|
||||||
state.dirty = true;
|
state.dirty = true;
|
||||||
|
state.regions_dirty = true;
|
||||||
message(
|
message(
|
||||||
"map-save-message",
|
"map-region-message",
|
||||||
"区域已从草稿移除,请点击保存地图设置。",
|
"区域已从草稿移除,请点击保存区域更改。",
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"estimate" => {
|
"estimate" => estimate(s),
|
||||||
let r = match request() {
|
|
||||||
Ok(r) => r,
|
|
||||||
Err(e) => {
|
|
||||||
message("map-download-message", &e, true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
s.borrow_mut().busy = true;
|
|
||||||
update_buttons(&s);
|
|
||||||
spawn_local(async move {
|
|
||||||
let result = post("/api/maps/downloads/estimate", &json!(r)).await;
|
|
||||||
s.borrow_mut().busy = false;
|
|
||||||
match result {
|
|
||||||
Ok(v) => {
|
|
||||||
text(
|
|
||||||
"map-estimate-message",
|
|
||||||
&format!(
|
|
||||||
"共 {} 张瓦片,估计约 {:.1} MiB(实际大小可能不同)。点击开始下载。",
|
|
||||||
v["tiles"],
|
|
||||||
v["estimatedBytes"].as_u64().unwrap_or(0) as f64 / 1048576.0
|
|
||||||
),
|
|
||||||
);
|
|
||||||
s.borrow_mut().estimate = Some(r);
|
|
||||||
}
|
|
||||||
Err(e) => message("map-download-message", &e, true),
|
|
||||||
}
|
|
||||||
update_buttons(&s);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
"start" => {
|
"start" => {
|
||||||
let Some(r) = s.borrow().estimate.clone() else {
|
let Some(r) = s.borrow().estimate.clone() else {
|
||||||
return;
|
return;
|
||||||
@@ -637,6 +827,9 @@ pub fn init() {
|
|||||||
}),
|
}),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
if let Some(s) = STATE.with(|slot| slot.borrow().clone()) {
|
||||||
|
update_buttons(&s);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
let state = s.clone();
|
let state = s.clone();
|
||||||
listen("input", move |e| {
|
listen("input", move |e| {
|
||||||
@@ -703,6 +896,39 @@ pub fn init() {
|
|||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
let state = s.clone();
|
||||||
|
listen("keydown", move |e| {
|
||||||
|
let Some(key) = e.dyn_ref::<web_sys::KeyboardEvent>() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let id = e
|
||||||
|
.target()
|
||||||
|
.and_then(|t| t.dyn_into::<Element>().ok())
|
||||||
|
.map(|e| e.id())
|
||||||
|
.unwrap_or_default();
|
||||||
|
if !matches!(id.as_str(), "map-tab-location" | "map-tab-downloads") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let tab = match key.key().as_str() {
|
||||||
|
"ArrowLeft" | "ArrowRight" => {
|
||||||
|
if state.borrow().tab == Tab::Location {
|
||||||
|
Tab::Downloads
|
||||||
|
} else {
|
||||||
|
Tab::Location
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"Home" => Tab::Location,
|
||||||
|
"End" => Tab::Downloads,
|
||||||
|
_ => return,
|
||||||
|
};
|
||||||
|
e.prevent_default();
|
||||||
|
select_tab(&state, tab);
|
||||||
|
focus(if tab == Tab::Location {
|
||||||
|
"map-tab-location"
|
||||||
|
} else {
|
||||||
|
"map-tab-downloads"
|
||||||
|
});
|
||||||
|
});
|
||||||
for event in ["rid-map-point", "rid-map-bounds", "rid-map-error"] {
|
for event in ["rid-map-point", "rid-map-bounds", "rid-map-error"] {
|
||||||
let state = s.clone();
|
let state = s.clone();
|
||||||
let name = event.to_owned();
|
let name = event.to_owned();
|
||||||
@@ -720,6 +946,7 @@ pub fn init() {
|
|||||||
.unwrap_or(Value::Null);
|
.unwrap_or(Value::Null);
|
||||||
match name.as_str() {
|
match name.as_str() {
|
||||||
"rid-map-point" => {
|
"rid-map-point" => {
|
||||||
|
select_tab(&state, Tab::Location);
|
||||||
for (id, key) in [
|
for (id, key) in [
|
||||||
("map-longitude", "longitude"),
|
("map-longitude", "longitude"),
|
||||||
("map-latitude", "latitude"),
|
("map-latitude", "latitude"),
|
||||||
@@ -737,7 +964,8 @@ pub fn init() {
|
|||||||
&& b.valid()
|
&& b.valid()
|
||||||
{
|
{
|
||||||
set_bounds(&b);
|
set_bounds(&b);
|
||||||
drawer(true);
|
select_tab(&state, Tab::Downloads);
|
||||||
|
go_step(&state, Step::Region);
|
||||||
invalidate(&state);
|
invalidate(&state);
|
||||||
text(
|
text(
|
||||||
"map-tool-hint",
|
"map-tool-hint",
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ impl Layout {
|
|||||||
detail: RwSignal::new(boolean("detail", true)),
|
detail: RwSignal::new(boolean("detail", true)),
|
||||||
receiver: RwSignal::new(receiver),
|
receiver: RwSignal::new(receiver),
|
||||||
mounted: RwSignal::new(receiver),
|
mounted: RwSignal::new(receiver),
|
||||||
dock: RwSignal::new(boolean("dock", true)),
|
dock: RwSignal::new(boolean("dock", false)),
|
||||||
compact: RwSignal::new(false),
|
compact: RwSignal::new(false),
|
||||||
mobile: RwSignal::new(0),
|
mobile: RwSignal::new(0),
|
||||||
height: RwSignal::new(170.0),
|
height: RwSignal::new(170.0),
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//! Map-overlay workspace: observed telemetry and actual local registration records only.
|
//! Map-overlay workspace: observed telemetry and actual local registration records only.
|
||||||
use super::target_lists::{Badge, Filter, Lists, Manager};
|
use super::target_lists::{Badge, Filter, Lists};
|
||||||
use gloo_timers::future::TimeoutFuture;
|
use gloo_timers::future::TimeoutFuture;
|
||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
use rid_shared::target_lists::ListKind;
|
use rid_shared::target_lists::ListKind;
|
||||||
@@ -137,9 +137,8 @@ fn map_label(value: &Value, kind: &str) -> String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Realtime() -> impl IntoView {
|
pub fn Realtime(lists: Lists) -> impl IntoView {
|
||||||
let ids = RwSignal::new(Vec::<String>::new());
|
let ids = RwSignal::new(Vec::<String>::new());
|
||||||
let lists = Lists::new();
|
|
||||||
let classification = Memo::new(move |_| {
|
let classification = Memo::new(move |_| {
|
||||||
lists
|
lists
|
||||||
.snapshot
|
.snapshot
|
||||||
@@ -177,7 +176,6 @@ pub fn Realtime() -> impl IntoView {
|
|||||||
.min(filtered.get().len().div_ceil(100).max(1) - 1)
|
.min(filtered.get().len().div_ceil(100).max(1) - 1)
|
||||||
});
|
});
|
||||||
let choose = move |id: String| {
|
let choose = move |id: String| {
|
||||||
lists.open.set(false);
|
|
||||||
layout.select();
|
layout.select();
|
||||||
if selected.get_untracked() != id {
|
if selected.get_untracked() != id {
|
||||||
selected.set(id.clone());
|
selected.set(id.clone());
|
||||||
@@ -265,13 +263,6 @@ pub fn Realtime() -> impl IntoView {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
let stopped = Rc::new(Cell::new(false));
|
let stopped = Rc::new(Cell::new(false));
|
||||||
let list_stop = stopped.clone();
|
|
||||||
spawn_local(async move {
|
|
||||||
while !list_stop.get() {
|
|
||||||
lists.refresh().await;
|
|
||||||
gloo_timers::future::TimeoutFuture::new(5000).await;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
let alert_stop = stopped.clone();
|
let alert_stop = stopped.clone();
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
let mut cursor = 0u64;
|
let mut cursor = 0u64;
|
||||||
@@ -662,7 +653,6 @@ pub fn Realtime() -> impl IntoView {
|
|||||||
<p class="live-data-label">"未收到的字段显示 —。未匹配本地记录不代表违法或未官方备案。"</p>
|
<p class="live-data-label">"未收到的字段显示 —。未匹配本地记录不代表违法或未官方备案。"</p>
|
||||||
</div><div class="mc-btn-row"><button class="primary" disabled=move||position.get().is_none() on:click=move |_|layout.focus()>"聚焦此目标"</button><a class="mc-btn mc-btn-secondary" aria-disabled=move||selected.get().is_empty().to_string() tabindex=move||if selected.get().is_empty(){-1}else{0} href=move||if selected.get().is_empty(){None}else{Some(format!("/?app=register&q={}",js_sys::encode_uri_component(&selected.get())))}>"查看本地登记"</a></div>
|
</div><div class="mc-btn-row"><button class="primary" disabled=move||position.get().is_none() on:click=move |_|layout.focus()>"聚焦此目标"</button><a class="mc-btn mc-btn-secondary" aria-disabled=move||selected.get().is_empty().to_string() tabindex=move||if selected.get().is_empty(){-1}else{0} href=move||if selected.get().is_empty(){None}else{Some(format!("/?app=register&q={}",js_sys::encode_uri_component(&selected.get())))}>"查看本地登记"</a></div>
|
||||||
</aside>
|
</aside>
|
||||||
<Manager lists=lists/>
|
|
||||||
<section id="rt-dock" class="mc-hud-dock" tabindex="-1" aria-label="事件与接收器" hidden=move||!layout.dock_visible()>
|
<section id="rt-dock" class="mc-hud-dock" tabindex="-1" aria-label="事件与接收器" hidden=move||!layout.dock_visible()>
|
||||||
<div class="live-resizer" role="separator" tabindex="0" aria-label="调整底栏高度" aria-orientation="horizontal" aria-valuemin="100" aria-valuemax=move||layout.maximum.get().round().to_string() aria-valuenow=move||layout.height.get().round().to_string()
|
<div class="live-resizer" role="separator" tabindex="0" aria-label="调整底栏高度" aria-orientation="horizontal" aria-valuemin="100" aria-valuemax=move||layout.maximum.get().round().to_string() aria-valuenow=move||layout.height.get().round().to_string()
|
||||||
on:pointerdown=move |e|{if e.button()!=0{return}
|
on:pointerdown=move |e|{if e.button()!=0{return}
|
||||||
|
|||||||
@@ -585,6 +585,7 @@ pub fn init() {
|
|||||||
&& let Ok(query) = js_sys::decode_uri_component(encoded)
|
&& let Ok(query) = js_sys::decode_uri_component(encoded)
|
||||||
{
|
{
|
||||||
input("history-query").set_value(&String::from(query));
|
input("history-query").set_value(&String::from(query));
|
||||||
|
crate::workspace::navigate("archives");
|
||||||
}
|
}
|
||||||
let state = Rc::new(RefCell::new(State {
|
let state = Rc::new(RefCell::new(State {
|
||||||
page: 1,
|
page: 1,
|
||||||
@@ -822,6 +823,7 @@ pub fn init() {
|
|||||||
hidden("empty-result", false);
|
hidden("empty-result", false);
|
||||||
text("form-message", "");
|
text("form-message", "");
|
||||||
render_rows(&state);
|
render_rows(&state);
|
||||||
|
crate::workspace::navigate("register");
|
||||||
let _ = input("serial-no").focus();
|
let _ = input("serial-no").focus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -858,10 +860,12 @@ pub fn init() {
|
|||||||
close_menu(&state, true);
|
close_menu(&state, true);
|
||||||
if action == "edit" {
|
if action == "edit" {
|
||||||
state.borrow_mut().edit_return = format!("more-{record_id}");
|
state.borrow_mut().edit_return = format!("more-{record_id}");
|
||||||
|
crate::workspace::navigate("register");
|
||||||
edit(&state, row);
|
edit(&state, row);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if action == "qr" || action == "view" {
|
if action == "qr" || action == "view" {
|
||||||
|
crate::workspace::navigate("register");
|
||||||
draw(&state, row);
|
draw(&state, row);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -976,6 +980,7 @@ pub fn init() {
|
|||||||
}
|
}
|
||||||
let target = state.borrow().edit_return.clone();
|
let target = state.borrow().edit_return.clone();
|
||||||
state.borrow_mut().editing = None;
|
state.borrow_mut().editing = None;
|
||||||
|
crate::workspace::navigate("archives");
|
||||||
focus(&target);
|
focus(&target);
|
||||||
});
|
});
|
||||||
let _ = el("edit-dialog")
|
let _ = el("edit-dialog")
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ use rid_shared::target_lists::{
|
|||||||
Entry, ListKind, MAX_NOTE_CHARS, Mutation, Snapshot, valid_target_id,
|
Entry, ListKind, MAX_NOTE_CHARS, Mutation, Snapshot, valid_target_id,
|
||||||
};
|
};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use wasm_bindgen::JsCast;
|
|
||||||
use wasm_bindgen_futures::spawn_local;
|
use wasm_bindgen_futures::spawn_local;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||||
@@ -64,10 +63,12 @@ pub(super) struct Lists {
|
|||||||
manager_filter: RwSignal<Filter>,
|
manager_filter: RwSignal<Filter>,
|
||||||
manager_page: RwSignal<usize>,
|
manager_page: RwSignal<usize>,
|
||||||
return_focus: RwSignal<String>,
|
return_focus: RwSignal<String>,
|
||||||
|
return_view: RwSignal<String>,
|
||||||
draft_id: RwSignal<String>,
|
draft_id: RwSignal<String>,
|
||||||
draft_note: RwSignal<String>,
|
draft_note: RwSignal<String>,
|
||||||
draft_kind: RwSignal<ListKind>,
|
draft_kind: RwSignal<ListKind>,
|
||||||
editing: RwSignal<bool>,
|
editing: RwSignal<bool>,
|
||||||
|
editor_open: RwSignal<bool>,
|
||||||
pub message: RwSignal<String>,
|
pub message: RwSignal<String>,
|
||||||
pub failed: RwSignal<bool>,
|
pub failed: RwSignal<bool>,
|
||||||
}
|
}
|
||||||
@@ -85,10 +86,12 @@ impl Lists {
|
|||||||
manager_filter: RwSignal::new(Filter::All),
|
manager_filter: RwSignal::new(Filter::All),
|
||||||
manager_page: RwSignal::new(0),
|
manager_page: RwSignal::new(0),
|
||||||
return_focus: RwSignal::new(String::new()),
|
return_focus: RwSignal::new(String::new()),
|
||||||
|
return_view: RwSignal::new("realtime".into()),
|
||||||
draft_id: RwSignal::new(String::new()),
|
draft_id: RwSignal::new(String::new()),
|
||||||
draft_note: RwSignal::new(String::new()),
|
draft_note: RwSignal::new(String::new()),
|
||||||
draft_kind: RwSignal::new(ListKind::Black),
|
draft_kind: RwSignal::new(ListKind::Black),
|
||||||
editing: RwSignal::new(false),
|
editing: RwSignal::new(false),
|
||||||
|
editor_open: RwSignal::new(false),
|
||||||
message: RwSignal::new(String::new()),
|
message: RwSignal::new(String::new()),
|
||||||
failed: RwSignal::new(false),
|
failed: RwSignal::new(false),
|
||||||
}
|
}
|
||||||
@@ -155,24 +158,13 @@ impl Lists {
|
|||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
self.return_focus.set(trigger);
|
self.return_focus.set(trigger);
|
||||||
}
|
}
|
||||||
|
super::workspace::navigate("target-lists");
|
||||||
self.open.set(true);
|
self.open.set(true);
|
||||||
super::realtime_layout::focus("rt-list-manager");
|
super::realtime_layout::focus("rt-list-manager");
|
||||||
}
|
}
|
||||||
fn show_black(self) {
|
|
||||||
self.manager_filter.set(Filter::Black);
|
|
||||||
self.manager_page.set(0);
|
|
||||||
self.query.set(String::new());
|
|
||||||
if !self.editing.get_untracked()
|
|
||||||
&& self.draft_id.get_untracked().is_empty()
|
|
||||||
&& !self.busy.get_untracked()
|
|
||||||
{
|
|
||||||
self.draft_kind.set(ListKind::Black);
|
|
||||||
}
|
|
||||||
self.show();
|
|
||||||
self.return_focus.set("rt-blacklist-menu".into());
|
|
||||||
}
|
|
||||||
pub fn close(self) {
|
pub fn close(self) {
|
||||||
self.open.set(false);
|
self.open.set(false);
|
||||||
|
super::workspace::navigate(&self.return_view.get_untracked());
|
||||||
// Layout compactness is reconciled every 100 ms; choose a visible return
|
// Layout compactness is reconciled every 100 ms; choose a visible return
|
||||||
// target after that reconciliation rather than a button about to hide.
|
// target after that reconciliation rather than a button about to hide.
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
@@ -227,6 +219,7 @@ impl Lists {
|
|||||||
.unwrap_or(ListKind::Black),
|
.unwrap_or(ListKind::Black),
|
||||||
);
|
);
|
||||||
self.editing.set(entry.is_some());
|
self.editing.set(entry.is_some());
|
||||||
|
self.editor_open.set(true);
|
||||||
self.message.set(String::new());
|
self.message.set(String::new());
|
||||||
self.failed.set(false);
|
self.failed.set(false);
|
||||||
self.show();
|
self.show();
|
||||||
@@ -357,41 +350,47 @@ pub(super) fn Badge(lists: Lists, target: String) -> impl IntoView {
|
|||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub(super) fn Manager(lists: Lists) -> impl IntoView {
|
pub(super) fn Manager(lists: Lists) -> impl IntoView {
|
||||||
let escape = window_event_listener(leptos::ev::keydown, move |event| {
|
|
||||||
let realtime = web_sys::window()
|
let realtime = web_sys::window()
|
||||||
.and_then(|window| window.document())
|
.is_some_and(|w| w.location().pathname().unwrap_or_default() == "/realtime");
|
||||||
.and_then(|document| document.body())
|
let last_view = RwSignal::new(if realtime { "realtime" } else { "home" }.to_owned());
|
||||||
.is_some_and(|body| body.get_attribute("data-screen").as_deref() == Some("realtime"));
|
let screen = window_event_listener(
|
||||||
if event.key() == "Escape" && lists.open.get_untracked() && realtime {
|
leptos::ev::Custom::new("rid-workspace-view"),
|
||||||
|
move |_: web_sys::Event| {
|
||||||
|
let view = web_sys::window()
|
||||||
|
.and_then(|w| w.document())
|
||||||
|
.and_then(|d| d.body())
|
||||||
|
.and_then(|b| b.get_attribute("data-screen"))
|
||||||
|
.unwrap_or_default();
|
||||||
|
if view == "target-lists" && last_view.get_untracked() != "target-lists" {
|
||||||
|
lists.return_view.set(last_view.get_untracked());
|
||||||
|
if let Some(active) = web_sys::window()
|
||||||
|
.and_then(|w| w.document())
|
||||||
|
.and_then(|d| d.active_element())
|
||||||
|
&& active.closest("#rt-list-manager").ok().flatten().is_none()
|
||||||
|
{
|
||||||
|
lists.return_focus.set(active.id());
|
||||||
|
}
|
||||||
|
super::realtime_layout::focus("rt-list-manager");
|
||||||
|
}
|
||||||
|
lists.open.set(view == "target-lists");
|
||||||
|
last_view.set(view);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
on_cleanup(move || screen.remove());
|
||||||
|
let escape = window_event_listener(leptos::ev::keydown, move |event| {
|
||||||
|
if event.key() == "Escape" && lists.open.get_untracked() {
|
||||||
event.prevent_default();
|
event.prevent_default();
|
||||||
lists.close();
|
lists.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
on_cleanup(move || escape.remove());
|
on_cleanup(move || escape.remove());
|
||||||
let blacklist_menu = window_event_listener(leptos::ev::click, move |event| {
|
let stopped = std::sync::Arc::new(std::sync::atomic::AtomicBool::new(false));
|
||||||
let document = web_sys::window().and_then(|w| w.document());
|
let stop = stopped.clone();
|
||||||
let realtime = document
|
on_cleanup(move || stopped.store(true, std::sync::atomic::Ordering::Relaxed));
|
||||||
.as_ref()
|
spawn_local(async move {
|
||||||
.and_then(|d| d.body())
|
while !stop.load(std::sync::atomic::Ordering::Relaxed) {
|
||||||
.is_some_and(|b| b.get_attribute("data-screen").as_deref() == Some("realtime"));
|
lists.refresh().await;
|
||||||
if realtime
|
gloo_timers::future::TimeoutFuture::new(5000).await;
|
||||||
&& event
|
|
||||||
.target()
|
|
||||||
.and_then(|e| e.dyn_into::<web_sys::Element>().ok())
|
|
||||||
.and_then(|e| e.closest("#rt-blacklist-menu").ok().flatten())
|
|
||||||
.is_some()
|
|
||||||
{
|
|
||||||
lists.show_black();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
on_cleanup(move || blacklist_menu.remove());
|
|
||||||
Effect::new(move |_| {
|
|
||||||
let expanded = lists.open.get();
|
|
||||||
if let Some(button) = web_sys::window()
|
|
||||||
.and_then(|w| w.document())
|
|
||||||
.and_then(|d| d.get_element_by_id("rt-blacklist-menu"))
|
|
||||||
{
|
|
||||||
let _ = button.set_attribute("aria-expanded", &expanded.to_string());
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let rows = Memo::new(move |_| {
|
let rows = Memo::new(move |_| {
|
||||||
@@ -417,29 +416,37 @@ pub(super) fn Manager(lists: Lists) -> impl IntoView {
|
|||||||
.min(rows.get().len().div_ceil(50).max(1) - 1)
|
.min(rows.get().len().div_ceil(50).max(1) - 1)
|
||||||
});
|
});
|
||||||
view! {
|
view! {
|
||||||
<aside id="rt-list-manager" tabindex="-1" class="rt-list-manager" aria-label=move||if lists.manager_filter.get()==Filter::Black{"黑名单管理"}else{"黑白名单管理"} hidden=move||!lists.open.get()>
|
<section id="rt-list-manager" tabindex="-1" class="rt-list-manager" aria-label="黑白名单管理" hidden=move||!lists.open.get()>
|
||||||
<header class="rt-list-manager-head"><h2>{move||if lists.manager_filter.get()==Filter::Black{"黑名单管理"}else{"黑白名单管理"}}</h2><button type="button" disabled=move||lists.busy.get() on:click=move |_|{lists.draft_id.set(String::new());lists.draft_note.set(String::new());lists.editing.set(false);lists.message.set(String::new());super::realtime_layout::focus("rt-list-entry-id");}>"新增条目"</button><button type="button" aria-label="关闭名单管理" on:click=move |_|lists.close()>"关闭"</button></header>
|
<header class="rt-list-manager-head"><div><h2>"黑白名单管理"</h2><p>"按目标标识精确匹配,区分大小写。名单与设备登记档案独立。"</p></div><button type="button" disabled=move||lists.busy.get() on:click=move |_|{lists.draft_id.set(String::new());lists.draft_note.set(String::new());lists.editing.set(false);lists.editor_open.set(true);lists.message.set(String::new());super::realtime_layout::focus("rt-list-entry-id");}>"新增条目"</button><button type="button" aria-label="返回工作区" on:click=move |_|lists.close()>"返回工作区"</button></header>
|
||||||
<div class="rt-list-manager-body">
|
<div class="rt-list-manager-body">
|
||||||
<p class="rt-list-help">"按目标标识精确匹配,区分大小写。名单独立于备案档案;可提前录入离线目标。"</p>
|
<aside class="rt-list-category-panel" aria-label="名单分类"><h3>"名单分类"</h3><div class="rt-list-tabs" role="group" aria-label="管理名单分类">{[Filter::All,Filter::White,Filter::Black].into_iter().map(move |filter|view!{<button type="button" aria-pressed=move||(lists.manager_filter.get()==filter).to_string() on:click=move |_|{lists.manager_filter.set(filter);lists.manager_page.set(0);}>{filter.label()}" "{move||if lists.ready.get(){lists.snapshot.with(|s|s.entries.iter().filter(|entry|filter.matches(Some(entry.list_kind))).count()).to_string()}else{"—".into()}}</button>}).collect_view()}</div><div class="rt-list-policy"><h3>"标记与告警规则"</h3><p>"白名单标记为可信,围栏免告警。黑名单突出显示并记录告警。所有目标继续接收和显示。"</p><p>"移除后恢复为未分类,保留遥测与登记档案。"</p></div></aside>
|
||||||
<div class="rt-list-tabs" role="group" aria-label="管理名单分类">{[Filter::All,Filter::White,Filter::Black].into_iter().map(move |filter|view!{<button type="button" aria-pressed=move||(lists.manager_filter.get()==filter).to_string() on:click=move |_|{lists.manager_filter.set(filter);lists.manager_page.set(0);}>{filter.label()}" "{move||if lists.ready.get(){lists.snapshot.with(|s|s.entries.iter().filter(|entry|filter.matches(Some(entry.list_kind))).count()).to_string()}else{"—".into()}}</button>}).collect_view()}</div>
|
<section class="rt-list-table-panel" aria-label="名单目录">
|
||||||
<label class="rt-list-search"><span>"搜索名单"</span><input placeholder="搜索目标标识或备注" prop:value=move||lists.query.get() on:input=move|event|{lists.query.set(event_target_value(&event));lists.manager_page.set(0);}/></label>
|
<div class="rt-list-table-toolbar">
|
||||||
|
<label class="rt-list-search"><span class="rt-list-search-label">"搜索名单"</span><input placeholder="搜索目标标识或备注" prop:value=move||lists.query.get() on:input=move|event|{lists.query.set(event_target_value(&event));lists.manager_page.set(0);}/></label></div>
|
||||||
<p class="rt-list-help" hidden=move||lists.ready.get()>"正在读取本机名单…"</p>
|
<p class="rt-list-help" hidden=move||lists.ready.get()>"正在读取本机名单…"</p>
|
||||||
<p class="rt-list-sync-error" role="status" hidden=move||lists.sync_error.get().is_empty()>{move||lists.sync_error.get()}<button type="button" on:click=move |_|spawn_local(lists.refresh())>"重试"</button></p>
|
<p class="rt-list-sync-error" role="status" hidden=move||lists.sync_error.get().is_empty()>{move||lists.sync_error.get()}<button type="button" on:click=move |_|spawn_local(lists.refresh())>"重试"</button></p>
|
||||||
<div class="rt-list-rows"><For each={move||rows.get().into_iter().skip(page.get()*50).take(50).collect::<Vec<_>>()} key=|entry|entry.target_id.clone() children=move |entry|{
|
<div class="rt-list-rows"><table aria-label="黑白名单条目"><thead><tr><th scope="col">"目标标识"</th><th scope="col">"分类"</th><th scope="col">"备注"</th><th scope="col">"操作"</th></tr></thead><tbody><Show when=move||lists.editor_open.get()&&(!lists.editing.get()||!rows.get().iter().skip(page.get()*50).take(50).any(|e|e.target_id==lists.draft_id.get()))><tr class="rt-inline-editor-row"><td colspan="4"><ListEditor lists=lists/></td></tr></Show><For each={move||rows.get().into_iter().skip(page.get()*50).take(50).collect::<Vec<_>>()} key=|entry|entry.target_id.clone() children=move |entry|{
|
||||||
let edit_id=entry.target_id.clone();let remove_id=entry.target_id.clone();let badge_id=entry.target_id.clone();let note_id=entry.target_id.clone();
|
let edit_id=entry.target_id.clone();let remove_id=entry.target_id.clone();let badge_id=entry.target_id.clone();let note_id=entry.target_id.clone();let selected_id=entry.target_id.clone();let editor_id=entry.target_id.clone();
|
||||||
view!{<div class="rt-list-row" data-target-id=entry.target_id.clone()><div class="rt-list-row-main"><strong>{entry.target_id.clone()}</strong><p>{move||lists.snapshot.with(|snapshot|snapshot.entries.iter().find(|entry|entry.target_id==note_id).map(|entry|entry.note.clone()).unwrap_or_default())}</p></div><Badge lists=lists target=badge_id/><button type="button" disabled=move||lists.busy.get() on:click=move |_|lists.edit(edit_id.clone())>"编辑"</button><button type="button" disabled=move||lists.busy.get() on:click=move |_|lists.remove(remove_id.clone())>"移除"</button></div>}
|
view!{<tr class="rt-list-row" class:selected=move||lists.editing.get()&&lists.draft_id.get()==selected_id data-target-id=entry.target_id.clone()><td class="rt-list-row-main"><strong>{entry.target_id.clone()}</strong></td><td><Badge lists=lists target=badge_id/></td><td class="rt-list-row-note"><p>{move||lists.snapshot.with(|snapshot|snapshot.entries.iter().find(|entry|entry.target_id==note_id).map(|entry|entry.note.clone()).unwrap_or_default())}</p></td><td class="rt-list-row-actions"><button type="button" disabled=move||lists.busy.get() on:click=move |_|lists.edit(edit_id.clone())>"编辑"</button><button type="button" disabled=move||lists.busy.get() on:click=move |_|lists.remove(remove_id.clone())>"移除"</button></td></tr><Show when=move||lists.editor_open.get()&&lists.editing.get()&&lists.draft_id.get()==editor_id><tr class="rt-inline-editor-row"><td colspan="4"><ListEditor lists=lists/></td></tr></Show>}
|
||||||
}/></div>
|
}/></tbody></table><p class="rt-list-help" hidden=move||!lists.ready.get()||!rows.get().is_empty()>"暂无匹配条目,可点击新增条目。"</p></div>
|
||||||
<p class="rt-list-help" hidden=move||!lists.ready.get()||!rows.get().is_empty()>"暂无匹配条目,可在下面新增。"</p>
|
<nav class="rt-list-pagination" aria-label="名单分页"><span>{move||format!("共 {} 条",rows.get().len())}</span><button type="button" disabled=move||page.get()==0 on:click=move |_|lists.manager_page.set(page.get().saturating_sub(1))>"上一页"</button><span>{move||format!("{} / {}",page.get()+1,rows.get().len().div_ceil(50).max(1))}</span><button type="button" disabled={move||(page.get()+1)*50>=rows.get().len()} on:click=move |_|lists.manager_page.set(page.get()+1)>"下一页"</button></nav>
|
||||||
<nav class="rt-list-pagination" aria-label="名单分页"><button type="button" disabled=move||page.get()==0 on:click=move |_|lists.manager_page.set(page.get().saturating_sub(1))>"上一页"</button><span>{move||format!("{} / {}",page.get()+1,rows.get().len().div_ceil(50).max(1))}</span><button type="button" disabled={move||(page.get()+1)*50>=rows.get().len()} on:click=move |_|lists.manager_page.set(page.get()+1)>"下一页"</button></nav>
|
</section>
|
||||||
<form id="rt-list-entry-form" on:submit=move |event|{event.prevent_default();lists.save(lists.draft_id.get_untracked().trim().to_owned(),lists.draft_kind.get_untracked(),lists.draft_note.get_untracked());}>
|
|
||||||
<h3>{move||if lists.editing.get(){"编辑名单条目"}else{"新增名单条目"}}</h3>
|
|
||||||
<label for="rt-list-entry-id">"目标标识"</label><input id="rt-list-entry-id" required maxlength="64" pattern="[A-Za-z0-9_-]{1,64}" autocomplete="off" readonly=move||lists.editing.get() disabled=move||lists.busy.get() prop:value=move||lists.draft_id.get() on:input=move|event|lists.draft_id.set(event_target_value(&event))/>
|
|
||||||
<label for="rt-list-entry-kind">"名单类型"</label><select id="rt-list-entry-kind" disabled=move||lists.busy.get() prop:value=move||match lists.draft_kind.get(){ListKind::White=>"white",ListKind::Black=>"black"} on:change=move|event|lists.draft_kind.set(if event_target_value(&event)=="white"{ListKind::White}else{ListKind::Black})><option value="white">"白名单"</option><option value="black">"黑名单"</option></select>
|
|
||||||
<label for="rt-list-entry-note">"备注(选填,最多 200 字)"</label><textarea id="rt-list-entry-note" maxlength="200" disabled=move||lists.busy.get() prop:value=move||lists.draft_note.get() on:input=move|event|lists.draft_note.set(event_target_value(&event))></textarea>
|
|
||||||
<button class="primary" type="submit" disabled=move||!lists.ready.get()||lists.busy.get()>{move||if lists.busy.get(){"正在保存…"}else{"保存名单条目"}}</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
<footer class="rt-list-manager-footer"><p role="status" class:error=move||lists.failed.get()>{move||lists.message.get()}</p><small>"名单保存在本机。移除后恢复未分类,不删除遥测或登记档案。"</small></footer>
|
<footer class="rt-list-manager-footer"><p role="status" class:error=move||lists.failed.get()>{move||lists.message.get()}</p><small>"名单保存在本机;可提前录入离线目标。"</small></footer>
|
||||||
</aside>
|
</section>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[component]
|
||||||
|
fn ListEditor(lists: Lists) -> impl IntoView {
|
||||||
|
view! {
|
||||||
|
<form id="rt-list-entry-form" on:submit=move |event|{event.prevent_default();lists.save(lists.draft_id.get_untracked().trim().to_owned(),lists.draft_kind.get_untracked(),lists.draft_note.get_untracked());}>
|
||||||
|
<div class="rt-inline-editor-heading"><h3>{move||if lists.editing.get(){"编辑名单条目"}else{"新增名单条目"}}</h3><button type="button" disabled=move||lists.busy.get() on:click=move |_|lists.editor_open.set(false)>"收起编辑"</button></div>
|
||||||
|
<label for="rt-list-entry-id">"目标标识"<input id="rt-list-entry-id" required maxlength="64" autocomplete="off" readonly=move||lists.editing.get() disabled=move||lists.busy.get() prop:value=move||lists.draft_id.get() on:input=move|event|lists.draft_id.set(event_target_value(&event))/></label>
|
||||||
|
<label for="rt-list-entry-kind">"名单类型"<select id="rt-list-entry-kind" disabled=move||lists.busy.get() prop:value=move||match lists.draft_kind.get(){ListKind::White=>"white",ListKind::Black=>"black"} on:change=move|event|lists.draft_kind.set(if event_target_value(&event)=="white"{ListKind::White}else{ListKind::Black})><option value="white">"白名单"</option><option value="black">"黑名单"</option></select></label>
|
||||||
|
<label for="rt-list-entry-note" class="rt-inline-note">"备注(最多200字)"<textarea id="rt-list-entry-note" maxlength="200" disabled=move||lists.busy.get() prop:value=move||lists.draft_note.get() on:input=move|event|lists.draft_note.set(event_target_value(&event))></textarea></label>
|
||||||
|
<div class="rt-inline-editor-actions"><button class="primary" type="submit" disabled=move||!lists.ready.get()||lists.busy.get()>{move||if lists.busy.get(){"正在保存…"}else{"保存名单条目"}}</button></div>
|
||||||
|
</form>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -157,6 +157,9 @@ fn apply(state: &Shared) {
|
|||||||
"B1" => "黑曜石柔光",
|
"B1" => "黑曜石柔光",
|
||||||
"B2" => "午夜蓝丝绸",
|
"B2" => "午夜蓝丝绸",
|
||||||
"B3" => "石墨空间玻璃",
|
"B3" => "石墨空间玻璃",
|
||||||
|
"B5" => "晴空流光",
|
||||||
|
"B6" => "晨雾青山",
|
||||||
|
"B7" => "暖沙光影",
|
||||||
_ => "科技网格",
|
_ => "科技网格",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -264,36 +267,86 @@ fn queue_save(state: Shared) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
pub(super) fn navigate(view: &str) {
|
||||||
|
let realtime = web_sys::window()
|
||||||
|
.is_some_and(|w| w.location().pathname().unwrap_or_default() == "/realtime");
|
||||||
|
show(view, realtime);
|
||||||
|
}
|
||||||
fn show(view: &str, realtime: bool) {
|
fn show(view: &str, realtime: bool) {
|
||||||
let previous = document()
|
let previous = document()
|
||||||
.body()
|
.body()
|
||||||
.and_then(|body| body.get_attribute("data-screen"));
|
.and_then(|body| body.get_attribute("data-screen"));
|
||||||
let view = match view {
|
let view = match view {
|
||||||
"register" | "realtime" | "settings" | "maps" | "geofences" => view,
|
"register" | "archives" | "realtime" | "settings" | "display" | "maps" | "geofences"
|
||||||
|
| "target-lists" => view,
|
||||||
_ => "home",
|
_ => "home",
|
||||||
};
|
};
|
||||||
if (view == "realtime" && !realtime) || (view == "register" && realtime) {
|
if (view == "realtime" && !realtime) || (matches!(view, "register" | "archives") && realtime) {
|
||||||
let _ = web_sys::window()
|
let _ = web_sys::window()
|
||||||
.expect("browser")
|
.expect("browser")
|
||||||
.location()
|
.location()
|
||||||
.set_href(if view == "realtime" {
|
.set_href(if view == "realtime" {
|
||||||
"/realtime"
|
"/realtime"
|
||||||
|
} else {
|
||||||
|
if view == "archives" {
|
||||||
|
"/?app=archives"
|
||||||
} else {
|
} else {
|
||||||
"/?app=register"
|
"/?app=register"
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
hidden(
|
hidden(
|
||||||
"workspace-content",
|
"workspace-content",
|
||||||
matches!(view, "home" | "settings" | "maps" | "geofences"),
|
matches!(
|
||||||
|
view,
|
||||||
|
"home" | "settings" | "display" | "maps" | "geofences" | "target-lists"
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
hidden("target-lists-view", view != "target-lists");
|
||||||
hidden("geofence-view", view != "geofences");
|
hidden("geofence-view", view != "geofences");
|
||||||
if view == "geofences" {
|
if view == "geofences" {
|
||||||
crate::geofences::open();
|
crate::geofences::open();
|
||||||
} else {
|
} else {
|
||||||
crate::geofences::close();
|
crate::geofences::close();
|
||||||
}
|
}
|
||||||
hidden("appearance-view", view != "settings");
|
hidden("appearance-view", !matches!(view, "settings" | "display"));
|
||||||
|
hidden("appearance-wallpaper-controls", view != "settings");
|
||||||
|
hidden("appearance-display", view != "display");
|
||||||
|
text(
|
||||||
|
"setting-content-title",
|
||||||
|
if view == "display" {
|
||||||
|
"显示方式"
|
||||||
|
} else {
|
||||||
|
"壁纸与外观"
|
||||||
|
},
|
||||||
|
);
|
||||||
|
let module = match view {
|
||||||
|
"settings" | "display" | "maps" => "settings",
|
||||||
|
"register" | "archives" => "register",
|
||||||
|
"realtime" | "geofences" | "target-lists" => "realtime",
|
||||||
|
_ => "home",
|
||||||
|
};
|
||||||
|
each("[data-module]", |entry| {
|
||||||
|
if entry.get_attribute("data-module").as_deref() == Some(module) {
|
||||||
|
let _ = entry.remove_attribute("hidden");
|
||||||
|
} else {
|
||||||
|
let _ = entry.set_attribute("hidden", "");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
each(".history-panel", |entry| {
|
||||||
|
let _ = entry.set_attribute("hidden", "");
|
||||||
|
if view == "archives" {
|
||||||
|
let _ = entry.remove_attribute("hidden");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
each(".registration-editor, #registration-result", |entry| {
|
||||||
|
if view == "archives" {
|
||||||
|
let _ = entry.set_attribute("hidden", "");
|
||||||
|
} else {
|
||||||
|
let _ = entry.remove_attribute("hidden");
|
||||||
|
}
|
||||||
|
});
|
||||||
hidden("map-settings-view", view != "maps");
|
hidden("map-settings-view", view != "maps");
|
||||||
if view == "maps" {
|
if view == "maps" {
|
||||||
crate::map_settings::open();
|
crate::map_settings::open();
|
||||||
@@ -306,10 +359,11 @@ fn show(view: &str, realtime: bool) {
|
|||||||
}
|
}
|
||||||
text(
|
text(
|
||||||
"workspace-brand",
|
"workspace-brand",
|
||||||
if view == "home" {
|
match module {
|
||||||
"RID 工作空间"
|
"settings" => "设置",
|
||||||
} else {
|
"register" => "设备登记",
|
||||||
"应用"
|
"realtime" => "实时工作台",
|
||||||
|
_ => "RID 工作空间",
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
each(".homescreen", |e| {
|
each(".homescreen", |e| {
|
||||||
@@ -322,7 +376,11 @@ fn show(view: &str, realtime: bool) {
|
|||||||
if let Some(body) = document().body() {
|
if let Some(body) = document().body() {
|
||||||
let _ = body.set_attribute("data-screen", view);
|
let _ = body.set_attribute("data-screen", view);
|
||||||
}
|
}
|
||||||
hidden("rt-blacklist-menu", view != "realtime");
|
if let Some(window) = web_sys::window()
|
||||||
|
&& let Ok(event) = Event::new("rid-workspace-view")
|
||||||
|
{
|
||||||
|
let _ = window.dispatch_event(&event);
|
||||||
|
}
|
||||||
if previous.as_deref() == Some("geofences")
|
if previous.as_deref() == Some("geofences")
|
||||||
&& view == "realtime"
|
&& view == "realtime"
|
||||||
&& let Some(region) = el("workspace-content").and_then(|e| e.dyn_into::<HtmlElement>().ok())
|
&& let Some(region) = el("workspace-content").and_then(|e| e.dyn_into::<HtmlElement>().ok())
|
||||||
@@ -334,34 +392,43 @@ fn show(view: &str, realtime: bool) {
|
|||||||
"reference-title",
|
"reference-title",
|
||||||
match view {
|
match view {
|
||||||
"register" => "设备登记",
|
"register" => "设备登记",
|
||||||
"realtime" => "实时目标工作台",
|
"archives" => "本地档案",
|
||||||
|
"display" => "显示方式",
|
||||||
|
"realtime" => "实时工作台",
|
||||||
"settings" => "壁纸与外观",
|
"settings" => "壁纸与外观",
|
||||||
"maps" => "地图配置",
|
"maps" => "地图配置",
|
||||||
"geofences" => "电子围栏",
|
"geofences" => "电子围栏",
|
||||||
|
"target-lists" => "黑白名单管理",
|
||||||
_ => "应用总览",
|
_ => "应用总览",
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
each("[data-menu]", |e| {
|
each("[data-menu]", |e| {
|
||||||
if e.get_attribute("data-menu").as_deref()
|
if e.get_attribute("data-menu").as_deref() == Some(view) {
|
||||||
== Some(if view == "maps" { "settings" } else { view })
|
|
||||||
{
|
|
||||||
let _ = e.set_attribute("aria-current", "page");
|
let _ = e.set_attribute("aria-current", "page");
|
||||||
} else {
|
} else {
|
||||||
let _ = e.remove_attribute("aria-current");
|
let _ = e.remove_attribute("aria-current");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if view == "home" {
|
if view == "home" {
|
||||||
if let Some(previous) =
|
if let Some(previous) = previous
|
||||||
previous.filter(|p| matches!(p.as_str(), "register" | "realtime" | "settings"))
|
.map(|p| match p.as_str() {
|
||||||
|
"display" | "maps" => "settings".to_owned(),
|
||||||
|
"archives" => "register".to_owned(),
|
||||||
|
"geofences" | "target-lists" => "realtime".to_owned(),
|
||||||
|
_ => p,
|
||||||
|
})
|
||||||
|
.filter(|p| p != "home")
|
||||||
&& let Some(card) =
|
&& let Some(card) =
|
||||||
el(&format!("home-app-{previous}")).and_then(|e| e.dyn_into::<HtmlElement>().ok())
|
el(&format!("home-app-{previous}")).and_then(|e| e.dyn_into::<HtmlElement>().ok())
|
||||||
{
|
{
|
||||||
let _ = card.focus();
|
let _ = card.focus();
|
||||||
}
|
}
|
||||||
} else if previous.as_deref() == Some("home") {
|
} else if previous.as_deref() == Some("home") {
|
||||||
let region = if view == "geofences" {
|
let region = if view == "target-lists" {
|
||||||
|
"target-lists-view"
|
||||||
|
} else if view == "geofences" {
|
||||||
"geofence-view"
|
"geofence-view"
|
||||||
} else if view == "settings" {
|
} else if matches!(view, "settings" | "display") {
|
||||||
"appearance-view"
|
"appearance-view"
|
||||||
} else {
|
} else {
|
||||||
"workspace-content"
|
"workspace-content"
|
||||||
@@ -489,10 +556,14 @@ pub fn init(realtime: bool) {
|
|||||||
.and_then(|w| w.location().search().ok())
|
.and_then(|w| w.location().search().ok())
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
show(
|
show(
|
||||||
if realtime {
|
if search.contains("app=target-lists") {
|
||||||
|
"target-lists"
|
||||||
|
} else if realtime {
|
||||||
"realtime"
|
"realtime"
|
||||||
} else if search.contains("app=geofences") {
|
} else if search.contains("app=geofences") {
|
||||||
"geofences"
|
"geofences"
|
||||||
|
} else if search.contains("app=archives") {
|
||||||
|
"archives"
|
||||||
} else if search.contains("app=register") {
|
} else if search.contains("app=register") {
|
||||||
"register"
|
"register"
|
||||||
} else {
|
} else {
|
||||||
@@ -525,35 +596,9 @@ pub fn init(realtime: bool) {
|
|||||||
show("home", realtime);
|
show("home", realtime);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if let Some(section) = button.get_attribute("data-setting-section") {
|
|
||||||
if let Some(target) = el(§ion) {
|
|
||||||
target.scroll_into_view();
|
|
||||||
if let Some(element) = target.dyn_ref::<HtmlElement>() {
|
|
||||||
let _ = element.focus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
each("[data-setting-section]", |entry| {
|
|
||||||
let active = entry.get_attribute("data-setting-section").as_deref()
|
|
||||||
== Some(section.as_str());
|
|
||||||
let _ = entry.set_attribute(
|
|
||||||
"class",
|
|
||||||
if active {
|
|
||||||
"setting-link active"
|
|
||||||
} else {
|
|
||||||
"setting-link"
|
|
||||||
},
|
|
||||||
);
|
|
||||||
if active {
|
|
||||||
let _ = entry.set_attribute("aria-current", "location");
|
|
||||||
} else {
|
|
||||||
let _ = entry.remove_attribute("aria-current");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if let Some(view) = button.get_attribute("data-open") {
|
if let Some(view) = button.get_attribute("data-open") {
|
||||||
show(&view, realtime);
|
show(&view, realtime);
|
||||||
if view == "settings" {
|
if matches!(view.as_str(), "settings" | "display") {
|
||||||
let s = clicked.clone();
|
let s = clicked.clone();
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
fetch_preferences(s).await;
|
fetch_preferences(s).await;
|
||||||
|
|||||||
@@ -10,7 +10,9 @@
|
|||||||
|
|
||||||
## 界面与告警
|
## 界面与告警
|
||||||
|
|
||||||
采用已选定的 A 方案:目标详情中快捷标记,右侧按需展开名单管理侧栏。
|
采用新选定的 A 完整页面方案:左侧菜单“黑白名单管理”进入独立工作区,左侧表格、右侧独立编辑区。地图内“名单管理”也进入同一页面;目标详情仍保留快捷标记。该页在登记、设置和围栏等页面均可进入,返回工作区恢复原页面,并保留名单草稿、搜索和分类条件。可用 `/?app=target-lists` 直接进入。
|
||||||
|
|
||||||
|
名单表格每页50条,表头及分页与滚动区分离。窄屏按表格、编辑区顺序排列,表格内部滚动。实时目录顶部控件减少占用,新默认收起底部事件区;已保存的布局偏好继续生效。
|
||||||
|
|
||||||
目标目录和地图使用同一名单筛选;筛选只影响显示,原始接收数量与数据流不变。名单加载失败时显示“名单未知”,已有快照同步失败时明确提示暂用上次名单,不把读取失败解释为空名单。
|
目标目录和地图使用同一名单筛选;筛选只影响显示,原始接收数量与数据流不变。名单加载失败时显示“名单未知”,已有快照同步失败时明确提示暂用上次名单,不把读取失败解释为空名单。
|
||||||
|
|
||||||
@@ -18,7 +20,7 @@
|
|||||||
|
|
||||||
同一目标连续在线且持续属于黑名单时只记一次命中;高频遥测、备注更新、筛选和连接状态变化不会重复刷屏。目标实际过期离线后重新出现,或从其他分类再次进入黑名单时重新记录。
|
同一目标连续在线且持续属于黑名单时只记一次命中;高频遥测、备注更新、筛选和连接状态变化不会重复刷屏。目标实际过期离线后重新出现,或从其他分类再次进入黑名单时重新记录。
|
||||||
|
|
||||||
告警复用当前工作台事件面板及其有界事件缓存。名单持久化,但当前版本不提供跨重启的长期告警历史。
|
告警由服务端统一去重并持久保存,工作台事件面板显示有界的近期事件。持久化、围栏豁免及分页查询规则见[监测接口](../../monitoring/api/monitoring.md)。
|
||||||
|
|
||||||
## 本机存储与接口
|
## 本机存储与接口
|
||||||
|
|
||||||
@@ -42,5 +44,7 @@
|
|||||||
- `cargo clippy -p rid-web-ui --target wasm32-unknown-unknown --locked -- -D warnings`
|
- `cargo clippy -p rid-web-ui --target wasm32-unknown-unknown --locked -- -D warnings`
|
||||||
- `cargo xtask web`,随后构建宿主程序。
|
- `cargo xtask web`,随后构建宿主程序。
|
||||||
- `node scripts/test-target-lists.mjs [待验证程序绝对路径]`
|
- `node scripts/test-target-lists.mjs [待验证程序绝对路径]`
|
||||||
|
- `node scripts/test-target-lists-page.mjs [待验证程序绝对路径]`
|
||||||
|
- `node scripts/test-realtime-menu-status.mjs [待验证程序绝对路径]`
|
||||||
|
|
||||||
浏览器验收使用独立数据库与显式开启的模拟输入,不打开物理接收器。覆盖互斥分类、重启保留、在线与离线加入、跨浏览器同步、冲突及失败保护、告警去重、地图筛选、窄屏、缩放和键盘焦点。
|
浏览器验收使用独立数据库与显式开启的模拟输入,不打开物理接收器。覆盖互斥分类、重启保留、在线与离线加入、跨浏览器同步、冲突及失败保护、告警去重、地图筛选、窄屏、缩放和键盘焦点。
|
||||||
|
|||||||
@@ -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));
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ async function fixture(run){
|
|||||||
addControl(){}on(name,f){(this.handlers[name]??=[]).push(f)}getCanvasContainer(){return this.canvas}getCanvas(){return this.canvas}getContainer(){return this.container}
|
addControl(){}on(name,f){(this.handlers[name]??=[]).push(f)}getCanvasContainer(){return this.canvas}getCanvas(){return this.canvas}getContainer(){return this.container}
|
||||||
getSource(k){if(!this.loadedStyle)return;return {setTiles:tiles=>this.sources[k].tiles=tiles}}
|
getSource(k){if(!this.loadedStyle)return;return {setTiles:tiles=>this.sources[k].tiles=tiles}}
|
||||||
load(){this.loadedStyle=true;for(const f of this.handlers.load??[])f()}
|
load(){this.loadedStyle=true;for(const f of this.handlers.load??[])f()}
|
||||||
|
fitBounds(bounds,options){this.fit={bounds,options}}
|
||||||
dragPan={disable(){},enable(){}};unproject([x,y]){return {lng:x/100,lat:10-y/100}}remove(){}resize(){}
|
dragPan={disable(){},enable(){}};unproject([x,y]){return {lng:x/100,lat:10-y/100}}remove(){}resize(){}
|
||||||
}
|
}
|
||||||
class Marker{setLngLat(){return this}addTo(){return this}}
|
class Marker{setLngLat(){return this}addTo(){return this}}
|
||||||
@@ -39,3 +40,9 @@ test('panning does not leave an obsolete screen rectangle over another area',()=
|
|||||||
api.tool('box');map().canvas.handlers.pointerdown({button:0,clientX:20,clientY:30,pointerId:1,preventDefault(){}});map().canvas.handlers.pointermove({clientX:160,clientY:170});map().canvas.handlers.pointerup();
|
api.tool('box');map().canvas.handlers.pointerdown({button:0,clientX:20,clientY:30,pointerId:1,preventDefault(){}});map().canvas.handlers.pointermove({clientX:160,clientY:170});map().canvas.handlers.pointerup();
|
||||||
for(const f of map().handlers.movestart??[])f();assert.equal(root.selection.hidden,true);
|
for(const f of map().handlers.movestart??[])f();assert.equal(root.selection.hidden,true);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
test('region framing uses the actual map viewport without obsolete drawer padding',()=>fixture(({api,map})=>{
|
||||||
|
const bounds={west:118,south:32,east:119,north:33};
|
||||||
|
api.bounds(bounds);assert.equal(map().fit.options.padding.left,60);assert.equal(map().fit.options.padding.right,60);
|
||||||
|
map().container.clientWidth=200;api.bounds(bounds);assert.equal(map().fit.options.padding.left,40);assert.equal(map().fit.options.padding.right,40);
|
||||||
|
}));
|
||||||
|
|||||||
@@ -34,12 +34,12 @@ try{
|
|||||||
for(const name of ['map-settings.css','map-settings-adapter.js','map-loader.js','map-adapter.js'])assert.equal(await(await fetch(base+'/'+name)).text(),await readFile(path.resolve('crates/web-ui/public',name),'utf8'),'stale embedded asset: '+name);
|
for(const name of ['map-settings.css','map-settings-adapter.js','map-loader.js','map-adapter.js'])assert.equal(await(await fetch(base+'/'+name)).text(),await readFile(path.resolve('crates/web-ui/public',name),'utf8'),'stale embedded asset: '+name);
|
||||||
page.on('pageerror',e=>errors.push(e.message));page.on('console',m=>{if(/Content Security Policy|Refused to/i.test(m.text()))csp.push(m.text());});
|
page.on('pageerror',e=>errors.push(e.message));page.on('console',m=>{if(/Content Security Policy|Refused to/i.test(m.text()))csp.push(m.text());});
|
||||||
const retryPage=await browser.newPage();let initialAttempts=0;await retryPage.route('**/api/maps/preferences',route=>++initialAttempts===1?route.fulfill({status:503,contentType:'application/json',body:JSON.stringify({error:'模拟首次读取失败'})}):route.continue());
|
const retryPage=await browser.newPage();let initialAttempts=0;await retryPage.route('**/api/maps/preferences',route=>++initialAttempts===1?route.fulfill({status:503,contentType:'application/json',body:JSON.stringify({error:'模拟首次读取失败'})}):route.continue());
|
||||||
await retryPage.goto(base);await retryPage.locator('#home-app-settings').click();await retryPage.locator('#appearance-view [data-open=maps]').click();await retryPage.waitForFunction(()=>document.querySelector('#map-save-message').textContent.includes('模拟首次读取失败'));assert.equal(await retryPage.locator('[data-map-action=reload]').isEnabled(),true,'initial load failure disabled retry');await retryPage.locator('[data-map-action=reload]').click();await retryPage.waitForFunction(()=>!document.querySelector('#map-save').disabled);assert.equal(initialAttempts,2);await retryPage.close();
|
await retryPage.goto(base);await retryPage.locator('#home-app-settings').click();await retryPage.locator('.reference-rail [data-open=maps]').click();await retryPage.waitForFunction(()=>document.querySelector('#map-save-message').textContent.includes('模拟首次读取失败'));assert.equal(await retryPage.locator('[data-map-action=reload]').isEnabled(),true,'initial load failure disabled retry');await retryPage.locator('[data-map-action=reload]').click();await retryPage.waitForFunction(()=>!document.querySelector('#map-save').disabled);assert.equal(initialAttempts,2);await retryPage.close();
|
||||||
// Switching away and back during the first load must not create competing responses.
|
// Switching away and back during the first load must not create competing responses.
|
||||||
let releaseLoad,firstLoad,loadRequests=0;const loadGate=new Promise(r=>releaseLoad=r),loadSeen=new Promise(r=>firstLoad=r);const pendingLoads=[];
|
let releaseLoad,firstLoad,loadRequests=0;const loadGate=new Promise(r=>releaseLoad=r),loadSeen=new Promise(r=>firstLoad=r);const pendingLoads=[];
|
||||||
const holdLoad=route=>{const work=(async()=>{loadRequests++;firstLoad();const response=await route.fetch();await loadGate;await route.fulfill({response});})();pendingLoads.push(work);return work;};
|
const holdLoad=route=>{const work=(async()=>{loadRequests++;firstLoad();const response=await route.fetch();await loadGate;await route.fulfill({response});})();pendingLoads.push(work);return work;};
|
||||||
await page.route('**/api/maps/preferences',holdLoad);
|
await page.route('**/api/maps/preferences',holdLoad);
|
||||||
try{await page.goto(base);await page.locator('#home-app-settings').click();await page.locator('#appearance-view [data-open=maps]').click();await loadSeen;await page.locator('#map-settings-view [data-open=settings]').click();await page.locator('#appearance-view [data-open=maps]').click();await page.waitForTimeout(250);assert.equal(loadRequests,1,'first load duplicated by rapid settings navigation');}
|
try{await page.goto(base);await page.locator('#home-app-settings').click();await page.locator('.reference-rail [data-open=maps]').click();await loadSeen;await page.locator('.reference-rail [data-open=settings]').click();await page.locator('.reference-rail [data-open=maps]').click();await page.waitForTimeout(250);assert.equal(loadRequests,1,'first load duplicated by rapid settings navigation');}
|
||||||
finally{releaseLoad();await Promise.all(pendingLoads);await page.unroute('**/api/maps/preferences',holdLoad);}
|
finally{releaseLoad();await Promise.all(pendingLoads);await page.unroute('**/api/maps/preferences',holdLoad);}
|
||||||
await page.locator('#map-save').waitFor();await page.waitForFunction(()=>!document.querySelector('#map-save').disabled);
|
await page.locator('#map-save').waitFor();await page.waitForFunction(()=>!document.querySelector('#map-save').disabled);
|
||||||
assert.equal(await page.locator('#map-settings-view').getAttribute('tabindex'),'-1');
|
assert.equal(await page.locator('#map-settings-view').getAttribute('tabindex'),'-1');
|
||||||
@@ -51,20 +51,47 @@ try{
|
|||||||
finally{releaseSave();await saveSent;await page.unroute('**/api/maps/preferences',holdSave);}
|
finally{releaseSave();await saveSent;await page.unroute('**/api/maps/preferences',holdSave);}
|
||||||
await page.waitForFunction(()=>!document.querySelector('#map-save').disabled);
|
await page.waitForFunction(()=>!document.querySelector('#map-save').disabled);
|
||||||
await page.waitForFunction(()=>window.ridMapSettings?.metrics()?.camera);
|
await page.waitForFunction(()=>window.ridMapSettings?.metrics()?.camera);
|
||||||
await page.locator('#map-settings-drawer [data-map-action=drawer]').click();assert.equal(await page.locator('#map-settings-drawer').isHidden(),true);await page.locator('.map-settings-head [data-map-action=drawer]').click();
|
await page.locator('#map-tab-location').focus();await page.keyboard.press('ArrowRight');assert.equal(await page.locator('#map-tab-downloads').getAttribute('aria-selected'),'true');
|
||||||
await page.locator('.map-settings-head [data-map-action=point]').click();await page.locator('#settings-map').click({position:{x:220,y:220}});assert.match(await page.locator('#map-save-message').textContent(),/起始点已选定/);
|
await page.locator('#map-step-next').click();assert.match(await page.locator('#map-step-message').textContent(),/有效范围/);assert.equal(await page.locator('#map-step-region').isVisible(),true);
|
||||||
|
await page.keyboard.press('Home');await page.locator('#map-tab-location').click();
|
||||||
|
await page.locator('#map-location-panel [data-map-action=point]').click();await page.locator('#settings-map').click({position:{x:220,y:220}});assert.match(await page.locator('#map-save-message').textContent(),/起始点已选定/);
|
||||||
await page.locator('#map-longitude').fill('181');await page.locator('#map-save').click();assert.match(await page.locator('#map-save-message').textContent(),/有效经纬度/);
|
await page.locator('#map-longitude').fill('181');await page.locator('#map-save').click();assert.match(await page.locator('#map-save-message').textContent(),/有效经纬度/);
|
||||||
await page.locator('#map-longitude').fill('116.4');await page.locator('#map-latitude').fill('39.9');await page.locator('#map-zoom').fill('12');await page.locator('#map-basemap').selectOption('road');await page.locator('#map-save').click();await page.waitForFunction(()=>document.querySelector('#map-save-message').textContent.includes('已保存'));
|
await page.locator('#map-longitude').fill('116.4');await page.locator('#map-latitude').fill('39.9');await page.locator('#map-zoom').fill('12');await page.locator('#map-basemap').selectOption('road');await page.locator('#map-save').click();await page.waitForFunction(()=>document.querySelector('#map-save-message').textContent.includes('已保存'));
|
||||||
assert.equal((await json('/api/maps/preferences')).value.longitude,116.4);
|
assert.equal((await json('/api/maps/preferences')).value.longitude,116.4);
|
||||||
// Unsaved fields survive a settings navigation within this document.
|
// Unsaved fields survive a settings navigation within this document.
|
||||||
await page.locator('#map-longitude').fill('116.41');await page.locator('#map-settings-view [data-open=settings]').click();await page.locator('#appearance-view [data-open=maps]').click();assert.equal(await page.locator('#map-longitude').inputValue(),'116.41');await page.locator('#map-longitude').fill('116.4');
|
await page.locator('#map-longitude').fill('116.41');await page.locator('.reference-rail [data-open=settings]').click();await page.locator('.reference-rail [data-open=maps]').click();assert.equal(await page.locator('#map-longitude').inputValue(),'116.41');await page.locator('#map-longitude').fill('116.4');
|
||||||
await page.locator('#map-basemap').selectOption('imagery');await page.locator('#map-settings-view [data-open=settings]').click();await page.locator('#appearance-view [data-open=maps]').click();await page.waitForFunction(()=>window.ridMapSettings?.metrics()?.camera);assert.equal(await page.locator('#map-basemap').inputValue(),'imagery');assert.equal(await page.evaluate(()=>window.ridMapSettings.metrics().basemap),'imagery','unsaved basemap disagrees with preview after navigation');await page.locator('#map-basemap').selectOption('road');
|
await page.locator('#map-basemap').selectOption('imagery');await page.locator('.reference-rail [data-open=settings]').click();await page.locator('.reference-rail [data-open=maps]').click();await page.waitForFunction(()=>window.ridMapSettings?.metrics()?.camera);assert.equal(await page.locator('#map-basemap').inputValue(),'imagery');assert.equal(await page.evaluate(()=>window.ridMapSettings.metrics().basemap),'imagery','unsaved basemap disagrees with preview after navigation');await page.locator('#map-basemap').selectOption('road');
|
||||||
await page.locator('.map-settings-head [data-map-action=box]').click();const rect=await page.locator('#settings-map').boundingBox();await page.mouse.move(rect.x+100,rect.y+100);await page.mouse.down();await page.mouse.move(rect.x+260,rect.y+230,{steps:8});await page.mouse.up();assert.ok(Number(await page.locator('#map-west').inputValue())<Number(await page.locator('#map-east').inputValue()));
|
await page.locator('#map-tab-downloads').click();await page.locator('[data-map-action=box]').click();const rect=await page.locator('#settings-map').boundingBox();await page.mouse.move(rect.x+100,rect.y+100);await page.mouse.down();await page.mouse.move(rect.x+260,rect.y+230,{steps:8});await page.mouse.up();assert.ok(Number(await page.locator('#map-west').inputValue())<Number(await page.locator('#map-east').inputValue()));
|
||||||
for(const [id,v]of Object.entries({'map-west':'120.15','map-south':'30.28','map-east':'120.16','map-north':'30.29','map-min-zoom':'11','map-max-zoom':'11'}))await page.locator('#'+id).fill(v);
|
await page.locator('.map-advanced summary').click();
|
||||||
await page.locator('#map-region-name').fill('验收常用区域');await page.locator('[data-map-action=region-save]').click();await page.locator('#map-save').click();await page.waitForFunction(()=>document.querySelector('#map-save-message').textContent.includes('已保存'));
|
for(const [id,v]of Object.entries({'map-west':'120.15','map-south':'30.28','map-east':'120.16','map-north':'30.29'}))await page.locator('#'+id).fill(v);
|
||||||
await page.locator('#map-estimate').click();await page.waitForFunction(()=>document.querySelector('#map-estimate-message').textContent.includes('共 4 张'));
|
await page.locator('#map-region-name').fill('验收常用区域');await page.locator('[data-map-action=region-save]').click();
|
||||||
|
await page.locator('#map-tab-location').click();await page.locator('#map-longitude').fill('117.5');await page.locator('#map-tab-downloads').click();
|
||||||
|
await page.locator('#map-region-persist').click();await page.waitForFunction(()=>document.querySelector('#map-region-persist').disabled && document.querySelector('#map-region-message').textContent.includes('已保存'));
|
||||||
|
assert.equal((await json('/api/maps/preferences')).value.longitude,116.4,'region save persisted location draft');
|
||||||
|
await page.locator('#map-region').selectOption('0');await page.locator('[data-map-action=region-delete]').click();assert.equal(await page.locator('#map-region option').count(),1);await page.locator('#map-region-persist').click();await page.waitForFunction(()=>document.querySelector('#map-region-persist').disabled);assert.equal((await json('/api/maps/preferences')).value.regions.length,0);
|
||||||
|
await page.locator('[data-map-action=region-save]').click();await page.locator('#map-region-persist').click();await page.waitForFunction(()=>document.querySelector('#map-region-persist').disabled);assert.equal((await json('/api/maps/preferences')).value.regions[0].name,'验收常用区域');
|
||||||
|
|
||||||
|
await page.locator('#map-tab-location').click();assert.equal(await page.locator('#map-longitude').inputValue(),'117.5');await page.locator('#map-longitude').fill('116.4');await page.locator('#map-tab-downloads').click();
|
||||||
|
await page.locator('#map-step-next').click();await page.locator('#map-min-zoom').fill('19');await page.locator('#map-step-next').click();assert.equal(await page.locator('#map-step-layers').isVisible(),true);assert.match(await page.locator('#map-step-message').textContent(),/0–18/);
|
||||||
|
await page.locator('#map-min-zoom').fill('11');await page.locator('#map-max-zoom').fill('11');
|
||||||
|
let starts=0;page.on('request',r=>{if(r.method()==='POST'&&new URL(r.url()).pathname==='/api/maps/downloads')starts++});
|
||||||
|
let failEstimate=true;await page.route('**/api/maps/downloads/estimate',route=>failEstimate?(failEstimate=false,route.fulfill({status:503,contentType:'application/json',body:JSON.stringify({error:'模拟核算失败'})})):route.continue());
|
||||||
|
await page.locator('#map-step-next').click();await page.waitForFunction(()=>document.querySelector('#map-step-message').textContent.includes('模拟核算失败'));assert.equal(await page.locator('#map-download-start').isDisabled(),true);
|
||||||
|
await page.locator('#map-estimate').click();await page.waitForFunction(()=>document.querySelector('#map-estimate-message').textContent.includes('共 4 张'));assert.equal(starts,0,'estimate started download');
|
||||||
|
await page.locator('#map-step-back').click();await page.locator('#map-max-zoom').fill('12');await page.locator('#map-max-zoom').fill('11');assert.equal(await page.locator('#map-download-start').isDisabled(),true,'changed draft kept old estimate');
|
||||||
|
await page.locator('#map-step-next').click();await page.waitForFunction(()=>!document.querySelector('#map-download-start').disabled);await page.unroute('**/api/maps/downloads/estimate');
|
||||||
await page.locator('#map-download-start').click();const done=await job('completed');assert.equal(done.done,4);assert.equal(done.failed,0);
|
await page.locator('#map-download-start').click();const done=await job('completed');assert.equal(done.done,4);assert.equal(done.failed,0);
|
||||||
for(const layer of ['vec_w','cva_w','img_w','cia_w'])assert.deepEqual(await readFile(path.join(root,`maps/offline/${layer}/11/${x}/${y}.png`)),png);
|
for(const layer of ['vec_w','cva_w','img_w','cia_w'])assert.deepEqual(await readFile(path.join(root,`maps/offline/${layer}/11/${x}/${y}.png`)),png);
|
||||||
|
// UI state for an already-running task, including re-entry and explicit cancellation.
|
||||||
|
let uiRunning=true,cancelClicks=0;
|
||||||
|
await page.route('**/api/maps/downloads',route=>route.request().method()==='GET'?route.fulfill({contentType:'application/json',body:JSON.stringify({available:true,job:{state:uiRunning?'running':'cancelled',message:uiRunning?'测试任务下载中':'测试任务已取消',done:1,total:4}})}):route.continue());
|
||||||
|
await page.route('**/api/maps/downloads/cancel',route=>{cancelClicks++;uiRunning=false;return route.fulfill({contentType:'application/json',body:JSON.stringify({message:'已请求取消'})})});
|
||||||
|
await page.waitForFunction(()=>!document.querySelector('#map-download-cancel').hidden);
|
||||||
|
assert.equal(await page.locator('[data-map-action=step-region]').isDisabled(),true);assert.equal(await page.locator('#map-west').isDisabled(),true);
|
||||||
|
await page.locator('#map-tab-location').click();await page.locator('#map-tab-downloads').click();assert.equal(await page.locator('#map-step-review').isVisible(),true);
|
||||||
|
await page.locator('#map-download-cancel').click();await page.waitForFunction(()=>document.querySelector('#map-download-message').textContent.includes('测试任务已取消'));assert.equal(cancelClicks,1);
|
||||||
|
await page.unroute('**/api/maps/downloads');await page.unroute('**/api/maps/downloads/cancel');
|
||||||
|
|
||||||
// Offline files remain readable even after the online cache is no longer needed.
|
// Offline files remain readable even after the online cache is no longer needed.
|
||||||
const tile=await fetch(base+`/api/maps/tile/vec_w/11/${x}/${y}`);assert.equal(tile.status,200);
|
const tile=await fetch(base+`/api/maps/tile/vec_w/11/${x}/${y}`);assert.equal(tile.status,200);
|
||||||
const task={bounds:{west:120.15,south:30.28,east:120.16,north:30.29},minZoom:16,maxZoom:16,road:true,imagery:true};
|
const task={bounds:{west:120.15,south:30.28,east:120.16,north:30.29},minZoom:16,maxZoom:16,road:true,imagery:true};
|
||||||
@@ -80,12 +107,29 @@ try{
|
|||||||
assert.equal(await page.evaluate(()=>window.ridMap.metrics().basemap),'road');
|
assert.equal(await page.evaluate(()=>window.ridMap.metrics().basemap),'road');
|
||||||
assert.equal((await json('/api/realtime/ingest','POST',[{target_id:'MAP-REVIEW-001',receiver_id:'MAP-REVIEW',source_epoch:1,sequence:1,longitude:120.1538,latitude:30.2874,altitude_m:120,heading_deg:0}])).status,200);await page.waitForFunction(()=>window.ridMap.metrics().targets>0);const populatedCamera=await page.evaluate(()=>window.ridMap.metrics().camera);assert.ok(Math.abs(populatedCamera.center[0]-116.4)<.0001,'initial telemetry replaced configured map center');
|
assert.equal((await json('/api/realtime/ingest','POST',[{target_id:'MAP-REVIEW-001',receiver_id:'MAP-REVIEW',source_epoch:1,sequence:1,longitude:120.1538,latitude:30.2874,altitude_m:120,heading_deg:0}])).status,200);await page.waitForFunction(()=>window.ridMap.metrics().targets>0);const populatedCamera=await page.evaluate(()=>window.ridMap.metrics().camera);assert.ok(Math.abs(populatedCamera.center[0]-116.4)<.0001,'initial telemetry replaced configured map center');
|
||||||
await page.getByRole('button',{name:'MAP-REVIEW-001',exact:true}).click();await page.getByRole('button',{name:'聚焦此目标',exact:true}).click();await page.waitForFunction(()=>{const c=window.ridMap.metrics().camera.center;return Math.abs(c[0]-120.1538)<.1&&Math.abs(c[1]-30.2874)<.1});
|
await page.getByRole('button',{name:'MAP-REVIEW-001',exact:true}).click();await page.getByRole('button',{name:'聚焦此目标',exact:true}).click();await page.waitForFunction(()=>{const c=window.ridMap.metrics().camera.center;return Math.abs(c[0]-120.1538)<.1&&Math.abs(c[1]-30.2874)<.1});
|
||||||
await page.locator('[data-open=settings]').first().click();await page.locator('#appearance-view [data-open=maps]').click();await page.waitForFunction(()=>!document.querySelector('#map-save').disabled);await page.waitForFunction(()=>window.ridMapSettings?.metrics()?.camera);
|
await page.locator('[data-open=settings]').first().click();await page.locator('.reference-rail [data-open=maps]').click();await page.waitForFunction(()=>!document.querySelector('#map-save').disabled);await page.waitForFunction(()=>window.ridMapSettings?.metrics()?.camera);
|
||||||
assert.equal(await page.locator('#map-region option').count(),2);await page.waitForFunction(()=>!document.querySelector('#map-network-note').textContent.includes('正在检查'));
|
assert.equal(await page.locator('#map-region option').count(),2);await page.waitForFunction(()=>!document.querySelector('#map-network-note').textContent.includes('正在检查'));
|
||||||
await page.route('**/api/maps/status',route=>route.abort('connectionfailed'));await page.waitForFunction(()=>document.querySelector('#map-network-note').textContent.includes('无法连接本机地图服务'));await page.unroute('**/api/maps/status');await page.waitForFunction(()=>document.querySelector('#map-network-note').textContent.includes('密钥未配置'));
|
await page.route('**/api/maps/status',route=>route.abort('connectionfailed'));await page.waitForFunction(()=>document.querySelector('#map-network-note').textContent.includes('无法连接本机地图服务'));await page.unroute('**/api/maps/status');await page.waitForFunction(()=>document.querySelector('#map-network-note').textContent.includes('密钥未配置'));
|
||||||
await page.screenshot({path:path.resolve('previews/map-settings-live-C-20261023.png')});
|
await page.locator('#map-tab-downloads').click();await page.locator('[data-map-action=step-region]').click();await page.locator('#map-region').selectOption('0');await page.locator('#map-step-next').click();await page.locator('#map-min-zoom').fill('11');await page.locator('#map-max-zoom').fill('11');await page.locator('#map-step-next').click();await page.waitForFunction(()=>!document.querySelector('#map-download-start').disabled);
|
||||||
|
await page.locator('#map-tab-location').click();
|
||||||
|
for(const [width,height]of [[1600,900],[1366,768],[900,700],[390,844],[1200,540]]){
|
||||||
|
await page.setViewportSize({width,height});
|
||||||
|
for(const tab of ['location','downloads']){
|
||||||
|
await page.locator('#map-tab-'+tab).click();
|
||||||
|
if(tab==='downloads')await page.locator('[data-map-action=step-review]').click();
|
||||||
|
const button=page.locator(tab==='location'?'#map-save':'#map-download-start');await button.scrollIntoViewIfNeeded();
|
||||||
|
assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true,`${width} ${tab} overflow`);
|
||||||
|
if(tab==='location'&&width>=1366)assert.equal(await page.locator('#map-location-panel .map-settings-scroll').evaluate(e=>e.scrollHeight<=e.clientHeight+1),true,'common map settings still require scrolling');
|
||||||
|
const b=await button.boundingBox();assert.ok(b.x>=0&&b.x+b.width<=width+1&&b.y>=48&&b.y+b.height<=height+1,JSON.stringify({width,tab,b}));
|
||||||
|
await page.screenshot({path:path.resolve(`previews/map-settings-${tab}-${width}x${height}.png`)});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await page.setViewportSize({width:1366,height:768});await page.evaluate(()=>document.documentElement.style.zoom='2');await page.locator('#map-tab-location').click();await page.locator('#map-save').scrollIntoViewIfNeeded();assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);await page.evaluate(()=>document.documentElement.style.zoom='');
|
||||||
|
|
||||||
await page.setViewportSize({width:800,height:1000});assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);
|
await page.setViewportSize({width:800,height:1000});assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);
|
||||||
await stop();start();await ready();const reloaded=(await json('/api/maps/preferences')).value;assert.equal(reloaded.longitude,116.4);assert.equal(reloaded.regions[0].name,'验收常用区域');
|
await stop();start();await ready();const reloaded=(await json('/api/maps/preferences')).value;assert.equal(reloaded.longitude,116.4);assert.equal(reloaded.regions[0].name,'验收常用区域');
|
||||||
assert.deepEqual(errors,[]);assert.deepEqual(csp,[]);
|
assert.deepEqual(errors,[]);assert.deepEqual(csp,[]);
|
||||||
report={status:'PASS',root,camera,download:done,scenarios:['actual C drawer and MapLibre point selection','pending save locks edits and ignores late map callbacks','invalid coordinates','default camera survives first telemetry','coordinates and unsaved basemap retained across navigation','saved region reload','actual Go sidecar and four-layer offline raster validation','download cancellation and single-job limit','unavailable tiles fail honestly','local service failure and automatic recovery','foreign origin rejection','800px width','no page errors or CSP violations']};console.log(JSON.stringify(report));
|
report={status:'PASS',root,camera,download:done,scenarios:['A layout and C wizard with real MapLibre','step validation and estimate retry','region save preserves location draft','parameter edits invalidate estimate','five viewport sizes and 200percent zoom','pending save locks edits and ignores late map callbacks','invalid coordinates','default camera survives first telemetry','coordinates and unsaved basemap retained across navigation','saved region reload','actual Go sidecar and four-layer offline raster validation','download cancellation and single-job limit','unavailable tiles fail honestly','local service failure and automatic recovery','foreign origin rejection','800px width','no page errors or CSP violations']};console.log(JSON.stringify(report));
|
||||||
}finally{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,'server.log'),output);await writeFile(path.join(root,'report.json'),JSON.stringify(report,null,2));}
|
}catch(error){console.error('MAP TEST FAILED',root,error.stack);const page=browser?.contexts()[0]?.pages()[0];if(page)await page.screenshot({path:path.resolve('previews/map-settings-failure.png'),fullPage:true}).catch(()=>{});throw error;}finally{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,'server.log'),output);await writeFile(path.join(root,'report.json'),JSON.stringify(report,null,2));}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
// 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-module-navigation-'));
|
||||||
|
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));
|
||||||
|
const menu=()=>page.locator('.reference-rail button:visible');
|
||||||
|
const open=async name=>page.locator(`.reference-rail [data-open="${name}"]`).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]);
|
||||||
|
await page.goto(base);await page.locator('#home-app-settings').waitFor();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('#choose-wallpaper').isVisible(),true);
|
||||||
|
assert.equal(await page.locator('#dim').isVisible(),false);
|
||||||
|
await open('display');assert.equal(await page.locator('#dim').isVisible(),true);assert.equal(await page.locator('#choose-wallpaper').isVisible(),false);
|
||||||
|
assert.equal(await page.locator('#reference-title').innerText(),'显示方式');
|
||||||
|
await open('maps');await labels(['壁纸与外观','显示方式','地图配置']);assert.equal(await page.locator('#map-settings-view').isVisible(),true);
|
||||||
|
await home();await labels([]);await page.locator('#home-app-register').click();await labels(['设备登记','本地档案']);
|
||||||
|
await page.locator('#serial-no').fill('NAV-123456');await page.locator('#model-name').fill('导航验收');
|
||||||
|
await open('archives');assert.equal(await page.locator('.history-panel').isVisible(),true);assert.equal(await page.locator('#register-form').isVisible(),false);
|
||||||
|
await open('register');assert.equal(await page.locator('#serial-no').inputValue(),'NAV-123456');
|
||||||
|
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 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 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'));
|
||||||
|
await page.locator('#new-registration').click();assert.equal(await page.locator('#serial-no').inputValue(),'');
|
||||||
|
for(const width of [1600,1000,700]) {
|
||||||
|
await page.setViewportSize({width,height:1000});
|
||||||
|
for(const name of ['archives','register']) {await open(name);assert.ok(await page.locator('#workspace-content').evaluate(e=>e.scrollWidth<=e.clientWidth+1));}
|
||||||
|
}
|
||||||
|
await home();await page.locator('#home-app-realtime').click();await page.waitForURL('**/realtime');await labels(['实时工作台','电子围栏','黑白名单管理']);
|
||||||
|
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 home();await page.locator('#home-app-settings').focus();await page.keyboard.press('Enter');await labels(['壁纸与外观','显示方式','地图配置']);
|
||||||
|
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')});
|
||||||
|
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']};
|
||||||
|
} 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));
|
||||||
|
}
|
||||||
@@ -13,7 +13,7 @@ const exe=process.argv[2]||'D:/Rust_Contact/util/target/Rid_Drone_Receivev/relea
|
|||||||
const base='http://127.0.0.1:18887';
|
const base='http://127.0.0.1:18887';
|
||||||
// Keep production origin checks unchanged. Only this isolated proxy maps the test origin.
|
// Keep production origin checks unchanged. Only this isolated proxy maps the test origin.
|
||||||
const sockets=new Set();
|
const 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:18888,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)});
|
const proxy=http.createServer(async(req,res)=>{if(process.env.RID_SOURCE_ASSETS==='1'&&!req.url.startsWith('/api/')){const pathname=new URL(req.url,'http://localhost').pathname;const relative=pathname==='/'||pathname==='/realtime'?'index.html':pathname.slice(1);if(!relative.includes('..'))try{let bytes;try{bytes=await readFile(path.join('crates/web-ui/public',relative));}catch{bytes=await readFile(path.join('dist/web-ui',relative));}res.writeHead(200,{'content-type':relative.endsWith('.html')?'text/html':relative.endsWith('.css')?'text/css':relative.endsWith('.wasm')?'application/wasm':relative.endsWith('.svg')?'image/svg+xml':relative.endsWith('.png')?'image/png':'text/javascript'});res.end(bytes);return}catch{}}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:18888,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(18888,'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';upstream.write(`GET ${req.url} HTTP/1.1\r\n${Object.entries(headers).map(([k,v])=>`${k}: ${v}`).join('\r\n')}\r\n\r\n`);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)})});
|
proxy.on('upgrade',(req,socket,head)=>{const upstream=net.connect(18888,'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';upstream.write(`GET ${req.url} HTTP/1.1\r\n${Object.entries(headers).map(([k,v])=>`${k}: ${v}`).join('\r\n')}\r\n\r\n`);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)})});
|
||||||
let occupied=false;try{await fetch(base,{signal:AbortSignal.timeout(800)});occupied=true;}catch{}if(occupied)throw Error('18887 occupied; preserving existing service');
|
let occupied=false;try{await fetch(base,{signal:AbortSignal.timeout(800)});occupied=true;}catch{}if(occupied)throw Error('18887 occupied; preserving existing service');
|
||||||
const backendOccupied=await new Promise(resolve=>{const socket=net.connect(18888,'127.0.0.1');socket.once('connect',()=>{socket.destroy();resolve(true)});socket.once('error',()=>resolve(false));socket.setTimeout(800,()=>{socket.destroy();resolve(false)})});if(backendOccupied)throw Error('18888 occupied; preserving existing service');
|
const backendOccupied=await new Promise(resolve=>{const socket=net.connect(18888,'127.0.0.1');socket.once('connect',()=>{socket.destroy();resolve(true)});socket.once('error',()=>resolve(false));socket.setTimeout(800,()=>{socket.destroy();resolve(false)})});if(backendOccupied)throw Error('18888 occupied; preserving existing service');
|
||||||
@@ -33,6 +33,7 @@ try {
|
|||||||
for(const asset of ['workspace-native.css','map-adapter.js','index.html']){const response=await fetch(base+'/'+(asset==='index.html'?'realtime':asset));assert.equal(response.status,200);assert.ok(await response.text()===await readFile(path.resolve('dist/web-ui',asset),'utf8'),'Executable contains stale '+asset);}
|
for(const asset of ['workspace-native.css','map-adapter.js','index.html']){const response=await fetch(base+'/'+(asset==='index.html'?'realtime':asset));assert.equal(response.status,200);assert.ok(await response.text()===await readFile(path.resolve('dist/web-ui',asset),'utf8'),'Executable contains stale '+asset);}
|
||||||
await page.goto(base+'/realtime');await page.locator('.rt-status').filter({hasText:'已连接'}).waitFor();
|
await page.goto(base+'/realtime');await page.locator('.rt-status').filter({hasText:'已连接'}).waitFor();
|
||||||
console.log('Checking actual Rust/Wasm layout and telemetry');
|
console.log('Checking actual Rust/Wasm layout and telemetry');
|
||||||
|
assert.equal(await page.locator('#rt-dock').isVisible(),false);await page.locator('#rt-dock-restore').click();
|
||||||
await page.locator('.live-empty').waitFor();assert.equal(await page.locator('.mc-btn-row a').getAttribute('aria-disabled'),'true');
|
await page.locator('.live-empty').waitFor();assert.equal(await page.locator('.mc-btn-row a').getAttribute('aria-disabled'),'true');
|
||||||
await page.getByRole('button',{name:'聚焦此目标',exact:true}).isDisabled().then(v=>assert.ok(v));
|
await page.getByRole('button',{name:'聚焦此目标',exact:true}).isDisabled().then(v=>assert.ok(v));
|
||||||
const registered=await fetch(base+'/api/records',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify({serialNo:'LAYOUT-0000',modelName:'验收模拟机型',ownerName:'隔离验收数据'})});assert.equal(registered.status,200);
|
const registered=await fetch(base+'/api/records',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify({serialNo:'LAYOUT-0000',modelName:'验收模拟机型',ownerName:'隔离验收数据'})});assert.equal(registered.status,200);
|
||||||
@@ -85,7 +86,7 @@ try {
|
|||||||
for(const zoom of [1.25,1.5]){await page.setViewportSize({width:1280,height:720});await page.evaluate(z=>document.documentElement.style.zoom=String(z),zoom);await wait(250);assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);await page.screenshot({path:path.join(root,`realtime-b-zoom-${zoom}.png`)});}
|
for(const zoom of [1.25,1.5]){await page.setViewportSize({width:1280,height:720});await page.evaluate(z=>document.documentElement.style.zoom=String(z),zoom);await wait(250);assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);await page.screenshot({path:path.join(root,`realtime-b-zoom-${zoom}.png`)});}
|
||||||
await page.evaluate(()=>document.documentElement.style.zoom='');await page.setViewportSize({width:1600,height:1000});await wait(250);
|
await page.evaluate(()=>document.documentElement.style.zoom='');await page.setViewportSize({width:1600,height:1000});await wait(250);
|
||||||
const savedBeforeHome=await page.evaluate(k=>localStorage.getItem(k),key);await page.getByRole('button',{name:'返回应用总览',exact:true}).click();await page.locator('body[data-screen=home]').waitFor();await page.setViewportSize({width:390,height:844});await wait(250);await page.setViewportSize({width:1600,height:1000});await wait(250);assert.equal(await page.evaluate(k=>localStorage.getItem(k),key),savedBeforeHome);await page.locator('#home-app-realtime').click();await page.locator('body[data-screen=realtime]').waitFor();await wait(250);
|
const savedBeforeHome=await page.evaluate(k=>localStorage.getItem(k),key);await page.getByRole('button',{name:'返回应用总览',exact:true}).click();await page.locator('body[data-screen=home]').waitFor();await page.setViewportSize({width:390,height:844});await wait(250);await page.setViewportSize({width:1600,height:1000});await wait(250);assert.equal(await page.evaluate(k=>localStorage.getItem(k),key),savedBeforeHome);await page.locator('#home-app-realtime').click();await page.locator('body[data-screen=realtime]').waitFor();await wait(250);
|
||||||
await page.evaluate(k=>localStorage.setItem(k,'broken json'),key);await page.reload();await page.locator('.rt-status').filter({hasText:'已连接'}).waitFor();await wait(250);assert.equal(Number(await grip.getAttribute('aria-valuenow')),170);
|
await page.evaluate(k=>localStorage.setItem(k,'broken json'),key);await page.reload();await page.locator('.rt-status').filter({hasText:'已连接'}).waitFor();await wait(250);assert.equal(await page.locator('#rt-dock').isVisible(),false);await page.locator('#rt-dock-restore').click();assert.equal(Number(await grip.getAttribute('aria-valuenow')),170);
|
||||||
await page.getByRole('textbox',{name:'搜索实时目标'}).fill('LAYOUT-0000');await page.getByRole('button',{name:'LAYOUT-0000',exact:true}).click();await page.getByRole('button',{name:'聚焦此目标',exact:true}).click();await wait(500);await page.screenshot({path:path.join(root,'realtime-b-final.png')});
|
await page.getByRole('textbox',{name:'搜索实时目标'}).fill('LAYOUT-0000');await page.getByRole('button',{name:'LAYOUT-0000',exact:true}).click();await page.getByRole('button',{name:'聚焦此目标',exact:true}).click();await wait(500);await page.screenshot({path:path.join(root,'realtime-b-final.png')});
|
||||||
const realtimeStatus=await (await fetch(base+'/api/realtime/status')).json();assert.equal(realtimeStatus.clients,1);
|
const realtimeStatus=await (await fetch(base+'/api/realtime/status')).json();assert.equal(realtimeStatus.clients,1);
|
||||||
assert.deepEqual(errors,[]);assert.deepEqual(csp,[]);
|
assert.deepEqual(errors,[]);assert.deepEqual(csp,[]);
|
||||||
|
|||||||
@@ -26,19 +26,19 @@ try{
|
|||||||
for(const asset of ['workspace-native.css','index.html']){const response=await fetch(base+'/'+(asset==='index.html'?'realtime':asset));assert.equal(await response.text(),await readFile(path.join('dist/web-ui',asset),'utf8'));}
|
for(const asset of ['workspace-native.css','index.html']){const response=await fetch(base+'/'+(asset==='index.html'?'realtime':asset));assert.equal(await response.text(),await readFile(path.join('dist/web-ui',asset),'utf8'));}
|
||||||
await save('MENU-BLACK','black');await save('MENU-WHITE','white');const before=await snapshot();
|
await save('MENU-BLACK','black');await save('MENU-WHITE','white');const before=await snapshot();
|
||||||
browser=await chromium.launch({headless:true,channel:'msedge'});const context=await browser.newContext({viewport:{width:1600,height:1000}});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:1600,height:1000}});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.waitForFunction(()=>document.querySelector('.rt-status')?.textContent.includes('已连接'));await page.waitForFunction(()=>!document.querySelector('#rt-list-manager-from-directory')?.disabled);await wait(300);
|
await page.goto(base+'/realtime');await page.waitForFunction(()=>document.querySelector('.rt-status')?.textContent.includes('已连接'));await page.waitForFunction(()=>!document.querySelector('#rt-list-manager-from-directory')?.disabled);await wait(300);await page.locator('#rt-dock-restore').click();
|
||||||
const nav=page.getByRole('navigation',{name:'主菜单'});assert.equal(await nav.locator('button:visible').count(),1);assert.equal(await nav.locator('button:visible').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'),'黑白名单管理');
|
||||||
for(const name of ['应用首页','应用总览','设备登记','实时目标工作台','壁纸与外观'])assert.equal(await nav.getByRole('button',{name,exact:true}).isVisible(),false);
|
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(),0);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);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-expanded'),'false');
|
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;}
|
||||||
await corner();await page.getByRole('button',{name:'隐藏事件面板',exact:true}).click();await page.locator('#rt-dock-restore').waitFor();await corner();await page.getByRole('button',{name:'收起目标目录',exact:true}).click();await page.getByRole('button',{name:'收起详情',exact:true}).click();await corner();await page.screenshot({path:path.join(root,'desktop-collapsed.png')});
|
await corner();await page.getByRole('button',{name:'隐藏事件面板',exact:true}).click();await page.locator('#rt-dock-restore').waitFor();await corner();await page.getByRole('button',{name:'收起目标目录',exact:true}).click();await page.getByRole('button',{name:'收起详情',exact:true}).click();await corner();await page.screenshot({path:path.join(root,'desktop-collapsed.png')});
|
||||||
await page.locator('#rt-dock-restore').click();await page.locator('#rt-dock').waitFor();await corner();const overDock=await page.evaluate(()=>{const info=document.querySelector('.mc-map-infobar').getBoundingClientRect(),dock=document.querySelector('#rt-dock').getBoundingClientRect();return info.left>=dock.left&&info.right<=dock.right&&info.top>=dock.top&&info.bottom<=dock.bottom});assert.ok(overDock,'Status must overlay the dock rather than avoiding it');
|
await page.locator('#rt-dock-restore').click();await page.locator('#rt-dock').waitFor();await corner();const overDock=await page.evaluate(()=>{const info=document.querySelector('.mc-map-infobar').getBoundingClientRect(),dock=document.querySelector('#rt-dock').getBoundingClientRect();return info.left>=dock.left&&info.right<=dock.right&&info.top>=dock.top&&info.bottom<=dock.bottom});assert.ok(overDock,'Status must overlay the dock rather than avoiding it');
|
||||||
await page.getByRole('button',{name:'隐藏事件面板',exact:true}).click();await page.locator('#rt-dock-restore').waitFor();await page.locator('#toggle-menu').click();await corner();assert.equal(await nav.isVisible(),false);await page.locator('#toggle-menu').click();assert.equal(await nav.locator('button:visible').count(),1);
|
await page.getByRole('button',{name:'隐藏事件面板',exact:true}).click();await page.locator('#rt-dock-restore').waitFor();await page.locator('#toggle-menu').click();await corner();assert.equal(await nav.isVisible(),false);await page.locator('#toggle-menu').click();assert.equal(await nav.locator('button:visible').count(),4);
|
||||||
const frames=[];for(const[width,height]of [[1600,1000],[1280,720],[390,844],[360,740]]){await page.setViewportSize({width,height});await wait(300);frames.push({width,height,...await corner()});assert.equal(await nav.locator('button:visible').count(),1);await page.screenshot({path:path.join(root,`menu-status-${width}.png`)});}
|
const frames=[];for(const[width,height]of [[1600,1000],[1280,720],[390,844],[360,740]]){await page.setViewportSize({width,height});await wait(300);frames.push({width,height,...await corner()});assert.equal(await nav.locator('button:visible').count(),4);await page.screenshot({path:path.join(root,`menu-status-${width}.png`)});}
|
||||||
await page.setViewportSize({width:1600,height:1000});await wait(300);await page.getByRole('button',{name:'返回应用总览',exact:true}).click();await page.locator('body[data-screen=home]').waitFor();assert.equal(await page.locator('#rt-blacklist-menu').isVisible(),false);await page.locator('#home-app-register').click();await page.locator('body[data-screen=register]').waitFor();assert.equal(await page.locator('.reference-rail [data-open=register]').isVisible(),true);assert.equal(await page.locator('#rt-blacklist-menu').isVisible(),false);
|
await page.setViewportSize({width:1600,height:1000});await wait(300);await page.getByRole('button',{name:'返回应用总览',exact:true}).click();await page.locator('body[data-screen=home]').waitFor();assert.equal(await page.locator('#rt-blacklist-menu').isVisible(),false);await page.locator('#home-app-register').click();await page.locator('body[data-screen=register]').waitFor();assert.equal(await page.locator('.reference-rail [data-open=register]').isVisible(),true);assert.equal(await page.locator('#rt-blacklist-menu').isVisible(),false);
|
||||||
await page.getByRole('button',{name:'返回应用总览',exact:true}).click();await page.locator('#home-app-realtime').click();await page.waitForFunction(()=>document.querySelector('.rt-status')?.textContent.includes('已连接'));assert.equal(await nav.locator('button:visible').count(),1);await corner();
|
await page.getByRole('button',{name:'返回应用总览',exact:true}).click();await page.locator('#home-app-realtime').click();await page.waitForFunction(()=>document.querySelector('.rt-status')?.textContent.includes('已连接'));assert.equal(await nav.locator('button:visible').count(),4);await corner();
|
||||||
assert.deepEqual(await snapshot(),before);assert.deepEqual(errors,[]);assert.deepEqual(csp,[]);report={status:'PASS',root,exe,frames,checks:['one-blacklist-menu','blacklist-filter-and-default-kind','keyboard-open-and-return-focus','fixed-bottom-right-dock-and-panels','overlays-dock','menu-collapse','four-window-sizes','other-app-navigation-preserved','list-data-unchanged'],errors,csp};console.log(JSON.stringify(report));
|
assert.deepEqual(await snapshot(),before);assert.deepEqual(errors,[]);assert.deepEqual(csp,[]);report={status:'PASS',root,exe,frames,checks:['left-menu-full-page','both-list-kinds-visible','keyboard-open-and-return-focus','fixed-bottom-right-dock-and-panels','overlays-dock','menu-collapse','four-window-sizes','other-app-navigation-preserved','list-data-unchanged'],errors,csp};console.log(JSON.stringify(report));
|
||||||
}finally{if(browser){if(report.status!=='PASS'){const p=browser.contexts()[0]?.pages()[0];if(p){await p.screenshot({path:path.join(root,'failure.png')}).catch(()=>{});console.log(JSON.stringify({root,errors,csp,diagnostic:await p.evaluate(()=>({screen:document.body.dataset.screen,menu:[...document.querySelectorAll('.reference-rail button')].map(e=>({id:e.id,label:e.getAttribute('aria-label'),height:e.getBoundingClientRect().height})),manager:document.getElementById('rt-list-manager')?.hidden})).catch(()=>null)}));}}await browser.close();}if(child&&child.exitCode===null){const done=new Promise(r=>child.once('exit',r));child.kill();await done;}for(const socket of sockets)socket.destroy();const closed=new Promise(r=>proxy.close(r));proxy.closeAllConnections();await closed;await writeFile(path.join(root,'report.json'),JSON.stringify(report,null,2));await writeFile(path.join(root,'server.log'),output);}
|
}finally{if(browser){if(report.status!=='PASS'){const p=browser.contexts()[0]?.pages()[0];if(p){await p.screenshot({path:path.join(root,'failure.png')}).catch(()=>{});console.log(JSON.stringify({root,errors,csp,diagnostic:await p.evaluate(()=>({screen:document.body.dataset.screen,menu:[...document.querySelectorAll('.reference-rail button')].map(e=>({id:e.id,label:e.getAttribute('aria-label'),height:e.getBoundingClientRect().height})),manager:document.getElementById('rt-list-manager')?.hidden})).catch(()=>null)}));}}await browser.close();}if(child&&child.exitCode===null){const done=new Promise(r=>child.once('exit',r));child.kill();await done;}for(const socket of sockets)socket.destroy();const closed=new Promise(r=>proxy.close(r));proxy.closeAllConnections();await closed;await writeFile(path.join(root,'report.json'),JSON.stringify(report,null,2));await writeFile(path.join(root,'server.log'),output);}
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
// Real SQLite, Rust/Wasm, Worker and WebGL acceptance. No physical transports opened.
|
||||||
|
import {mkdtemp,readFile,writeFile} 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-list-page-'));
|
||||||
|
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,heartbeat,output='';const errors=[],csp=[],sockets=new Set();
|
||||||
|
const proxy=http.createServer(async(req,res)=>{if(process.env.RID_SOURCE_ASSETS==='1'&&!req.url.startsWith('/api/')){const pathname=new URL(req.url,'http://localhost').pathname;const relative=pathname==='/'||pathname==='/realtime'?'index.html':pathname.slice(1);if(!relative.includes('..'))try{let bytes;try{bytes=await readFile(path.join('crates/web-ui/public',relative));}catch{bytes=await readFile(path.join('dist/web-ui',relative));}res.writeHead(200,{'content-type':relative.endsWith('.html')?'text/html':relative.endsWith('.css')?'text/css':relative.endsWith('.wasm')?'application/wasm':relative.endsWith('.svg')?'image/svg+xml':relative.endsWith('.png')?'image/png':'text/javascript'});res.end(bytes);return}catch{}}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/target-lists')).ok)return}catch{}await wait(100)}throw Error('server timeout '+output)}
|
||||||
|
async function snapshot(){return(await fetch(base+'/api/target-lists')).json()}
|
||||||
|
async function save(id,kind,note='验收备注'){const current=await snapshot();const r=await fetch(base+'/api/target-lists/'+id,{method:'PUT',headers:{'content-type':'application/json'},body:JSON.stringify({list_kind:kind,note,expected_revision:current.revision})});assert.equal(r.status,200);return r.json()}
|
||||||
|
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();
|
||||||
|
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())});
|
||||||
|
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);
|
||||||
|
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.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');
|
||||||
|
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.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.
|
||||||
|
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=target-lists');await page.locator('body[data-screen=target-lists]').waitFor();await page.locator('.rt-list-row').first().waitFor();
|
||||||
|
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));
|
||||||
|
}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);}
|
||||||
@@ -12,7 +12,7 @@ const root=await mkdtemp(path.join(tmpdir(),'RID-target-lists-'));
|
|||||||
const exe=process.argv[2]||'D:/Rust_Contact/util/target/Rid_Drone_Receivev/release/fpv-rid-registry-fullstack.exe';
|
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));
|
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,heartbeat,output='';const errors=[],csp=[],sockets=new Set();
|
let base,child,browser,heartbeat,output='';const errors=[],csp=[],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)});
|
const proxy=http.createServer(async(req,res)=>{if(process.env.RID_SOURCE_ASSETS==='1'&&!req.url.startsWith('/api/')){const pathname=new URL(req.url,'http://localhost').pathname;const relative=pathname==='/'||pathname==='/realtime'?'index.html':pathname.slice(1);if(!relative.includes('..'))try{let bytes;try{bytes=await readFile(path.join('crates/web-ui/public',relative));}catch{bytes=await readFile(path.join('dist/web-ui',relative));}res.writeHead(200,{'content-type':relative.endsWith('.html')?'text/html':relative.endsWith('.css')?'text/css':relative.endsWith('.wasm')?'application/wasm':relative.endsWith('.svg')?'image/svg+xml':relative.endsWith('.png')?'image/png':'text/javascript'});res.end(bytes);return}catch{}}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)})});
|
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));
|
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)}
|
||||||
@@ -29,7 +29,7 @@ try{
|
|||||||
await save('LIST-WHITE','white');await save('LIST-BLACK','black');await save('OFFLINE_001','white');
|
await save('LIST-WHITE','white');await save('LIST-BLACK','black');await save('OFFLINE_001','white');
|
||||||
for(const file of ['target-lists.css','map-adapter.js'])assert.equal(await(await fetch(base+'/'+file)).text(),await readFile(path.join('dist/web-ui',file),'utf8'));
|
for(const file of ['target-lists.css','map-adapter.js'])assert.equal(await(await fetch(base+'/'+file)).text(),await readFile(path.join('dist/web-ui',file),'utf8'));
|
||||||
browser=await chromium.launch({headless:true,channel:'msedge'});const context=await browser.newContext({viewport:{width:1600,height:1000}});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:1600,height:1000}});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();
|
await page.goto(base+'/realtime');await page.locator('.rt-status').filter({hasText:'已连接'}).waitFor();await page.locator('#rt-dock-restore').click();
|
||||||
const filters=page.getByRole('group',{name:'目标名单筛选'});
|
const filters=page.getByRole('group',{name:'目标名单筛选'});
|
||||||
await page.waitForFunction(()=>![...document.querySelectorAll('.rt-target-list-filters button')].some(b=>b.disabled));
|
await page.waitForFunction(()=>![...document.querySelectorAll('.rt-target-list-filters button')].some(b=>b.disabled));
|
||||||
await ingest();heartbeat=setInterval(()=>ingest().catch(()=>{}),3000);
|
await ingest();heartbeat=setInterval(()=>ingest().catch(()=>{}),3000);
|
||||||
@@ -74,7 +74,7 @@ try{
|
|||||||
await page.unroute('**/api/target-lists?revision=*');await page.locator('#rt-list-manager .rt-list-sync-error').getByRole('button',{name:'重试',exact:true}).click();await page.locator('#rt-list-manager .rt-list-sync-error').waitFor({state:'hidden'});
|
await page.unroute('**/api/target-lists?revision=*');await page.locator('#rt-list-manager .rt-list-sync-error').getByRole('button',{name:'重试',exact:true}).click();await page.locator('#rt-list-manager .rt-list-sync-error').waitFor({state:'hidden'});
|
||||||
const unavailableContext=await browser.newContext(),unavailable=await unavailableContext.newPage();
|
const unavailableContext=await browser.newContext(),unavailable=await unavailableContext.newPage();
|
||||||
await unavailable.route('**/api/target-lists**',r=>r.fulfill({status:503,contentType:'application/json',body:'{}'}));await unavailable.goto(base+'/realtime');
|
await unavailable.route('**/api/target-lists**',r=>r.fulfill({status:503,contentType:'application/json',body:'{}'}));await unavailable.goto(base+'/realtime');
|
||||||
await unavailable.locator('.rt-list-sync-error').filter({hasText:'名单读取失败'}).first().waitFor();await unavailable.locator('.rt-target').first().waitFor();
|
await unavailable.locator('#rt-directory .rt-list-sync-error').filter({hasText:'名单读取失败'}).waitFor();await unavailable.locator('.rt-target').first().waitFor();
|
||||||
assert.equal(await unavailable.locator('.rt-target .rt-list-badge[data-kind=unavailable]').count(),3);
|
assert.equal(await unavailable.locator('.rt-target .rt-list-badge[data-kind=unavailable]').count(),3);
|
||||||
assert.equal(await unavailable.getByRole('group',{name:'目标名单筛选'}).getByRole('button',{name:/^黑名单/}).isDisabled(),true);assert.ok((await unavailable.getByRole('group',{name:'目标名单筛选'}).getByRole('button',{name:/^黑名单/}).innerText()).includes('—'));
|
assert.equal(await unavailable.getByRole('group',{name:'目标名单筛选'}).getByRole('button',{name:/^黑名单/}).isDisabled(),true);assert.ok((await unavailable.getByRole('group',{name:'目标名单筛选'}).getByRole('button',{name:/^黑名单/}).innerText()).includes('—'));
|
||||||
await unavailableContext.close();
|
await unavailableContext.close();
|
||||||
|
|||||||
+18
-1
@@ -32,7 +32,10 @@ impl Default for Appearance {
|
|||||||
impl Appearance {
|
impl Appearance {
|
||||||
fn validate(&self) -> Result<()> {
|
fn validate(&self) -> Result<()> {
|
||||||
if !matches!(self.theme.as_str(), "graphite" | "blue" | "white")
|
if !matches!(self.theme.as_str(), "graphite" | "blue" | "white")
|
||||||
|| !matches!(self.wallpaper.as_str(), "B1" | "B2" | "B3" | "B4")
|
|| !matches!(
|
||||||
|
self.wallpaper.as_str(),
|
||||||
|
"B1" | "B2" | "B3" | "B4" | "B5" | "B6" | "B7"
|
||||||
|
)
|
||||||
|| !matches!(self.fit.as_str(), "cover" | "contain")
|
|| !matches!(self.fit.as_str(), "cover" | "contain")
|
||||||
|| self.dim > 65
|
|| self.dim > 65
|
||||||
|| self.blur > 16
|
|| self.blur > 16
|
||||||
@@ -143,6 +146,20 @@ mod tests {
|
|||||||
assert_eq!(raw, "broken");
|
assert_eq!(raw, "broken");
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
|
fn bright_wallpapers_persist_and_unknown_wallpapers_are_rejected() {
|
||||||
|
let mut db = db();
|
||||||
|
for wallpaper in ["B5", "B6", "B7"] {
|
||||||
|
let mut prefs = load(&db).unwrap();
|
||||||
|
prefs.wallpaper = wallpaper.into();
|
||||||
|
save(&mut db, serde_json::to_value(prefs).unwrap()).unwrap();
|
||||||
|
assert_eq!(load(&db).unwrap().wallpaper, wallpaper);
|
||||||
|
}
|
||||||
|
let mut prefs = load(&db).unwrap();
|
||||||
|
prefs.wallpaper = "B8".into();
|
||||||
|
assert!(save(&mut db, serde_json::to_value(prefs).unwrap()).is_err());
|
||||||
|
assert_eq!(load(&db).unwrap().wallpaper, "B7");
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
fn new_default_does_not_replace_saved_legacy_appearance() {
|
fn new_default_does_not_replace_saved_legacy_appearance() {
|
||||||
let mut db = db();
|
let mut db = db();
|
||||||
assert_eq!(load(&db).unwrap().wallpaper, "B4");
|
assert_eq!(load(&db).unwrap().wallpaper, "B4");
|
||||||
|
|||||||
Reference in New Issue
Block a user