fix:优化切换判定

zlx
zhoulexin 2 weeks ago
parent 06b15e74ea
commit 0bc2be5a42

@ -382,11 +382,24 @@ function connectDetectStream() {
detectWsClient.connect()
}
function switchStream() {
async function switchStream() {
if (!streamAddress.value) {
ElMessage.warning('请输入视频流地址')
return
}
// true
try {
await setAlgorithmStatusApi({ enabled: true })
algorithmEnabled.value = true
} catch {
algorithmEnabled.value = false
}
// 线 hasOfflineVideo
if (offlineVideoUrl.value) {
URL.revokeObjectURL(offlineVideoUrl.value)
offlineVideoUrl.value = ''
detectionFile.value = null
}
stopRawStream()
videoMode.value = 'live'
webrtcUrl.value = ''
@ -396,7 +409,7 @@ function switchStream() {
stopDetectStream(() => connectRawStream())
}
function toggleStream() {
async function toggleStream() {
if (streamRunning.value) {
//
stopRawStream()
@ -410,7 +423,6 @@ function toggleStream() {
ending.value = false
ElMessage.info('视频流已关闭')
addLog('视频检测完成,已切换到结果视频', 'info')
disableAlgorithm()
})
} else {
stopDetectStream()
@ -422,10 +434,16 @@ function toggleStream() {
ending.value = false
ElMessage.info('视频流已关闭')
addLog('视频流已关闭', 'info')
disableAlgorithm()
}
} else {
//
// true
try {
await setAlgorithmStatusApi({ enabled: true })
algorithmEnabled.value = true
} catch {
algorithmEnabled.value = false
}
if (offlineVideoUrl.value) {
URL.revokeObjectURL(offlineVideoUrl.value)
offlineVideoUrl.value = ''
@ -824,16 +842,6 @@ onMounted(async () => {
}
})
async function disableAlgorithm() {
try {
await setAlgorithmStatusApi({ enabled: false })
const enabled = await getAlgorithmStatusApi()
algorithmEnabled.value = !!enabled
} catch {
addLog('更新算法状态失败', 'error')
}
}
function connectProcessWs() {
if (processWsClient) return

Loading…
Cancel
Save