fix: keep orders and batches as independent navigation entries

This commit is contained in:
abaishu0730 committed 2026-10-21 13:47:07 +08:00
1 parent d46370df92
commit d03a4ccd9d
9 files changed
+32 -12

No files matched your search

+2 -2
View File
@@ -104,8 +104,8 @@ async function renderView() {
historyIndex=Number.isInteger(history.state?.appIndex)?history.state.appIndex:historyIndex;history.replaceState({...history.state,appIndex:historyIndex},'',window.RecordState.isRecord(location.hash)?location.hash:'#'+currentView+(['exceptions'].includes(currentView)&&location.hash.includes('?')?location.hash.slice(location.hash.indexOf('?')):''));
const section=window.AppNavigation.sectionFor(currentView);
window.AppNavigation.renderTabs(document.querySelector('#settings-tabs'),{id:currentView,user:currentUser,views,esc});
document.querySelectorAll('[data-view]').forEach(link=>{const active=link.dataset.view===(['notification-orders','notification-batches'].includes(currentView)?currentView:section==='order-notifications'?'notification-batches':section||currentView);link.classList.toggle('active',active);if(active)link.setAttribute('aria-current','page');else link.removeAttribute('aria-current');});
const sectionTitle=section==='order-notifications'?'订单通知管理':views[section]?.[0];
document.querySelectorAll('[data-view]').forEach(link=>{const active=link.dataset.view===(section||currentView);link.classList.toggle('active',active);if(active)link.setAttribute('aria-current','page');else link.removeAttribute('aria-current');});
const sectionTitle=views[section]?.[0];
const breadcrumb=document.querySelector('#view-breadcrumb');breadcrumb.hidden=!section||section===currentView||section==='records';breadcrumb.innerHTML=breadcrumb.hidden?'':`<a href="#${section}" aria-label="返回${sectionTitle}">← ${sectionTitle}</a> <span class="text-secondary"> / ${esc(views[currentView][0])}</span>`;
document.querySelector('#view-title').textContent=views[currentView][0];document.querySelector('#view-description').textContent=views[currentView][1];
const container=document.querySelector('#content');if(!(wasRecord&&['records','records-pdf'].includes(currentView)))container.innerHTML='<div class="card"><div class="card-body text-secondary">正在加载…</div></div>';
+3 -4
View File
@@ -3,8 +3,7 @@ window.AppNavigation=(()=>{
const primary=[['overview','overview'],['notification-orders','file'],['notification-batches','mail'],['tools','spark'],['exceptions','alert'],['business-settings','rules'],['system-settings','settings']];
const groups={
tools:['records','records-pdf','assistant','storage'],
'order-notifications':['notification-orders','notification-batches','schedule'],
'business-settings':['order-rules','rule-fields'],
'business-settings':['order-rules','rule-fields','schedule'],
'system-settings':['bpm','mail','assistant-settings','health','users','audit']
};
const configuration=['schedule','calendar','templates','notification-settings'];
@@ -28,7 +27,7 @@ window.AppNavigation=(()=>{
const routeIcons={records:'history','records-pdf':'file','order-notifications':'overview','notification-execution':'play','notification-orders':'file','notification-batches':'batches','notification-history':'history',schedule:'calendar',calendar:'calendar',templates:'mail','notification-settings':'settings','order-rules':'rules','rule-fields':'fields',bpm:'link',mail:'mail',storage:'batches','assistant-settings':'spark',health:'alert',users:'users',audit:'history'};
const resolve=id=>aliases[id]||id;
const isConfiguration=id=>configuration.includes(resolve(id));
function sectionFor(id){id=resolve(id);if(isConfiguration(id))return 'order-notifications';return Object.keys(groups).find(section=>groups[section].includes(id))||null;}
function sectionFor(id){id=resolve(id);if(isConfiguration(id))return 'business-settings';return Object.keys(groups).find(section=>groups[section].includes(id))||null;}
function icon(name){return `<svg class="navigation-icon" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${icons[name]||icons.settings}"/></svg>`;}
function reveal(container){
const active=container.querySelector('.active');if(!active)return;
@@ -39,7 +38,7 @@ window.AppNavigation=(()=>{
function links(ids,active,{views,esc},labels={}){return ids.map(id=>`<a class="nav-link settings-tab ${active===id?'active':''}" href="${window.RecordState?.href(id)||'#'+id}" ${['records','records-pdf','notification-orders','notification-batches'].includes(id)?'data-record-route="'+id+'"':''} ${active===id?'aria-current="page"':''}>${icon(routeIcons[id])}<span>${esc(labels[id]||views[id][0])}</span></a>`).join('');}
function renderTabs(container,{id,user,views,esc}){
const section=sectionFor(id);container.hidden=!section;
container.className='nav nav-segmented settings-tabs';container.setAttribute('aria-label',section==='tools'?'工具导航':section==='records'?'记录导航':section==='order-notifications'?'订单通知管理导航':section==='business-settings'?'业务设置导航':'系统设置导航');
container.className='nav nav-segmented settings-tabs';container.setAttribute('aria-label',section==='tools'?'工具导航':section==='records'?'记录导航':section==='business-settings'?'业务设置导航':'系统设置导航');
container.innerHTML=section?links(groups[section].filter(item=>item!=='users'||user.role==='admin'),isConfiguration(id)?'schedule':id,{views,esc},{schedule:'通知配置',records:'流程到达记录','records-pdf':'PDF 导出记录'}):'';
reveal(container);
}