Files
ucvl-home-vision/web/ui/assets/tv-BLhSIH0H.js
T

2 lines
12 KiB
JavaScript
Raw Normal View History

import"./modulepreload-polyfill-B5Qt9EMX.js";import{w as ve,f as de,g as he,o as i,c,a as e,e as B,t as n,u as V,h as _,F as U,j as R,i as me,B as ye,k as Y,l as C,r as S,n as ie,K as ge}from"./FamilyMap-CoPJzTbz.js";function pe(v){const r=Object.fromEntries(new Intl.DateTimeFormat("en-GB",{timeZone:"Asia/Shanghai",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"}).formatToParts(v).map(k=>[k.type,k.value])),h=new Date(Date.UTC(+r.year,+r.month-1,+r.day)),m=h.getUTCDay(),g=new Date(h);g.setUTCDate(h.getUTCDate()+4-(m||7));const T=new Date(Date.UTC(g.getUTCFullYear(),0,1));return{...r,weekday:"星期"+"日一二三四五六"[m],week:Math.ceil(((g-T)/864e5+1)/7),weekYear:g.getUTCFullYear(),date:`${r.year}-${r.month}-${r.day}`}}const ue=v=>v===0?"晴":v<=3?"多云":v<=48?"有雾":v<=67?"有雨":v<=77?"有雪":v<=82?"阵雨":v<=86?"阵雪":v>=95?"雷雨":"天气更新中",j="zhao.display",Z=v=>typeof v=="string"&&/^[A-Za-z0-9_-]{43}$/.test(v);function fe({fetcher:v=fetch,storage:r=localStorage,url:h=location,historyApi:m=history,onChange:g,later:T=setTimeout,cancel:k=clearTimeout,now:P=Date.now}={}){let d="",D=0,$,w,p=!1,f=0,o={data:null,error:"",authRequired:!1,loading:!1,lastSync:0};const b=l=>{o={...o,...l},g({...o})},L=()=>{try{return r.getItem(j)||""}catch(l){return""}},I=l=>{try{l?r.setItem(j,l):r.removeItem(j)}catch(M){}};function N(){D++,k($),w==null||w.abort()}function x(l){if(!p&&(N(),d=Z(l)?l:"",I(d),f=0,b({data:null,lastSync:0,error:d?"":"请在家庭的显示终端管理中获取配对码,完成绑定。",authRequired:!d,loading:!!d}),d))return E()}function F(){const l=new URLSearchParams(h.hash.slice(1));if(!l.has("display"))return!1;const M=l.get("display");l.delete("display");try{m.replaceState(null,"",h.pathname+h.search+(l.toString()?"#"+l.toString():""))}catch(u){}return x(M),!0}async function E(){if(p||!d)return;k($);const l=++D,M=d;w==null||w.abort();const u=new AbortController;w=u;const O=T(()=>u.abort(),12e3);b({loading:!0});try{const y=await v("/api/display/snapshot",{headers:{Authorization:"Bearer "+M},signal:u.signal,cache:"no-store"}),A=await y.json();if(p||l!==D)return;if(y.status===401||y.status===403){const q=L();if(Z(q)&&q!==M){x(q);return}d="",I(""),b({data:null,lastSync:0,error:A.error||"展示授权已失效,请重新连接显示终端。",authRequired:!0});return}if(!y.ok)throw Error(A.error||"暂时无法同步家庭资料");f=0,b({data:A,error:"",authRequired:!1,lastSync:P()})}catch(y){!p&&l===D&&(f++,b({error:y.name==="AbortError"?"家庭连接暂时超时":y.message||"家庭连接暂时中断"}))}finally{k(O),!p&&l===D&&(b({loading:!1}),d&&($=T(E,Math.min(12e4,3e4*Math.max(1,f)))))}}return{start(){if(!F())return x(L())},hashChanged:F,storageChanged(l){if(l.key===j||l.key===null)return x(L())},retry(){if(F())return;const l=L();return Z(l)&&l!==d?x(l):d?E():x("")},stop(){p=!0,N()}}}const _e={class:"tv-shell"},ke={class:"tv-top"},we={key:0,class:"tv-reconnect",role:"alert"},be=["disabled"],xe={class:"tv-upper"},Ce={class:"square-clock","aria-label":"北京时间时钟"},Te=["aria-label"],De=["transform"],Se=["y1","y2"],Ee=["x","y"],Le=["transform"],Me=["transform"],$e=["transform"],Fe={x:"220",y:"303",class:"digital-time"},qe={class:"tv-home"},Ie={class:"tv-greeting"},Ae={class:"tv-date"},ze={class:"tv-date-extra"},Be={key:0},Ue={class:"tv-weather tv-card","aria-label":"天气"},Re={class:"weather-current"},Pe={class:"section-label"},Ne={class:"weather-big"},Ye={class:"weather-symbol"},je={key:0},Oe={class:"weather-note"},Ve={key:0,class:"weather-forecast"},Ze={class:"tv-bottom"},Ge={class:"tv-card tv-devices"},Ke={class:"tv-section-heading"},He={class:"tv-device-grid"},Je={class:"device-emblem"},Qe={key:0,class:"tv-empty"},We={key:0,class:"tv-page-count"},Xe={class:"tv-family-presence tv-card"},et={key:0},tt={key:2,class:"tv-positions"},at={key:0},st={key:0},nt={class:"tv-footer"},lt={key:0,class:"sync-error"},ot={__name:"Television",setup(v){const r=S(null),h=S(Date.now()),m=S(""),g=S(0),T=S(0),k=S(0),P=S(!1),d=S(!1),D=S(!1