fix: TV RTSP compatibility and adaptive colorful day-night clock
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
<script setup>
|
||||
import {ref,computed,onMounted,onBeforeUnmount} from 'vue'
|
||||
import {ref,computed,watch,onMounted,onBeforeUnmount} from 'vue'
|
||||
import {chinaParts,weatherLabel} from './time.mjs'
|
||||
const data=ref(null),clock=ref(Date.now()),error=ref(''),lastSync=ref(0),paging=ref(0),offset=ref(0),fullscreen=ref(false)
|
||||
let poll,tick,cycle,controller,token='',failures=0,wake
|
||||
try {const found=new URLSearchParams(location.hash.slice(1)).get('display');if(found){localStorage.setItem('zhao.display',found);history.replaceState(null,'',location.pathname)} token=localStorage.getItem('zhao.display')||''}catch{}
|
||||
const time=computed(()=>chinaParts(new Date(clock.value+offset.value)))
|
||||
const night=computed(()=>+time.value.hour>=20||+time.value.hour<7)
|
||||
const clockColor=n=>(night.value?['#978469','#739486','#8299aa','#ab8278']:['#ee8a25','#148a7e','#2585cb','#d44e6b'])[n%4]
|
||||
watch(night,value=>document.documentElement.dataset.theme=value?'night':'day',{immediate:true})
|
||||
const lunar=computed(()=>{try{return new Intl.DateTimeFormat('zh-CN-u-ca-chinese',{timeZone:'Asia/Shanghai',month:'long',day:'numeric'}).format(new Date(clock.value+offset.value))}catch{return ''}})
|
||||
const greeting=computed(()=>+time.value.hour<6?'夜深了,愿你好梦':+time.value.hour<11?'早安,新的一天':+time.value.hour<14?'午安,慢慢生活':+time.value.hour<18?'午后,家有暖意':'晚安时光,灯火可亲')
|
||||
const angles=computed(()=>({hour:(+time.value.hour%12)*30+(+time.value.minute)/2,minute:(+time.value.minute)*6,second:(+time.value.second)*6}))
|
||||
@@ -31,8 +34,8 @@ onBeforeUnmount(()=>{clearTimeout(poll);clearInterval(tick);clearInterval(cycle)
|
||||
<div class="tv-upper">
|
||||
<section class="square-clock" aria-label="北京时间时钟">
|
||||
<svg viewBox="0 0 440 440" role="img" :aria-label="`${time.hour}:${time.minute}:${time.second}`">
|
||||
<g v-for="n in 60" :key="n" :transform="`rotate(${n*6} 220 220)`"><line x1="220" :y1="n%5===0?29:32" x2="220" :y2="n%5===0?46:39" :class="n%5===0?'hour-mark':'minute-mark'"/></g>
|
||||
<text v-for="n in 12" :key="'n'+n" :x="220+148*Math.sin(n*Math.PI/6)" :y="220-148*Math.cos(n*Math.PI/6)+10" class="clock-number">{{n}}</text>
|
||||
<g v-for="n in 60" :key="n" :transform="`rotate(${n*6} 220 220)`"><line x1="220" :y1="n%5===0?29:32" x2="220" :y2="n%5===0?46:39" :style="n%5===0?{stroke:clockColor(n/5)}:{}" :class="n%5===0?'hour-mark':'minute-mark'"/></g>
|
||||
<text v-for="n in 12" :key="'n'+n" :x="220+148*Math.sin(n*Math.PI/6)" :y="220-148*Math.cos(n*Math.PI/6)+10" :style="{fill:clockColor(n)}" class="clock-number">{{n}}</text>
|
||||
<text x="220" y="140" class="clock-word">家 · 在 此 刻</text>
|
||||
<line x1="220" y1="231" x2="220" y2="127" class="clock-hour" :transform="`rotate(${angles.hour} 220 220)`"/>
|
||||
<line x1="220" y1="234" x2="220" y2="91" class="clock-minute" :transform="`rotate(${angles.minute} 220 220)`"/>
|
||||
@@ -49,9 +52,8 @@ onBeforeUnmount(()=>{clearTimeout(poll);clearInterval(tick);clearInterval(cycle)
|
||||
</section>
|
||||
<div class="tv-bottom">
|
||||
<section class="tv-card tv-devices"><div class="tv-section-heading"><h2>家中设备</h2><span>{{data?.home.deviceCount??'—'}} 台 · {{data?.home.spaces??'—'}} 处区域</span></div><div class="tv-device-grid"><article v-for="d in devices" :key="d.id" class="tv-device"><div class="device-emblem">{{/电视|显示/.test(d.type)?'▣':/摄像/.test(d.type)?'◉':/路由|网关/.test(d.type)?'⌁':'◇'}}</div><div><h3>{{d.name}}</h3><p>{{d.location}}</p><span :class="['tv-status',d.status]"><i></i>{{d.statusLabel}}</span></div></article><div class="tv-empty" v-if="!devices.length">设备接入后,会在这里与你见面。</div></div><div class="tv-page-count" v-if="(data?.devices.length||0)>4">设备分组自动轮换 · 每 15 秒</div></section>
|
||||
<section class="tv-card tv-agenda"><div class="tv-section-heading"><h2>近期日程</h2><span>未来 60 天</span></div><div v-if="!data?.events.length" class="agenda-empty"><span class="agenda-line">日子从容,家有余闲。</span><p>暂没有已发布的家庭安排</p></div><article v-for="e in data?.events.slice(0,3)" :key="e.id" class="tv-event"><time>{{e.date.slice(5).replace('-',' / ')}}</time><h3>{{e.title}}</h3></article><div class="agenda-source">来自本家庭已发布的重大记事</div></section>
|
||||
<section class="tv-family-presence tv-card"><div><h2>家人位置</h2><p>等待家人主动开启位置共享</p></div><span>共享关闭</span></section>
|
||||
</div>
|
||||
<section class="tv-family-presence tv-card"><div><h2>家人位置</h2><p>等待家人主动开启位置共享</p></div><span>共享关闭</span></section>
|
||||
<footer class="tv-footer"><span :class="{warning:!!error}"><i></i>{{syncLabel}}</span><span v-if="error" class="sync-error">{{error}}</span><span>愿每个平常日,都有家的温度</span><a href="https://open-meteo.com/" target="_blank" rel="noreferrer">天气 Open-Meteo</a></footer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -4,5 +4,8 @@
|
||||
@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important;animation:none!important;transition:none!important}}
|
||||
@media (max-aspect-ratio: 1/1) and (min-width:601px){.tv-shell{gap:1.4vh;padding-top:1.8vh;padding-bottom:1.2vh}.square-clock{width:31vh}.tv-upper{gap:1.3vh}.tv-home h1{margin-bottom:.7vh}.tv-weather{min-height:11.8vh}.tv-bottom{gap:1.2vh}.tv-card{padding:1.4vh 2vw}.tv-device{min-height:5.1vh;padding:.7vh 1vw}.tv-section-heading{margin-bottom:.9vh}.tv-greeting{margin-bottom:.5vh}.tv-agenda{padding-top:1.2vh;padding-bottom:1.2vh}}
|
||||
.tv-family-presence{display:flex;align-items:center;justify-content:space-between;gap:1vw;padding:1vh 2vw}.tv-family-presence h2{font-size:1.5vh;margin:0 0 .4vh}.tv-family-presence p{font-size:1.05vh;margin:0;color:#8b8b78}.tv-family-presence>span{font-size:1vh;color:#8b8b78;border:1px solid #ddd8c8;padding:.4vh .8vw;border-radius:.6vh}
|
||||
@media(max-aspect-ratio:1/1) and (min-width:601px){.square-clock{width:27vh}.tv-shell{gap:1.2vh}.tv-weather{min-height:10vh}.tv-home h1{font-size:3.1vh}}
|
||||
@media(max-aspect-ratio:1/1) and (min-width:601px){.square-clock{width:23vh}.tv-shell{gap:1vh;padding-top:1.2vh}.tv-weather{min-height:9vh}.tv-home h1{font-size:3.1vh}.tv-card{padding:1vh 2vw}.tv-agenda{padding:.8vh 2vw}.tv-family-presence{padding:.6vh 2vw}.agenda-source{display:none}.tv-device{padding:.6vh 1vw;min-height:4.8vh}.tv-date-extra{font-size:1.15vh}}
|
||||
@media(min-aspect-ratio:1/1){.square-clock{width:30vh}.tv-shell{gap:1.7vh}.tv-upper{gap:5vw}.tv-weather{min-height:12vh}.tv-family-presence{padding:.8vh 2vw}}
|
||||
[data-theme=night] body{background:#141c18;color:#b7bead}[data-theme=night] .tv-shell{background:radial-gradient(ellipse at 85% 5%,#252b2044,transparent 60%),#141c18}[data-theme=night] .square-clock{background:#1c251f;border-color:#354034;box-shadow:0 1vh 4vh #0003,inset 0 0 0 .6vh #202a22}[data-theme=night] .clock-number{fill:#9ba58d}[data-theme=night] .hour-mark{stroke:#788169}[data-theme=night] .minute-mark{stroke:#434e3e}[data-theme=night] .clock-hour{stroke:#b2bda1}[data-theme=night] .clock-minute{stroke:#899a78}[data-theme=night] .digital-time{fill:#a9b497}[data-theme=night] .clock-second{stroke:#9b7653}[data-theme=night] .tv-card{background:#1d2821;border-color:#303e32;box-shadow:none}[data-theme=night] .tv-device{background:#253128}[data-theme=night] .device-emblem{background:#334132;color:#9aa98b}[data-theme=night] .tv-home h1{color:#b3bca4}[data-theme=night] .tv-status.online{color:#94a682}[data-theme=night] .weather-forecast{border-color:#3b4938}[data-theme=night] .weather-symbol{opacity:.55}[data-theme=night] .tv-fullscreen,[data-theme=night] .tv-top{color:#929d85}[data-theme=night] .tv-family-presence>span{border-color:#41513d}[data-theme=night] .tv-brand img{opacity:.65}
|
||||
@media(max-aspect-ratio:1/1) and (min-width:601px){.tv-shell{height:100vh;min-height:100vh;padding:1vh 3vw .6vh;gap:.7vh}.tv-upper{gap:.5vh;padding:0}.square-clock{width:min(94vw,56vh);max-width:100%;border-radius:3.4vh;padding:.7vh}.tv-home h1{font-size:2.4vh;margin:0 0 .35vh}.tv-greeting{display:none}.tv-date{font-size:1.5vh}.tv-date-extra{font-size:1vh;margin-top:.3vh}.tv-card{padding:.7vh 1.7vw}.tv-weather{min-height:8vh}.weather-big strong{font-size:3.8vh}.weather-big b{font-size:1.4vh}.weather-symbol{font-size:3vh}.weather-note{font-size:.8vh}.weather-forecast>div{gap:.6vh}.tv-device-grid{grid-template-columns:repeat(3,minmax(0,1fr));gap:.8vw}.tv-device{min-height:4.7vh;padding:.5vh .8vw;gap:.6vw}.tv-device h3{font-size:1.1vh}.tv-device p{font-size:.8vh}.tv-status{font-size:.85vh}.device-emblem{width:2.3vh;height:2.3vh;font-size:1.5vh}.tv-section-heading h2{font-size:1.3vh}.tv-section-heading{margin-bottom:.5vh}.tv-family-presence h2{font-size:1.3vh}.tv-family-presence p{font-size:.9vh}.tv-bottom{gap:.7vh}.tv-footer{font-size:.7vh}}
|
||||
[data-theme=day] .clock-hour{stroke:#167f98}[data-theme=day] .clock-minute{stroke:#169881}[data-theme=day] .clock-second{stroke:#e05260}
|
||||
|
||||
Reference in New Issue
Block a user