fix: TV RTSP compatibility and adaptive colorful day-night clock

This commit is contained in:
Codex
2026-10-16 01:04:49 +08:00
parent 6aa20391b2
commit 292321ea20
11 changed files with 70 additions and 26 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/> <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/> <uses-permission android:name="android.permission.WAKE_LOCK"/>
<application android:label="赵府家庭屏" android:allowBackup="false" android:usesCleartextTraffic="false" android:theme="@android:style/Theme.Material.Light.NoActionBar"> <application android:label="赵府家庭屏" android:allowBackup="false" android:usesCleartextTraffic="true" android:theme="@android:style/Theme.Material.Light.NoActionBar">
<activity android:name=".MainActivity" android:exported="true" android:configChanges="orientation|screenSize|keyboardHidden" android:launchMode="singleTask"> <activity android:name=".MainActivity" android:exported="true" android:configChanges="orientation|screenSize|keyboardHidden" android:launchMode="singleTask">
<intent-filter><action android:name="android.intent.action.MAIN"/><category android:name="android.intent.category.LAUNCHER"/><category android:name="android.intent.category.LEANBACK_LAUNCHER"/></intent-filter> <intent-filter><action android:name="android.intent.action.MAIN"/><category android:name="android.intent.category.LAUNCHER"/><category android:name="android.intent.category.LEANBACK_LAUNCHER"/></intent-filter>
</activity> </activity>
+11
View File
@@ -0,0 +1,11 @@
# Android player libraries
LibVLC Android 3.7.7, Copyright VideoLAN and contributors, LGPL 2.1 or later.
Unmodified shared libraries distributed from Maven Central. Source and build instructions:
https://code.videolan.org/videolan/libvlcjni and https://code.videolan.org/videolan/vlc
License: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
The application source and build script are published with ZhaoVision. Users may rebuild and relink this app with modified library versions for their own use.
Kotlin standard library 2.2.10, Copyright JetBrains, Apache License 2.0.
Source: https://github.com/JetBrains/kotlin/tree/v2.2.10
License: https://www.apache.org/licenses/LICENSE-2.0
+17 -3
View File
@@ -9,6 +9,16 @@ $jdk=Join-Path $ToolRoot 'jdk-staging\jdk-21.0.12.1+1'
$sdk=Join-Path $ToolRoot 'android-sdk' $sdk=Join-Path $ToolRoot 'android-sdk'
$bt=Join-Path $sdk 'build-tools\36.0.0' $bt=Join-Path $sdk 'build-tools\36.0.0'
$android=Join-Path $sdk 'platforms\android-37.0\android.jar' $android=Join-Path $sdk 'platforms\android-37.0\android.jar'
$deps=Join-Path $env:LOCALAPPDATA 'ZhaoDisplay\dependencies'
New-Item -ItemType Directory -Force -Path $deps | Out-Null
$vlcArchive=Join-Path $deps 'libvlc-3.7.7.aar'
if(!(Test-Path -LiteralPath $vlcArchive)){Invoke-WebRequest 'https://repo.maven.apache.org/maven2/org/videolan/android/libvlc-all/3.7.7/libvlc-all-3.7.7.aar' -OutFile $vlcArchive}
if((Get-FileHash -LiteralPath $vlcArchive -Algorithm SHA256).Hash.ToLowerInvariant() -ne 'b48dab96e0e90e34cce3861963500c144a5aadb1b249d501d6a4b104d849e61b'){throw 'LibVLC checksum mismatch'}
Add-Type -AssemblyName System.IO.Compression.FileSystem
$vlc=Join-Path $stage 'libvlc'
[IO.Compression.ZipFile]::ExtractToDirectory($vlcArchive,$vlc)
$kotlin=Join-Path $deps 'kotlin-stdlib-2.2.10.jar'
if(!(Test-Path -LiteralPath $kotlin)){Invoke-WebRequest 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/2.2.10/kotlin-stdlib-2.2.10.jar' -OutFile $kotlin}
$env:JAVA_HOME=$jdk $env:JAVA_HOME=$jdk
$env:Path="$jdk\bin;$env:Path" $env:Path="$jdk\bin;$env:Path"
$build=Join-Path $stage 'build' $build=Join-Path $stage 'build'
@@ -18,15 +28,19 @@ if($LASTEXITCODE){throw 'Resource compilation failed'}
& "$bt\aapt2.exe" link -o "$build\unsigned.apk" -I $android --manifest "$stage\AndroidManifest.xml" --java "$build\generated" "$build\compiled.zip" & "$bt\aapt2.exe" link -o "$build\unsigned.apk" -I $android --manifest "$stage\AndroidManifest.xml" --java "$build\generated" "$build\compiled.zip"
if($LASTEXITCODE){throw 'Resource linking failed'} if($LASTEXITCODE){throw 'Resource linking failed'}
$sources=@((Get-ChildItem "$stage\src","$build\generated" -Recurse -Filter '*.java').FullName) $sources=@((Get-ChildItem "$stage\src","$build\generated" -Recurse -Filter '*.java').FullName)
& "$jdk\bin\javac.exe" -encoding UTF-8 -source 8 -target 8 -cp $android -d "$build\classes" $sources & "$jdk\bin\javac.exe" -encoding UTF-8 -source 8 -target 8 -cp "$android;$vlc\classes.jar;$kotlin" -d "$build\classes" $sources
if($LASTEXITCODE){throw 'Java compilation failed'} if($LASTEXITCODE){throw 'Java compilation failed'}
& "$jdk\bin\jar.exe" cf "$build\classes.jar" -C "$build\classes" . & "$jdk\bin\jar.exe" cf "$build\classes.jar" -C "$build\classes" .
& "$bt\d8.bat" --lib $android --min-api 26 --output "$build\dex" "$build\classes.jar" & "$bt\d8.bat" --lib $android --min-api 26 --output "$build\dex" "$build\classes.jar" "$vlc\classes.jar" $kotlin
if($LASTEXITCODE){throw 'Dex compilation failed'} if($LASTEXITCODE){throw 'Dex compilation failed'}
Copy-Item "$build\unsigned.apk" "$build\with-dex.apk" Copy-Item "$build\unsigned.apk" "$build\with-dex.apk"
Add-Type -AssemblyName System.IO.Compression.FileSystem Add-Type -AssemblyName System.IO.Compression.FileSystem
$zip=[IO.Compression.ZipFile]::Open("$build\with-dex.apk",[IO.Compression.ZipArchiveMode]::Update) $zip=[IO.Compression.ZipFile]::Open("$build\with-dex.apk",[IO.Compression.ZipArchiveMode]::Update)
try{[IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zip,"$build\dex\classes.dex",'classes.dex',[IO.Compression.CompressionLevel]::Optimal) | Out-Null}finally{$zip.Dispose()} try{
[IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zip,"$build\dex\classes.dex",'classes.dex',[IO.Compression.CompressionLevel]::Optimal) | Out-Null
foreach($abi in @('arm64-v8a','armeabi-v7a')){foreach($lib in Get-ChildItem "$vlc\jni\$abi" -Filter '*.so'){[IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zip,$lib.FullName,"lib/$abi/$($lib.Name)",[IO.Compression.CompressionLevel]::Optimal) | Out-Null}}
[IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zip,"$source\THIRD_PARTY.md",'assets/THIRD_PARTY.md',[IO.Compression.CompressionLevel]::Optimal) | Out-Null
}finally{$zip.Dispose()}
& "$bt\zipalign.exe" -f 4 "$build\with-dex.apk" "$build\aligned.apk" & "$bt\zipalign.exe" -f 4 "$build\with-dex.apk" "$build\aligned.apk"
$keydir=Join-Path $env:LOCALAPPDATA 'ZhaoDisplay' $keydir=Join-Path $env:LOCALAPPDATA 'ZhaoDisplay'
New-Item -ItemType Directory -Force -Path $keydir | Out-Null New-Item -ItemType Directory -Force -Path $keydir | Out-Null
@@ -1,7 +1,10 @@
package cn.ucvl.zhaodisplay; package cn.ucvl.zhaodisplay;
import android.graphics.*; import android.graphics.*;
import android.media.MediaPlayer; import org.videolan.libvlc.MediaPlayer;
import org.videolan.libvlc.Media;
import org.videolan.libvlc.LibVLC;
import android.net.Uri;
import android.view.*; import android.view.*;
import android.widget.*; import android.widget.*;
import android.os.Handler; import android.os.Handler;
@@ -19,6 +22,7 @@ final class CameraStrip extends LinearLayout {
final ScheduledExecutorService worker=Executors.newSingleThreadScheduledExecutor(); final ScheduledExecutorService worker=Executors.newSingleThreadScheduledExecutor();
final LinearLayout row; final LinearLayout row;
final TextView title; final TextView title;
final LibVLC vlc;
final List<Tile> tiles=new ArrayList<>(); final List<Tile> tiles=new ArrayList<>();
JSONArray cameras=new JSONArray(); JSONArray cameras=new JSONArray();
String signature=""; String signature="";
@@ -28,6 +32,7 @@ final class CameraStrip extends LinearLayout {
static volatile String report="[]"; static volatile String report="[]";
CameraStrip(MainActivity a){ CameraStrip(MainActivity a){
super(a);app=a;setOrientation(VERTICAL);setBackgroundColor(0xffe8e5db); super(a);app=a;setOrientation(VERTICAL);setBackgroundColor(0xffe8e5db);
vlc=new LibVLC(a,new ArrayList<>(Arrays.asList("--rtsp-tcp","--network-caching=400","--no-audio","--no-video-title-show","--quiet")));
int pad=Math.max(12,a.getResources().getDisplayMetrics().widthPixels/50); int pad=Math.max(12,a.getResources().getDisplayMetrics().widthPixels/50);
setPadding(pad,pad/3,pad,pad/3); setPadding(pad,pad/3,pad,pad/3);
LinearLayout heading=new LinearLayout(a);heading.setGravity(Gravity.CENTER_VERTICAL); LinearLayout heading=new LinearLayout(a);heading.setGravity(Gravity.CENTER_VERTICAL);
@@ -65,7 +70,7 @@ final class CameraStrip extends LinearLayout {
} }
void clear(){for(Tile t:tiles)t.close();tiles.clear();row.removeAllViews();report="[]";} void clear(){for(Tile t:tiles)t.close();tiles.clear();row.removeAllViews();report="[]";}
void foreground(boolean value){foreground=value;if(value)render();else clear();} void foreground(boolean value){foreground=value;if(value)render();else clear();}
void close(){stopped=true;ui.removeCallbacksAndMessages(null);worker.shutdownNow();clear();} void close(){stopped=true;ui.removeCallbacksAndMessages(null);worker.shutdownNow();clear();vlc.release();}
final Runnable watch=new Runnable(){public void run(){ final Runnable watch=new Runnable(){public void run(){
if(stopped)return; if(stopped)return;
long now=SystemClock.elapsedRealtime(); long now=SystemClock.elapsedRealtime();
@@ -115,20 +120,19 @@ final class CameraStrip extends LinearLayout {
URI uri=new URI(camera.getString("url")); URI uri=new URI(camera.getString("url"));
if(!"rtsp".equals(uri.getScheme())||!camera.getString("host").equals(uri.getHost())){fail("直连地址不正确","unsupported");return;} if(!"rtsp".equals(uri.getScheme())||!camera.getString("host").equals(uri.getHost())){fail("直连地址不正确","unsupported");return;}
state="connecting";label.setText(camera.optString("name")+" · 正在直连");curtain.setVisibility(VISIBLE);visible=false;lastFrame=SystemClock.elapsedRealtime(); state="connecting";label.setText(camera.optString("name")+" · 正在直连");curtain.setVisibility(VISIBLE);visible=false;lastFrame=SystemClock.elapsedRealtime();
MediaPlayer p=new MediaPlayer();player=p;p.setSurface(surface);p.setVolume(0,0); MediaPlayer p=new MediaPlayer(vlc);player=p;
p.setOnPreparedListener(mp->{if(player==mp&&!closed)mp.start();}); p.getVLCVout().setVideoSurface(surface,null);p.getVLCVout().setWindowSize(texture.getWidth(),texture.getHeight());
p.setOnVideoSizeChangedListener((mp,w,h)->fit(w,h)); p.getVLCVout().attachViews((vout,w,h,vw,vh,sn,sd)->fit(vw,vh));
p.setOnErrorListener((mp,what,extra)->{if(player==mp)fail(extra==-1010?"电视暂不支持此编码":"直连未成功 · 自动重试",extra==-1010?"unsupported":"offline");return true;}); p.setEventListener(event->{if(player!=p||closed)return;if(event.type==MediaPlayer.Event.EncounteredError||event.type==MediaPlayer.Event.EndReached)fail("直连未成功 · 自动重试","offline");});
p.setOnCompletionListener(mp->{if(player==mp)fail("画面中断 · 自动重连","offline");}); Media media=new Media(vlc,Uri.parse(camera.getString("url")));media.setHWDecoderEnabled(true,false);media.addOption(":rtsp-tcp");media.addOption(":network-caching=400");media.addOption(":no-audio");p.setMedia(media);media.release();p.setVolume(0);p.play();
p.setDataSource(camera.getString("url"));p.prepareAsync();
}catch(Exception e){fail("直连未成功 · 自动重试","offline");} }catch(Exception e){fail("直连未成功 · 自动重试","offline");}
} }
void fit(int w,int h){if(w<=0||h<=0||texture.getWidth()==0||texture.getHeight()==0)return;float scale=Math.min((float)texture.getWidth()/w,(float)texture.getHeight()/h);Matrix matrix=new Matrix();matrix.setScale(w*scale/texture.getWidth(),h*scale/texture.getHeight(),texture.getWidth()/2f,texture.getHeight()/2f);texture.setTransform(matrix);} void fit(int w,int h){if(w<=0||h<=0||texture.getWidth()==0||texture.getHeight()==0)return;float scale=Math.min((float)texture.getWidth()/w,(float)texture.getHeight()/h);Matrix matrix=new Matrix();matrix.setScale(w*scale/texture.getWidth(),h*scale/texture.getHeight(),texture.getWidth()/2f,texture.getHeight()/2f);texture.setTransform(matrix);}
void fail(String text,String value){if(closed)return;state=value;release();curtain.setVisibility(VISIBLE);visible=false;label.setText(camera.optString("name")+" · "+text);ui.removeCallbacks(retry);ui.postDelayed(retry,Math.min(60000,10000L*(++failures)));} void fail(String text,String value){if(closed)return;state=value;release();curtain.setVisibility(VISIBLE);visible=false;label.setText(camera.optString("name")+" · "+text);ui.removeCallbacks(retry);ui.postDelayed(retry,Math.min(60000,10000L*(++failures)));}
void release(){MediaPlayer old=player;player=null;if(old!=null){try{old.reset();old.release();}catch(Exception ignored){}}} void release(){MediaPlayer old=player;player=null;if(old!=null){try{old.setEventListener(null);old.stop();old.getVLCVout().detachViews();old.release();}catch(Exception ignored){}}}
void close(){closed=true;ui.removeCallbacks(retry);release();if(surface!=null){surface.release();surface=null;}} void close(){closed=true;ui.removeCallbacks(retry);release();if(surface!=null){surface.release();surface=null;}}
public void onSurfaceTextureAvailable(SurfaceTexture s,int w,int h){surface=new Surface(s);connect();} public void onSurfaceTextureAvailable(SurfaceTexture s,int w,int h){surface=new Surface(s);connect();}
public void onSurfaceTextureSizeChanged(SurfaceTexture s,int w,int h){if(player!=null)try{fit(player.getVideoWidth(),player.getVideoHeight());}catch(Exception ignored){}} public void onSurfaceTextureSizeChanged(SurfaceTexture s,int w,int h){if(player!=null)try{player.getVLCVout().setWindowSize(w,h);}catch(Exception ignored){}}
public boolean onSurfaceTextureDestroyed(SurfaceTexture s){release();if(surface!=null)surface.release();surface=null;return true;} public boolean onSurfaceTextureDestroyed(SurfaceTexture s){release();if(surface!=null)surface.release();surface=null;return true;}
public void onSurfaceTextureUpdated(SurfaceTexture s){lastFrame=SystemClock.elapsedRealtime();if(player!=null&&!visible){visible=true;state="online";failures=0;curtain.setVisibility(GONE);label.setText(camera.optString("name")+" · 局域网直连");}} public void onSurfaceTextureUpdated(SurfaceTexture s){lastFrame=SystemClock.elapsedRealtime();if(player!=null&&!visible){visible=true;state="online";failures=0;curtain.setVisibility(GONE);label.setText(camera.optString("name")+" · 局域网直连");}}
} }
@@ -24,6 +24,8 @@ public class MainActivity extends Activity {
static volatile MainActivity active; static volatile MainActivity active;
WebView web; WebView web;
CameraStrip cameras; CameraStrip cameras;
final Handler themeHandler=new Handler();
final Runnable themeTick=new Runnable(){public void run(){applyTimeMode();themeHandler.postDelayed(this,60000);}};
@Override public void onCreate(Bundle state) { @Override public void onCreate(Bundle state) {
super.onCreate(state); super.onCreate(state);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
@@ -34,7 +36,8 @@ public class MainActivity extends Activity {
web.getSettings().setDomStorageEnabled(true); web.getSettings().setDomStorageEnabled(true);
web.getSettings().setAllowFileAccess(false); web.getSettings().setAllowFileAccess(false);
web.getSettings().setAllowContentAccess(false); web.getSettings().setAllowContentAccess(false);
web.getSettings().setMixedContentMode(0); // Plain RTSP is allowed only by the native player's same-network check.
web.getSettings().setMixedContentMode(android.webkit.WebSettings.MIXED_CONTENT_NEVER_ALLOW);
web.setWebViewClient(new WebViewClient(){ web.setWebViewClient(new WebViewClient(){
@Override public boolean shouldOverrideUrlLoading(WebView view,WebResourceRequest request){ @Override public boolean shouldOverrideUrlLoading(WebView view,WebResourceRequest request){
return !"https".equals(request.getUrl().getScheme()) || !"zhao.ucvl.cn".equals(request.getUrl().getHost()) || !request.getUrl().getPath().startsWith("/tv"); return !"https".equals(request.getUrl().getScheme()) || !"zhao.ucvl.cn".equals(request.getUrl().getHost()) || !request.getUrl().getPath().startsWith("/tv");
@@ -44,6 +47,7 @@ public class MainActivity extends Activity {
layout.addView(web,new LinearLayout.LayoutParams(-1,0,88)); layout.addView(web,new LinearLayout.LayoutParams(-1,0,88));
cameras=new CameraStrip(this);layout.addView(cameras,new LinearLayout.LayoutParams(-1,0,12)); cameras=new CameraStrip(this);layout.addView(cameras,new LinearLayout.LayoutParams(-1,0,12));
setContentView(layout); setContentView(layout);
themeHandler.post(themeTick);
configure(getIntent()); configure(getIntent());
} }
void configure(Intent intent){ void configure(Intent intent){
@@ -73,7 +77,13 @@ public class MainActivity extends Activity {
@Override public void onNewIntent(Intent intent){super.onNewIntent(intent);setIntent(intent);configure(intent);} @Override public void onNewIntent(Intent intent){super.onNewIntent(intent);setIntent(intent);configure(intent);}
@Override public void onResume(){super.onResume();active=this;immersive();if(cameras!=null)cameras.foreground(true);} @Override public void onResume(){super.onResume();active=this;immersive();if(cameras!=null)cameras.foreground(true);}
@Override public void onPause(){if(active==this)active=null;if(cameras!=null)cameras.foreground(false);super.onPause();} @Override public void onPause(){if(active==this)active=null;if(cameras!=null)cameras.foreground(false);super.onPause();}
@Override public void onDestroy(){if(active==this)active=null;if(cameras!=null)cameras.close();web.destroy();super.onDestroy();} @Override public void onDestroy(){if(active==this)active=null;themeHandler.removeCallbacksAndMessages(null);if(cameras!=null)cameras.close();web.destroy();super.onDestroy();}
void applyTimeMode(){
java.util.Calendar cal=java.util.Calendar.getInstance(java.util.TimeZone.getTimeZone("Asia/Shanghai"));
int hour=cal.get(java.util.Calendar.HOUR_OF_DAY);boolean night=hour>=20||hour<7;
WindowManager.LayoutParams params=getWindow().getAttributes();params.screenBrightness=night?.12f:.75f;getWindow().setAttributes(params);
if(cameras!=null){cameras.setBackgroundColor(night?0xff18221b:0xffe8e5db);cameras.title.setTextColor(night?0xff98a48c:0xff57634e);}
}
@Override public void onWindowFocusChanged(boolean hasFocus){super.onWindowFocusChanged(hasFocus);if(hasFocus)immersive();} @Override public void onWindowFocusChanged(boolean hasFocus){super.onWindowFocusChanged(hasFocus);if(hasFocus)immersive();}
void immersive(){getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN|View.SYSTEM_UI_FLAG_HIDE_NAVIGATION|View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY|View.SYSTEM_UI_FLAG_LAYOUT_STABLE|View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN|View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);} void immersive(){getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN|View.SYSTEM_UI_FLAG_HIDE_NAVIGATION|View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY|View.SYSTEM_UI_FLAG_LAYOUT_STABLE|View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN|View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);}
static void capture(Consumer<byte[]> callback){ static void capture(Consumer<byte[]> callback){
+7 -5
View File
@@ -1,10 +1,13 @@
<script setup> <script setup>
import {ref,computed,onMounted,onBeforeUnmount} from 'vue' import {ref,computed,watch,onMounted,onBeforeUnmount} from 'vue'
import {chinaParts,weatherLabel} from './time.mjs' 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) 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 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{} 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 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 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 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})) 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"> <div class="tv-upper">
<section class="square-clock" aria-label="北京时间时钟"> <section class="square-clock" aria-label="北京时间时钟">
<svg viewBox="0 0 440 440" role="img" :aria-label="`${time.hour}:${time.minute}:${time.second}`"> <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> <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" class="clock-number">{{n}}</text> <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> <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="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)`"/> <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> </section>
<div class="tv-bottom"> <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-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> </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> <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> </div>
</template> </template>
+4 -1
View File
@@ -4,5 +4,8 @@
@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important;animation:none!important;transition:none!important}} @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}} @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} .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}} @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}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -1,5 +1,5 @@
<!doctype html><html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="theme-color" content="#f3eee4"><meta name="referrer" content="no-referrer"><link rel="icon" href="/zhao-icon.png"><title>赵府 · 家庭时光</title> <script type="module" crossorigin src="/ui/assets/tv-BwowoKxJ.js"></script> <!doctype html><html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="theme-color" content="#f3eee4"><meta name="referrer" content="no-referrer"><link rel="icon" href="/zhao-icon.png"><title>赵府 · 家庭时光</title> <script type="module" crossorigin src="/ui/assets/tv-BtFxErTq.js"></script>
<link rel="modulepreload" crossorigin href="/ui/assets/bootstrap.min-z2h-5aUQ.js"> <link rel="modulepreload" crossorigin href="/ui/assets/bootstrap.min-z2h-5aUQ.js">
<link rel="stylesheet" crossorigin href="/ui/assets/bootstrap-DBkz-poX.css"> <link rel="stylesheet" crossorigin href="/ui/assets/bootstrap-DBkz-poX.css">
<link rel="stylesheet" crossorigin href="/ui/assets/tv-Bv_s0xCW.css"> <link rel="stylesheet" crossorigin href="/ui/assets/tv-BP8VHHR2.css">
</head><body><div id="app"></div></body></html> </head><body><div id="app"></div></body></html>