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

2 lines
9.8 KiB
JavaScript
Raw Normal View History

import{w as ce,f as ve,g as de,o,c as i,a as e,e as T,t as a,F as D,j as C,h as _,u as ae,k as M,l as y,r as g,n as le,J as he}from"./bootstrap.min-C5Nka04t.js";function me(c){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(c).map(f=>[f.type,f.value])),d=new Date(Date.UTC(+r.year,+r.month-1,+r.day)),v=d.getUTCDay(),h=new Date(d);h.setUTCDate(d.getUTCDate()+4-(v||7));const p=new Date(Date.UTC(h.getUTCFullYear(),0,1));return{...r,weekday:"星期"+"日一二三四五六"[v],week:Math.ceil(((h-p)/864e5+1)/7),weekYear:h.getUTCFullYear(),date:`${r.year}-${r.month}-${r.day}`}}const se=c=>c===0?"晴":c<=3?"多云":c<=48?"有雾":c<=67?"有雨":c<=77?"有雪":c<=82?"阵雨":c<=86?"阵雪":c>=95?"雷雨":"天气更新中",ye={class:"tv-shell"},_e={class:"tv-top"},ge={class:"tv-upper"},pe={class:"square-clock","aria-label":"北京时间时钟"},fe=["aria-label"],ke=["transform"],we=["y1","y2"],be=["x","y"],xe=["transform"],Te=["transform"],De=["transform"],Ce={x:"220",y:"303",class:"digital-time"},Me={class:"tv-home"},Le={class:"tv-greeting"},$e={class:"tv-date"},Fe={class:"tv-date-extra"},Ie={key:0},Se={class:"tv-weather tv-card","aria-label":"天气"},ze={class:"weather-current"},Ee={class:"section-label"},Ue={class:"weather-big"},Be={class:"weather-symbol"},Ae={key:0},Ne={class:"weather-note"},Pe={key:0,class:"weather-forecast"},qe={class:"tv-bottom"},Ye={class:"tv-card tv-devices"},je={class:"tv-section-heading"},Ve={class:"tv-device-grid"},Oe={class:"device-emblem"},Ze={key:0,class:"tv-empty"},Ge={key:0,class:"tv-page-count"},Je={class:"tv-family-presence tv-card"},Re={key:0},He={key:1,class:"tv-positions"},Ke={key:0},Qe={key:0},We={class:"tv-footer"},Xe={key:0,class:"sync-error"},et={__name:"Television",setup(c){const r=g(null),d=g(Date.now()),v=g(""),h=g(0),p=g(0),f=g(0),I=g(!1);let S,z,E,k,w="",L=0,b;try{const s=new URLSearchParams(location.hash.slice(1)).get("display");s&&(localStorage.setItem("zhao.display",s),history.replaceState(null,"",location.pathname)),w=localStorage.getItem("zhao.display")||""}catch(s){}const n=y(()=>me(new Date(d.value+f.value))),U=y(()=>+n.value.hour>=20||+n.value.hour<7),B=s=>(U.value?["#978469","#739486","#8299aa","#ab8278"]:["#ee8a25","#148a7e","#2585cb","#d44e6b"])[s%4];ce(U,s=>document.documentElement.dataset.theme=s?"night":"day",{immediate:!0});const A=y(()=>{try{return new Intl.DateTimeFormat("zh-CN-u-ca-chinese",{timeZone:"Asia/Shanghai",month:"long",day:"numeric"}).format(new Date(d.value+f.value))}catch(s){return""}}),ne=y(()=>+n.value.hour<6?"夜深了,愿你好梦":+n.value.hour<11?"早安,新的一天":+n.value.hour<14?"午安,慢慢生活":+n.value.hour<18?"午后,家有暖意":"晚安时光,灯火可亲"),$=y(()=>({hour:+n.value.hour%12*30+ +n.value.minute/2,minute:+n.value.minute*6,second:+n.value.second*6})),N=y(()=>{var m;const s=((m=r.value)==null?void 0:m.devices)||[],t=p.value%Math.max(1,Math.ceil(s.length/3))*3;return s.slice(t,t+3)}),F=y(()=>{var t;if(d.value-h.value>9e4||v.value)return[];const s=((t=r.value)==null?void 0:t.locations)||[];return s.slice(p.value%Math.max(1,Math.ceil(s.length/3))*3,p.value%Math.max(1,Math.ceil(s.length/3))*3+3)}),oe=s=>s.status==="stale"?"位置更新中断 · 请检查手机":s.position?`${s.position.latitude.toFixed(3)}°, ${s.position.longitude.toFixed(3)}°`:"等待手机定位",u=y(()=>{var s;return(s=r.value)==null?void 0:s.weather}),ie=y(()=>h.value?d.value-h.value>9e4?"网络暂时中断 · 显示上次资料":"家庭资料已同步":"正在连接家庭"),x=s=>typeof s=="number"?Math.round(s):"—";async function P(){if(!w){v.value="请从家庭设备页获取这台电视的展示授权";return}k=new AbortController;const s=setTimeout(()=>k.abort(),12e3);try{const t=await fetch("/api/display/snapshot",{headers:{Authorization:"Bearer "+w},signal:k.signal,cache:"no-store"}),m=await t.json();if(!t.ok)throw(t.status===401||t.status===403)&&(r.value=null,localStorage.