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

2 lines
9.4 KiB
JavaScript
Raw Normal View History

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