feat(web-ui): 增强围栏地图交互与接收机状态显示
- 在 geofence-map-adapter.js 中添加了处理围栏顶点和圆心的拖动功能,提升用户交互体验。 - 实现了计算两点间距离的函数,以支持动态调整围栏半径。 - 更新了 receivers.js 中的状态显示逻辑,优化了设备状态的反馈信息,确保更准确的连接状态提示。 - 修改了 CSS 文件以改善界面样式,确保在不同主题下的视觉一致性。
This commit is contained in:
@@ -11,9 +11,12 @@ function ring(g){if(g.type==='polygon')return [...g.vertices,g.vertices[0]];
|
|||||||
for(let i=0;i<=96;i++){const bearing=i/96*2*Math.PI,p=Math.asin(Math.sin(a)*Math.cos(delta)+Math.cos(a)*Math.sin(delta)*Math.cos(bearing));const q=b+Math.atan2(Math.sin(bearing)*Math.sin(delta)*Math.cos(a),Math.cos(delta)-Math.sin(a)*Math.sin(p));points.push([q*180/Math.PI,p*180/Math.PI]);}return points;
|
for(let i=0;i<=96;i++){const bearing=i/96*2*Math.PI,p=Math.asin(Math.sin(a)*Math.cos(delta)+Math.cos(a)*Math.sin(delta)*Math.cos(bearing));const q=b+Math.atan2(Math.sin(bearing)*Math.sin(delta)*Math.cos(a),Math.cos(delta)-Math.sin(a)*Math.sin(p));points.push([q*180/Math.PI,p*180/Math.PI]);}return points;
|
||||||
}
|
}
|
||||||
function feature(f,draft=false){return {type:'Feature',properties:{id:f.id,enabled:f.enabled,draft},geometry:{type:'Polygon',coordinates:[ring(f.geometry)]}};}
|
function feature(f,draft=false){return {type:'Feature',properties:{id:f.id,enabled:f.enabled,draft},geometry:{type:'Polygon',coordinates:[ring(f.geometry)]}};}
|
||||||
|
function metres(a,b){const dLat=(b[1]-a[1])*Math.PI/180,dLon=(b[0]-a[0])*Math.PI/180,la=a[1]*Math.PI/180,lb=b[1]*Math.PI/180,h=Math.sin(dLat/2)**2+Math.cos(la)*Math.cos(lb)*Math.sin(dLon/2)**2;return 6371008.8*2*Math.asin(Math.min(1,Math.sqrt(h)));}
|
||||||
|
function handle(point,label,apply){const element=document.createElement('div');element.className='gf-handle';element.setAttribute('aria-label',label);const marker=new ml.Marker({element,anchor:'center',offset:[0,0],draggable:true}).setLngLat(point).addTo(map);marker.on('dragend',()=>{const p=marker.getLngLat();apply([p.lng,p.lat]);});markers.push(marker);}
|
||||||
function handles(){for(const m of markers)m.remove();markers=[];if(!map||mode||!data.draft)return;
|
function handles(){for(const m of markers)m.remove();markers=[];if(!map||mode||!data.draft)return;
|
||||||
const g=data.draft.geometry,points=g.type==='circle'?[g.center]:g.vertices;
|
const g=data.draft.geometry;
|
||||||
points.forEach((point,index)=>{const element=document.createElement('div');element.className='gf-handle';element.setAttribute('aria-label',g.type==='circle'?'拖动围栏圆心':`拖动围栏顶点 ${index+1}`);const marker=new ml.Marker({element,draggable:true}).setLngLat(point).addTo(map);marker.on('dragend',()=>{const p=marker.getLngLat(),geometry=structuredClone(g);marker.setLngLat(point);if(g.type==='circle')geometry.center=[p.lng,p.lat];else geometry.vertices[index]=[p.lng,p.lat];emit('rid-fence-geometry',geometry);});markers.push(marker);});
|
if(g.type==='circle'){handle(g.center,'拖动围栏圆心',p=>{const geometry=structuredClone(g);geometry.center=p;emit('rid-fence-geometry',geometry);});handle(ring(g)[24],'拖动圆边调整半径',p=>{const geometry=structuredClone(g);geometry.radius_m=Math.min(1000000,Math.max(1,metres(g.center,p)));emit('rid-fence-geometry',geometry);});return;}
|
||||||
|
g.vertices.forEach((point,index)=>handle(point,`拖动围栏顶点 ${index+1}`,p=>{const geometry=structuredClone(g);geometry.vertices[index]=p;emit('rid-fence-geometry',geometry);}));
|
||||||
}
|
}
|
||||||
export function render(value){data=value||data;if(!map?.getSource('fences'))return;
|
export function render(value){data=value||data;if(!map?.getSource('fences'))return;
|
||||||
const features=data.entries.filter(f=>f.id!==data.draft?.id).map(f=>feature(f));if(data.draft)features.push(feature(data.draft,true));
|
const features=data.entries.filter(f=>f.id!==data.draft?.id).map(f=>feature(f));if(data.draft)features.push(feature(data.draft,true));
|
||||||
@@ -21,7 +24,7 @@ export function render(value){data=value||data;if(!map?.getSource('fences'))retu
|
|||||||
}
|
}
|
||||||
export function targets(items){latestTargets=(items||[]).filter(t=>Number.isFinite(t.longitude)&&Number.isFinite(t.latitude));map?.getSource('targets')?.setData({type:'FeatureCollection',features:latestTargets.map(t=>({type:'Feature',properties:t,geometry:{type:'Point',coordinates:[t.longitude,t.latitude]}}))});}
|
export function targets(items){latestTargets=(items||[]).filter(t=>Number.isFinite(t.longitude)&&Number.isFinite(t.latitude));map?.getSource('targets')?.setData({type:'FeatureCollection',features:latestTargets.map(t=>({type:'Feature',properties:t,geometry:{type:'Point',coordinates:[t.longitude,t.latitude]}}))});}
|
||||||
export function open(p){if(map){map.resize();return;}kind=p.basemap==='road'?'road':'imagery';
|
export function open(p){if(map){map.resize();return;}kind=p.basemap==='road'?'road':'imagery';
|
||||||
try{map=new ml.Map({container:'geofence-map',center:[p.longitude,p.latitude],zoom:p.zoom??15,pitch:0,bearing:0,maxZoom:18,maxTileCacheSize:1024,style:{version:8,sources:{base:{type:'raster',tiles:[url(0)],tileSize:256,maxzoom:18},labels:{type:'raster',tiles:[url(1)],tileSize:256,maxzoom:18},targets:{type:'geojson',data:{type:'FeatureCollection',features:[]}},fences:{type:'geojson',data:{type:'FeatureCollection',features:[]}}},layers:[{id:'background',type:'background',paint:{'background-color':'#020b18'}},{id:'base',type:'raster',source:'base'},{id:'labels',type:'raster',source:'labels'},{id:'fence-fill',type:'fill',source:'fences',paint:{'fill-color':['case',['get','enabled'],'#5ba6ed','#8192a5'],'fill-opacity':['case',['get','draft'],.22,.10]}},{id:'fence-line',type:'line',source:'fences',paint:{'line-color':['case',['get','draft'],'#c5e3ff',['get','enabled'],'#7ec6ff','#8192a5'],'line-width':['case',['get','draft'],2.5,1.5]}},{id:'target-dots',type:'circle',source:'targets',paint:{'circle-radius':6,'circle-color':['match',['get','list_kind'],'white','#83dcb9','black','#ff938b','#91c9ff'],'circle-stroke-color':'#020b18','circle-stroke-width':2}}]}});
|
try{map=new ml.Map({container:'geofence-map',center:[p.longitude,p.latitude],zoom:p.zoom??15,pitch:0,bearing:0,maxZoom:18,maxTileCacheSize:1024,boxZoom:false,dragRotate:false,style:{version:8,sources:{base:{type:'raster',tiles:[url(0)],tileSize:256,maxzoom:18},labels:{type:'raster',tiles:[url(1)],tileSize:256,maxzoom:18},targets:{type:'geojson',data:{type:'FeatureCollection',features:[]}},fences:{type:'geojson',data:{type:'FeatureCollection',features:[]}}},layers:[{id:'background',type:'background',paint:{'background-color':'#020b18'}},{id:'base',type:'raster',source:'base'},{id:'labels',type:'raster',source:'labels'},{id:'fence-fill',type:'fill',source:'fences',paint:{'fill-color':['case',['get','enabled'],'#5ba6ed','#8192a5'],'fill-opacity':['case',['get','draft'],.22,.10]}},{id:'fence-line',type:'line',source:'fences',layout:{'line-join':'round','line-cap':'round'},paint:{'line-color':['case',['get','draft'],'#d7ecff',['get','enabled'],'#7ec6ff','#8192a5'],'line-width':['case',['get','draft'],2.5,1.5]}},{id:'target-dots',type:'circle',source:'targets',paint:{'circle-radius':6,'circle-color':['match',['get','list_kind'],'white','#83dcb9','black','#ff938b','#91c9ff'],'circle-stroke-color':'#020b18','circle-stroke-width':2}}]}});
|
||||||
buffer=attachTileBuffer(map,()=>kind);observer=new ResizeObserver(()=>map?.resize());observer.observe(document.getElementById('geofence-map'));map.addControl(new ml.NavigationControl({showCompass:false}),'bottom-left');map.addControl(new ml.AttributionControl({customAttribution:'天地图 © 自然资源部 · 本地监测围栏',compact:true}),'bottom-right');
|
buffer=attachTileBuffer(map,()=>kind);observer=new ResizeObserver(()=>map?.resize());observer.observe(document.getElementById('geofence-map'));map.addControl(new ml.NavigationControl({showCompass:false}),'bottom-left');map.addControl(new ml.AttributionControl({customAttribution:'天地图 © 自然资源部 · 本地监测围栏',compact:true}),'bottom-right');
|
||||||
map.on('load',()=>{render(data);targets(latestTargets);});map.on('error',e=>{if(!['base','labels'].includes(e.sourceId))emit('rid-fence-map-error',{message:'围栏地图操作失败,请使用坐标编辑并检查 WebGL。'});});
|
map.on('load',()=>{render(data);targets(latestTargets);});map.on('error',e=>{if(!['base','labels'].includes(e.sourceId))emit('rid-fence-map-error',{message:'围栏地图操作失败,请使用坐标编辑并检查 WebGL。'});});
|
||||||
map.on('click',e=>{if(mode==='circle'){const radius=data.draft?.geometry?.radius_m||500;emit('rid-fence-geometry',{type:'circle',center:[e.lngLat.lng,e.lngLat.lat],radius_m:radius});tool('');}
|
map.on('click',e=>{if(mode==='circle'){const radius=data.draft?.geometry?.radius_m||500;emit('rid-fence-geometry',{type:'circle',center:[e.lngLat.lng,e.lngLat.lat],radius_m:radius});tool('');}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -4,28 +4,30 @@ let rows = [], selected = null, busy = false, pending = false, dirty = false, in
|
|||||||
const defaults = {enabled:false,transport:'serial',format:'raw',serialPort:'',baudRate:115200,bindIp:'127.0.0.1',port:8788};
|
const defaults = {enabled:false,transport:'serial',format:'raw',serialPort:'',baudRate:115200,bindIp:'127.0.0.1',port:8788};
|
||||||
const protocols = {'raw':'原始诊断','uid-json':'UID JSON','rid-device-json':'RID / uav','json-lines':'约定 JSON','postcard':'Postcard'};
|
const protocols = {'raw':'原始诊断','uid-json':'UID JSON','rid-device-json':'RID / uav','json-lines':'约定 JSON','postcard':'Postcard'};
|
||||||
function state(row) {
|
function state(row) {
|
||||||
const s=row.status;
|
const s=row.status||{};
|
||||||
if(s?.notice)return s.notice;
|
if(!row.config?.enabled)return !row.detector&&row.deviceKind?'其他串口 · 未当作侦测机':'未启用';
|
||||||
if(!row.detector && row.deviceKind && !row.config.enabled)return '其他串口 · 未当作侦测机';
|
|
||||||
if(!row.config.enabled)return '未启用';
|
|
||||||
if(s.state==='disconnected')return '连接失败 · 自动重试';
|
if(s.state==='disconnected')return '连接失败 · 自动重试';
|
||||||
if(s.state==='connecting')return '正在连接';
|
if(s.state==='connecting'||s.state==='stopped')return '正在连接';
|
||||||
|
if(s.notice)return s.notice;
|
||||||
if(!s.receivedBytes)return row.detector?'侦测串口已连接 · 还没有数据':'已连接 · 等待数据';
|
if(!s.receivedBytes)return row.detector?'侦测串口已连接 · 还没有数据':'已连接 · 等待数据';
|
||||||
if(Date.now()-(s.lastDataMs||0)>10000)return '连接中 · 暂无新数据';
|
if(typeof s.lastDataMs==='number'&&Date.now()-s.lastDataMs>10000)return '连接中 · 暂无新数据';
|
||||||
if(row.config.format==='raw')return '接收中 · 原始诊断';
|
if(row.config.format==='raw')return '接收中 · 原始诊断';
|
||||||
if(s.rejectedFrames && !s.decodedFrames)return '收到数据 · 协议不匹配';
|
if(s.rejectedFrames&&!s.decodedFrames)return '收到数据 · 协议不匹配';
|
||||||
if(!s.acceptedObservations)return '正在接收 · 暂无有效目标';
|
if(!s.acceptedObservations)return '正在接收 · 暂无有效目标';
|
||||||
return '正在接收 · 已解析目标';
|
return '正在接收 · 已解析目标';
|
||||||
}
|
}
|
||||||
const GB_NOTE='这台设备收到了报文,但帧头不符合它自己的 GB46750 要求,所以不会生成目标。';
|
const GB_NOTE='这台设备收到了报文,但帧头不符合它自己的 GB46750 要求,所以不会生成目标。';
|
||||||
const UID_NOTE='坐标系待核实 · 原始坐标在目标详情中查看';
|
const UID_NOTE='坐标系待核实 · 原始坐标在目标详情中查看';
|
||||||
let popFor=null;
|
let popFor=null;
|
||||||
|
function linkUp(row){const state=row.status?.state;return state==='serial-open'||state==='udp-listening'||state==='tcp-listening';}
|
||||||
function tone(row){
|
function tone(row){
|
||||||
if(!row.config?.enabled)return 'idle';
|
if(!row.config?.enabled)return 'idle';
|
||||||
const s=row.status||{};
|
const s=row.status||{};
|
||||||
if(s.notice||s.state==='disconnected')return 'warn';
|
if(s.state==='disconnected')return 'warn';
|
||||||
if(s.state==='connecting'||s.state==='stopped'||!s.receivedBytes)return 'info';
|
if(s.state==='connecting'||s.state==='stopped')return 'info';
|
||||||
if(Date.now()-(s.lastDataMs||0)>10000)return 'info';
|
if(s.notice)return 'warn';
|
||||||
|
if(!s.receivedBytes)return 'info';
|
||||||
|
if(typeof s.lastDataMs==='number'&&Date.now()-s.lastDataMs>10000)return 'info';
|
||||||
if(row.config.format==='raw')return 'ok';
|
if(row.config.format==='raw')return 'ok';
|
||||||
if(s.rejectedFrames&&!s.decodedFrames)return 'warn';
|
if(s.rejectedFrames&&!s.decodedFrames)return 'warn';
|
||||||
if(!s.acceptedObservations)return 'info';
|
if(!s.acceptedObservations)return 'info';
|
||||||
@@ -34,14 +36,28 @@ function tone(row){
|
|||||||
function cardStatus(row){return row.config?.enabled?state(row):'未启用';}
|
function cardStatus(row){return row.config?.enabled?state(row):'未启用';}
|
||||||
function roleLabel(row){if(row.config.transport!=='serial')return '网络';if(row.detector)return '侦测机';if(row.deviceKind)return '其他串口';return '接收机';}
|
function roleLabel(row){if(row.config.transport!=='serial')return '网络';if(row.detector)return '侦测机';if(row.deviceKind)return '其他串口';return '接收机';}
|
||||||
function identity(row){
|
function identity(row){
|
||||||
const name=row.name||'未命名接收机',cut=name.indexOf(' · ');
|
const name=row.name||'未命名接收机',socket=row.devicePlace||'';
|
||||||
const head=cut<0?name:name.slice(0,cut);
|
if(socket&&(name===socket||name.endsWith(` · ${socket}`))){
|
||||||
let place=cut<0?'':name.slice(cut+3);
|
const head=name===socket?name:name.slice(0,name.length-socket.length-3);
|
||||||
if(!place)place=row.devicePlace||(row.config.transport==='serial'?'—':'网络 · 手动添加');
|
return {head:head||name,place:socket};
|
||||||
return {head,place};
|
}
|
||||||
|
if(row.deviceKind&&(name===row.deviceKind||name.startsWith(`${row.deviceKind} · `))){
|
||||||
|
const rest=name===row.deviceKind?'':name.slice(row.deviceKind.length+3);
|
||||||
|
return {head:row.deviceKind,place:socket||rest||'—'};
|
||||||
|
}
|
||||||
|
if(socket)return {head:name,place:socket};
|
||||||
|
if(row.config.transport!=='serial')return {head:name,place:'网络 · 手动添加'};
|
||||||
|
const cut=name.indexOf(' · ');
|
||||||
|
return cut<0?{head:name,place:'—'}:{head:name.slice(0,cut),place:name.slice(cut+3)};
|
||||||
}
|
}
|
||||||
function endpoint(row){const c=row.config;return c.transport==='serial'?`${c.serialPort||'尚未选择串口'} · ${c.baudRate}`:`${c.transport==='udp'?'UDP':'TCP'} · ${c.bindIp}:${c.port}`;}
|
function endpoint(row){const c=row.config;return c.transport==='serial'?`${c.serialPort||'尚未选择串口'} · ${c.baudRate}`:`${c.transport==='udp'?'UDP':'TCP'} · ${c.bindIp}:${c.port}`;}
|
||||||
function faults(row){const list=[];if(row.status?.lastError)list.push(row.status.lastError);if(row.status?.notice)list.push(GB_NOTE);if(row.config.format==='uid-json')list.push(UID_NOTE);return list;}
|
function faults(row){
|
||||||
|
const list=[],s=row.status||{},enabled=!!row.config?.enabled;
|
||||||
|
if(enabled&&s.lastError&&!linkUp(row))list.push(s.lastError);
|
||||||
|
if(enabled&&s.notice)list.push(linkUp(row)?GB_NOTE:`${s.notice}。${GB_NOTE}`);
|
||||||
|
if(row.config?.format==='uid-json')list.push(UID_NOTE);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
function closePop(){popFor=null;const pop=$('rx-pop');if(pop)pop.hidden=true;}
|
function closePop(){popFor=null;const pop=$('rx-pop');if(pop)pop.hidden=true;}
|
||||||
function placePop(anchor){
|
function placePop(anchor){
|
||||||
const pop=$('rx-pop');if(!pop||pop.hidden||!anchor)return;
|
const pop=$('rx-pop');if(!pop||pop.hidden||!anchor)return;
|
||||||
@@ -95,7 +111,7 @@ async function refresh(){if(pending||!$('rx-cards'))return;pending=true;try{cons
|
|||||||
async function mutate(action){if(busy)return;busy=true;render();try{await action();await refresh();}catch(e){$('rx-error').hidden=false;$('rx-error').textContent=e.message;if($('rx-drawer').open)$('rx-message').textContent=e.message;}finally{busy=false;render();}}
|
async function mutate(action){if(busy)return;busy=true;render();try{await action();await refresh();}catch(e){$('rx-error').hidden=false;$('rx-error').textContent=e.message;if($('rx-drawer').open)$('rx-message').textContent=e.message;}finally{busy=false;render();}}
|
||||||
function fields(){const f=$('rx-form');$('rx-serial-fields').hidden=f.elements.transport.value!=='serial';$('rx-network-fields').hidden=f.elements.transport.value==='serial';$('rx-protocol-note').textContent=f.elements.format.value==='uid-json'?'UID 报文中的坐标系代码尚未核实:显示原始坐标,不在地图落点、不参与围栏。':f.elements.format.value==='raw'?'原始诊断只接收字节,不生成无人机目标。':'协议必须与设备实际输出一致;未知报文不会猜测为位置。';}
|
function fields(){const f=$('rx-form');$('rx-serial-fields').hidden=f.elements.transport.value!=='serial';$('rx-network-fields').hidden=f.elements.transport.value==='serial';$('rx-protocol-note').textContent=f.elements.format.value==='uid-json'?'UID 报文中的坐标系代码尚未核实:显示原始坐标,不在地图落点、不参与围栏。':f.elements.format.value==='raw'?'原始诊断只接收字节,不生成无人机目标。':'协议必须与设备实际输出一致;未知报文不会猜测为位置。';}
|
||||||
function tab(diagnostic){$('rx-form').hidden=diagnostic;$('rx-diagnostic').hidden=!diagnostic;$('rx-config-tab').setAttribute('aria-pressed',String(!diagnostic));$('rx-diagnostic-tab').setAttribute('aria-pressed',String(diagnostic));diagnostics();}
|
function tab(diagnostic){$('rx-form').hidden=diagnostic;$('rx-diagnostic').hidden=!diagnostic;$('rx-config-tab').setAttribute('aria-pressed',String(!diagnostic));$('rx-diagnostic-tab').setAttribute('aria-pressed',String(diagnostic));diagnostics();}
|
||||||
function diagnostics(){const row=rows.find(r=>r.id===selected);$('rx-status-label').textContent=row?state(row):'保存接收机后可查看诊断';const s=row?.status;const stats=s?[['设备种类',row.deviceKind||'—'],['插口位置',row.devicePlace||'—'],['设备 ID',row.hardwareId||row.id],['接收字节',s.receivedBytes],['解码帧',s.decodedFrames],['接受更新',s.acceptedObservations],['拒绝帧',s.rejectedFrames],['忽略日志',s.ignoredLines],['无效目标',s.invalidTargets],['最近接收',s.lastDataMs?new Date(s.lastDataMs).toLocaleTimeString():'—'],['连接错误',s.lastError||'无']]:[];$('rx-stats').replaceChildren(...stats.flatMap(([k,v])=>[el('dt',k),el('dd',String(v))]));$('rx-capture').disabled=!row;}
|
function diagnostics(){const row=rows.find(r=>r.id===selected);$('rx-status-label').textContent=row?state(row):'保存接收机后可查看诊断';const s=row?.status;const stats=s?[['设备种类',row.deviceKind||'—'],['插口位置',row.devicePlace||'—'],['设备 ID',row.hardwareId||row.id],['接收字节',s.receivedBytes],['解码帧',s.decodedFrames],['接受更新',s.acceptedObservations],['拒绝帧',s.rejectedFrames],['忽略日志',s.ignoredLines],['无效目标',s.invalidTargets],['最近接收',s.lastDataMs?new Date(s.lastDataMs).toLocaleTimeString():'—'],['连接错误',s.lastError||'无'],...(s.notice?[['帧头提示',s.notice]]:[])]:[];$('rx-stats').replaceChildren(...stats.flatMap(([k,v])=>[el('dt',k),el('dd',String(v))]));$('rx-capture').disabled=!row;}
|
||||||
function open(row){closePop();selected=row?.id||null;dirty=false;$('rx-title').textContent=row?.name||'添加接收机';$('rx-message').textContent='';$('rx-raw').textContent='尚未读取。最多显示最近 4 KiB。';const f=$('rx-form'),config=row?.config||defaults;f.elements.name.value=row?.name||'';for(const [key,value] of Object.entries(config)){if(key==='enabled')f.elements[key].checked=value;else f.elements[key].value=value;}$('rx-delete').hidden=!selected||selected==='default';fields();tab(false);$('rx-drawer').showModal();f.elements.name.focus();api('/api/receiver/ports').then(v=>$('rx-port-options').replaceChildren(...v.ports.map(p=>{const o=el('option');o.value=p;return o;}))).catch(()=>{});}
|
function open(row){closePop();selected=row?.id||null;dirty=false;$('rx-title').textContent=row?.name||'添加接收机';$('rx-message').textContent='';$('rx-raw').textContent='尚未读取。最多显示最近 4 KiB。';const f=$('rx-form'),config=row?.config||defaults;f.elements.name.value=row?.name||'';for(const [key,value] of Object.entries(config)){if(key==='enabled')f.elements[key].checked=value;else f.elements[key].value=value;}$('rx-delete').hidden=!selected||selected==='default';fields();tab(false);$('rx-drawer').showModal();f.elements.name.focus();api('/api/receiver/ports').then(v=>$('rx-port-options').replaceChildren(...v.ports.map(p=>{const o=el('option');o.value=p;return o;}))).catch(()=>{});}
|
||||||
function close(){if(dirty&&!confirm('尚有未保存的配置,放弃修改并关闭?'))return;$('rx-drawer').close();selected=null;dirty=false;}
|
function close(){if(dirty&&!confirm('尚有未保存的配置,放弃修改并关闭?'))return;$('rx-drawer').close();selected=null;dirty=false;}
|
||||||
function init(){if(initialized||!$('rx-cards'))return;initialized=true;$('rx-add').onclick=()=>open(null);$('rx-refresh').onclick=refresh;$('rx-search').oninput=render;$('rx-close').onclick=close;$('rx-drawer').addEventListener('cancel',e=>{e.preventDefault();close();});$('rx-form').oninput=()=>{dirty=true;fields();};$('rx-form').onchange=()=>{dirty=true;fields();};$('rx-config-tab').onclick=()=>tab(false);$('rx-diagnostic-tab').onclick=()=>tab(true);
|
function init(){if(initialized||!$('rx-cards'))return;initialized=true;$('rx-add').onclick=()=>open(null);$('rx-refresh').onclick=refresh;$('rx-search').oninput=render;$('rx-close').onclick=close;$('rx-drawer').addEventListener('cancel',e=>{e.preventDefault();close();});$('rx-form').oninput=()=>{dirty=true;fields();};$('rx-form').onchange=()=>{dirty=true;fields();};$('rx-config-tab').onclick=()=>tab(false);$('rx-diagnostic-tab').onclick=()=>tab(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user