fix(web): 修复 WebRTC 首帧状态与视频状态判定

This commit is contained in:
mofeng-git
2026-03-27 10:44:59 +08:00
parent c8fd3648ad
commit e20136a5ab
2 changed files with 8 additions and 4 deletions

View File

@@ -71,14 +71,14 @@ fn rebuild_event_tasks(
let mut device_info_task_added = false; let mut device_info_task_added = false;
for topic in topics { for topic in topics {
if is_device_info_topic(&topic) && !device_info_task_added { if is_device_info_topic(&topic) && !device_info_task_added {
let state = state.clone();
let mut rx = state.subscribe_device_info(); let mut rx = state.subscribe_device_info();
let event_tx = event_tx.clone(); let event_tx = event_tx.clone();
event_tasks.push(tokio::spawn(async move { event_tasks.push(tokio::spawn(async move {
if let Some(snapshot) = rx.borrow().clone() { let snapshot = state.get_device_info().await;
if event_tx.send(BusMessage::Event(snapshot)).is_err() { if event_tx.send(BusMessage::Event(snapshot)).is_err() {
return; return;
} }
}
loop { loop {
if rx.changed().await.is_err() { if rx.changed().await.is_err() {

View File

@@ -174,6 +174,10 @@ const videoStatus = computed<'connected' | 'connecting' | 'disconnected' | 'erro
if (videoError.value) return 'error' if (videoError.value) return 'error'
if (videoLoading.value) return 'connecting' if (videoLoading.value) return 'connecting'
if (videoMode.value !== 'mjpeg') {
if (webrtc.isConnecting.value) return 'connecting'
if (webrtc.isConnected.value) return 'connected'
}
if (systemStore.stream?.online) return 'connected' if (systemStore.stream?.online) return 'connected'
return 'disconnected' return 'disconnected'
}) })