diff --git a/src/pages/index.vue b/src/pages/index.vue index a0b7f22..3d8ab7e 100644 --- a/src/pages/index.vue +++ b/src/pages/index.vue @@ -19,10 +19,11 @@ const ruleFormRef = ref() const ruleForm = reactive({ vidPath: '', function: [ - // 'runSam3', - // 'runHazardCheck', - // 'runGenerateReport', - // 'runAudioRecognition', + 'runAudioRecognition', + 'runSam3', + 'runHazardCheck', + 'runGenerateReport', + 'convertToMp4', ], }) @@ -71,30 +72,47 @@ async function runCheck(formEl: FormInstance | undefined) { } }) if (valid) { - isRunningCheck.value = true - startTimer() - if (ruleForm.function.includes('runAudioRecognition')) { - await runApiAudio('recognize', 'GET', { - path: vidPaths.value[vidPaths.value.indexOf(ruleForm.vidPath)], + runProcess() + } +} + +async function runProcess() { + isRunningCheck.value = true + startTimer() + const tasks: Promise[] = [] + + if (ruleForm.function.includes('runAudioRecognition')) { + tasks.push(runApiAudio('recognize', 'GET', { + path: vidPaths.value[vidPaths.value.indexOf(ruleForm.vidPath)], + })) + } + + if (ruleForm.function.includes('convertToMp4')) { + tasks.push(runApiAudio('convert', 'GET', { + path: vidPaths.value[vidPaths.value.indexOf(ruleForm.vidPath)], + })) + } + + tasks.push(runApi('/run', { + vid_file: vidPaths.value[vidPaths.value.indexOf(ruleForm.vidPath)], + run_sam3: ruleForm.function.includes('runSam3'), + run_inspection: ruleForm.function.includes('runHazardCheck'), + gen_report: ruleForm.function.includes('runGenerateReport'), + })) + + await Promise.all(tasks).then((results) => { + isRunningCheck.value = false + // 判定是否成功运行 + const lastRes = results[results.length - 1] + if (lastRes !== 'error') { + router.push({ + path: '/nav/hazardCheckResult', + query: { vid_file: vidPaths.value[vidPaths.value.indexOf(ruleForm.vidPath)] }, }) } - await runApi('/run', { - vid_file: vidPaths.value[vidPaths.value.indexOf(ruleForm.vidPath)], - run_sam3: ruleForm.function.includes('runSam3'), - run_inspection: ruleForm.function.includes('runHazardCheck'), - gen_report: ruleForm.function.includes('runGenerateReport'), - }).then((res) => { - isRunningCheck.value = false - stopTimer() - // 判定是否成功运行 - if (res !== 'error') { - router.push({ - path: '/nav/hazardCheckResult', - query: { vid_file: vidPaths.value[vidPaths.value.indexOf(ruleForm.vidPath)] }, - }) - } - }) - } + }) + + stopTimer() } async function reloadFiles() { @@ -153,6 +171,12 @@ onMounted(() => { + + 视频转码 + + + 音频识别 + 物体识别 @@ -162,9 +186,6 @@ onMounted(() => { 生成报告 - - 音频识别 - diff --git a/src/pages/nav/HazardCheckResult/index.vue b/src/pages/nav/HazardCheckResult/index.vue index f59a628..4ca176f 100644 --- a/src/pages/nav/HazardCheckResult/index.vue +++ b/src/pages/nav/HazardCheckResult/index.vue @@ -327,29 +327,17 @@ onMounted(async () => { const vidFile = router.currentRoute.value.query.vid_file as string if (vidFile) { // 调用接口获取完整视频路径 - runApi('/get_full_vid_path', { - vid_file: vidFile, + runApiAudio('/getVidUrl', 'GET', { + path: vidFile, }).then((res) => { + if (res === 'error') { + console.error('获取视频路径失败') + return + } // console.log('接口调用成功,返回数据:', res) - vidUrl.value = (res as string[])[0] - - // 截取文件名 - const fileName = vidUrl.value.split('\\').pop() || '' - // 去掉文件扩展名 - const fileNameNoExt = fileName.split('.')[0] - // 文件扩展名 - // const fileExt = fileName.split('.')[1] - // 临时拼接视频路径 - vidUrl.value = `http://localhost:8086/${fileNameNoExt}_h264.mp4` + vidUrl.value = res.url }) - // 临时拼接视频路径 - // 去掉文件扩展名 - // const fileNameNoExt = vidFile.split('.')[0] - // // 文件扩展名 - // const fileExt = vidFile.split('.')[1] - // vidUrl.value = `http://localhost:8086/${fileNameNoExt}_h264.${fileExt}` - // 调用接口获取隐患数据 runApi('/run', { vid_file: vidFile,