'use strict'; let deviceContext=null,scopeEntered=false; Object.assign(pageInfo,{overview:['场所总览','人、区域与设备,在这里各有归属。'],device:['设备档案','查看这台设备的位置、责任人与功能。'],heritage:['家庭传承','把人物、记忆、文化与物品的来历留存下来。']}); function currentHome(){return (state.households||[]).find(h=>h.id===state.familyId);} function selectedDevice(){return deviceContext?ZhaoDevices.catalog(state).find(d=>d.id===deviceContext.id&&d.source===deviceContext.source):null;} function deviceCameras(cameras,context=deviceContext){ if(!context)return cameras; if(context.source==='camera')return cameras.filter(c=>c.assetId===context.id); if(context.source==='recorder')return cameras.filter(c=>c.recorderId===context.id||c.archiveRecorderId===context.id); return []; } function enterDevice(source,id,tab='device'){ const device=ZhaoDevices.catalog(state).find(d=>d.source===source&&d.id===id); if(!device){toast('该设备不存在或未获授权');return;} stopPlayers();resetPlayback();if(typeof closePtz==='function')closePtz(); $('#site-filter').value='';deviceContext={source,id};scopeEntered=true; showPage(tab==='device'&&source==='camera'&&deviceCameras(state.cameras).length?'live':tab); } function renderSteward(){ const home=currentHome(),device=selectedDevice(),within=loggedIn&&scopeEntered&&!!home; if(deviceContext&&!device&&loggedIn){deviceContext=null;stopPlayers();resetPlayback();showPage('objects');return;} $('#scope-navigation').hidden=!within; $('#scope-nav-name').textContent=home?.name||''; $('#household-context').hidden=!within; $('#household-context-note').textContent=home?scopeKind(home)+' · '+home.name:''; $('#device-context').hidden=!device||!['device','live','playback','cameras'].includes(activePage); $('#wall-context').hidden=activePage!=='live'||!!device; $('#device-breadcrumb').textContent=device?[home?.name,siteName(device.siteId),device.name].filter(Boolean).join(' / '):''; $('#scope-back').textContent='返回 '+(home?.name||'场所'); const hasVideo=device&&['camera','recorder'].includes(device.source); $$('[data-device-tab]').forEach(b=>{b.hidden=b.dataset.deviceTab!=='device'&&(!hasVideo||b.dataset.deviceTab==='cameras'&&!isAdmin());b.classList.toggle('active',b.dataset.deviceTab===activePage);}); if(device&&['device','live','playback','cameras'].includes(activePage)){ $('#page-title').textContent=device.name; $('#page-note').textContent=pageInfo[activePage][0]+' · '+(home?.name||''); } if(activePage==='live')$('#live-heading').textContent=device?'实时画面 · 镜头':'本场所监控墙'; if(activePage==='overview')renderOverview(); if(activePage==='device')renderDeviceDetail(device); if(activePage==='heritage')renderHeritageHome(); const homeKind=!home?.kind||home.kind==='home'; $('nav [data-page="heritage"]').hidden=!homeKind||(!isAdmin()&¤tUser?.familyAccess==='none'&¤tUser?.heritageAccess!=='read'&¤tUser?.heritageAccess!=='edit'); } function renderOverview(){ const home=currentHome();if(!home){$('#scope-overview').replaceChildren();return;} const devices=ZhaoDevices.catalog(state),homeKind=!home.kind||home.kind==='home'; $('#scope-overview').innerHTML=`
${esc(home.note||'从每一处空间,照看每一件事物。')}
${esc(device.note||'')}
${device.source==='device'?'当前已登记档案;自动控制需按实际设备协议接入。
':''}${device.source==='recorder'?'可查看已关联镜头。录像机硬盘的历史检索与回放仍待设备适配。
':''}人物、记事、文化资料与家庭物品分别保存,关联同一个家庭。
文化与财产档案须由家庭管理员另行授权。
'}