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

2 lines
12 KiB
JavaScript
Raw Normal View History

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