perf: streamline rule settings reads and local save updates

This commit is contained in:
abaishu0730 committed 2026-10-27 18:13:22 +08:00
1 parent 39ece1920a
commit 649a0df832
20 files changed
+384 -45

No files matched your search

+4 -3
View File
@@ -18,7 +18,7 @@ async function api(route,body,{signal,ownerCheck,managedOutcome=false}={}) {
}
async function verifyUncertainWrite(route,isActive){
const resource=route.startsWith('/order-rules/field-mappings/')||route==='/order-rules/field-samples/capture'?['/order-rules/fields','processes']:route.startsWith('/order-execution')?['/order-execution','tasks']:route.startsWith('/order-rules')?['/order-rules','rules']:route.startsWith('/assistant')?['/assistant','settings']:route.startsWith('/mail')?['/mail','channels']:route.startsWith('/storage')?['/storage','servers']:route==='/settings'?['/settings','schedule']:route==='/calendar'?['/workspace','calendar']:route.startsWith('/connections')?['/workspace','connections']:route.startsWith('/exceptions')?['/workspace','exceptions']:route.startsWith('/users')?['/users','users']:route==='/account/password'?['/me','user']:['/overview','stats'];
const resource=route.startsWith('/order-rules/field-mappings/')||route==='/order-rules/field-samples/capture'?['/order-rules/fields','processes']:route.startsWith('/order-execution')?['/order-execution','tasks']:(route.startsWith('/order-rules/rules')||route==='/order-rules/restricted-test/apply')?['/order-rules/configuration','rules']:route.startsWith('/order-rules')?['/order-rules','rules']:route.startsWith('/assistant')?['/assistant','settings']:route.startsWith('/mail')?['/mail','channels']:route.startsWith('/storage')?['/storage','servers']:route==='/settings'?['/settings','schedule']:route==='/calendar'?['/workspace','calendar']:route.startsWith('/connections')?['/workspace','connections']:route.startsWith('/exceptions')?['/workspace','exceptions']:route.startsWith('/users')?['/users','users']:route==='/account/password'?['/me','user']:['/overview','stats'];
const panel=document.querySelector('#content');if(!isActive()||!panel)return;let alert=panel.querySelector('#operation-uncertain');if(!alert){alert=document.createElement('div');alert.id='operation-uncertain';alert.className='alert alert-warning';alert.setAttribute('role','alert');panel.prepend(alert);}const prefix='结果待核实:请求超时或连接中断;不会自动重试。';alert.textContent=prefix+' 正在查询状态。';
if(route==='/order-rules/field-samples/list'){alert.textContent='待办列表读取结果待确认,请使用读取按钮核实同次请求;系统不会归档、发信或办理节点。';return;}
const controller=new AbortController(),timeout=setTimeout(()=>controller.abort(),8000),unregister=window.PageLifecycle?.onDispose(()=>controller.abort());
@@ -106,11 +106,12 @@ async function updateAutomationStatus(isActive){
const request=++automationRevision,node=document.querySelector('#automation-status');if(!node||!isActive())return;
const apply=(label,color,detail)=>{if(!isActive()||request!==automationRevision||!node.isConnected)return;node.textContent=label;node.className='badge bg-'+color+'-lt text-decoration-none';node.title=detail;};
try{
const data=await api('/order-rules?view=summary',undefined,{ownerCheck:isActive});if(!isActive())return;
const lightweight=currentView==='order-rules',data=await api(lightweight?'/order-rules/status':'/order-rules?view=summary',undefined,{ownerCheck:isActive});if(!isActive())return;
if(typeof data?.settings?.enabled!=='boolean')throw Error('服务端未返回有效通知开关');
const missing=Object.entries({liveTodo:'实时待办接入',pdfExport:'PDF 导出',automaticArchive:'自动归档'}).filter(([key])=>data.capabilities?.[key]!==true).map(([,label])=>label);
if(!data.settings.enabled)apply('自动通知已暂停','secondary','自动发信保持暂停;请完成类别字段、目录、邮箱与预览核验。'+(missing.length?' 待检查:'+missing.join('、'):' 点击查看发送设置。'));
else if(missing.length&&data.capabilities?.liveTodo===true&&data.counts?.orders===0&&!(data.scans||[]).some(scan=>scan.status==='failed'))apply('自动通知待验证','yellow','当前没有匹配订单;'+missing.join('、')+'尚待实际业务验证。匹配订单到达后按流程核验。');
else if(missing.length&&lightweight)apply('自动通知待核验','yellow','部分接入能力尚待核验,请到通知总览查看实际订单和阻塞详情。');
else if(missing.length&&data.capabilities?.liveTodo===true&&data.counts?.orders===0&&!(data.scans||[]).some(scan=>scan.status==='failed'))apply('自动通知待验证','yellow','当前没有匹配订单;'+missing.join('、')+'尚待实际业务验证。匹配订单到达后按流程核验。');
else if(missing.length)apply('自动通知受阻','yellow','未通过实际检查:'+missing.join('、')+'。点击查看发送设置。');
else apply('自动通知已启用','green','通知开关已启用;实际任务、类别及批次仍按各自检查结果执行。');
}catch(error){apply('通知状态待确认','yellow',error.message+';请刷新重试。');}