|
|
|
@ -382,11 +382,24 @@ function connectDetectStream() {
|
|
|
|
detectWsClient.connect()
|
|
|
|
detectWsClient.connect()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function switchStream() {
|
|
|
|
async function switchStream() {
|
|
|
|
if (!streamAddress.value) {
|
|
|
|
if (!streamAddress.value) {
|
|
|
|
ElMessage.warning('请输入视频流地址')
|
|
|
|
ElMessage.warning('请输入视频流地址')
|
|
|
|
return
|
|
|
|
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()
|
|
|
|
stopRawStream()
|
|
|
|
videoMode.value = 'live'
|
|
|
|
videoMode.value = 'live'
|
|
|
|
webrtcUrl.value = ''
|
|
|
|
webrtcUrl.value = ''
|
|
|
|
@ -396,7 +409,7 @@ function switchStream() {
|
|
|
|
stopDetectStream(() => connectRawStream())
|
|
|
|
stopDetectStream(() => connectRawStream())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function toggleStream() {
|
|
|
|
async function toggleStream() {
|
|
|
|
if (streamRunning.value) {
|
|
|
|
if (streamRunning.value) {
|
|
|
|
// 关闭视频流
|
|
|
|
// 关闭视频流
|
|
|
|
stopRawStream()
|
|
|
|
stopRawStream()
|
|
|
|
@ -410,7 +423,6 @@ function toggleStream() {
|
|
|
|
ending.value = false
|
|
|
|
ending.value = false
|
|
|
|
ElMessage.info('视频流已关闭')
|
|
|
|
ElMessage.info('视频流已关闭')
|
|
|
|
addLog('视频检测完成,已切换到结果视频', 'info')
|
|
|
|
addLog('视频检测完成,已切换到结果视频', 'info')
|
|
|
|
disableAlgorithm()
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
stopDetectStream()
|
|
|
|
stopDetectStream()
|
|
|
|
@ -422,10 +434,16 @@ function toggleStream() {
|
|
|
|
ending.value = false
|
|
|
|
ending.value = false
|
|
|
|
ElMessage.info('视频流已关闭')
|
|
|
|
ElMessage.info('视频流已关闭')
|
|
|
|
addLog('视频流已关闭', 'info')
|
|
|
|
addLog('视频流已关闭', 'info')
|
|
|
|
disableAlgorithm()
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// 启动视频流
|
|
|
|
// 启动视频流 — 确保算法启用状态为 true
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
await setAlgorithmStatusApi({ enabled: true })
|
|
|
|
|
|
|
|
algorithmEnabled.value = true
|
|
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
|
|
algorithmEnabled.value = false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (offlineVideoUrl.value) {
|
|
|
|
if (offlineVideoUrl.value) {
|
|
|
|
URL.revokeObjectURL(offlineVideoUrl.value)
|
|
|
|
URL.revokeObjectURL(offlineVideoUrl.value)
|
|
|
|
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() {
|
|
|
|
function connectProcessWs() {
|
|
|
|
if (processWsClient) return
|
|
|
|
if (processWsClient) return
|
|
|
|
|
|
|
|
|
|
|
|
|