From 45e3a8b754f7379fde18dff8c721489c8d427602 Mon Sep 17 00:00:00 2001 From: yueliuli <1628111725@qq.com> Date: Sat, 9 May 2026 14:12:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E9=9A=90=E6=82=A3?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E4=B8=BB=E9=A1=B5=E6=B7=BB=E5=8A=A0=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/index.vue | 67 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/src/pages/index.vue b/src/pages/index.vue index 3d8ab7e..7257209 100644 --- a/src/pages/index.vue +++ b/src/pages/index.vue @@ -11,6 +11,8 @@ const runCheckBtnRef = ref() const isRunningCheck = ref(false) const vidPaths = ref([]) +const processLog = ref([]) + interface RuleForm { vidPath: string function: string[] @@ -76,20 +78,38 @@ async function runCheck(formEl: FormInstance | undefined) { } } +function formatTime(date: Date) { + return `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')} ${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}:${date.getSeconds().toString().padStart(2, '0')}` +} + async function runProcess() { isRunningCheck.value = true startTimer() const tasks: Promise[] = [] + processLog.value = [] + processLog.value.push(`[${formatTime(new Date())}] 💬开始运行...`) if (ruleForm.function.includes('runAudioRecognition')) { tasks.push(runApiAudio('recognize', 'GET', { path: vidPaths.value[vidPaths.value.indexOf(ruleForm.vidPath)], + }).then((res) => { + if (res === 'error') + processLog.value.push(`[${formatTime(new Date())}] ❌️音频识别失败`) + else + processLog.value.push(`[${formatTime(new Date())}] ✅️音频识别完成`) + return res })) } if (ruleForm.function.includes('convertToMp4')) { tasks.push(runApiAudio('convert', 'GET', { path: vidPaths.value[vidPaths.value.indexOf(ruleForm.vidPath)], + }).then((res) => { + if (res === 'error') + processLog.value.push(`[${formatTime(new Date())}] ❌️转码失败`) + else + processLog.value.push(`[${formatTime(new Date())}] ✅️转码完成`) + return res })) } @@ -98,21 +118,31 @@ async function runProcess() { run_sam3: ruleForm.function.includes('runSam3'), run_inspection: ruleForm.function.includes('runHazardCheck'), gen_report: ruleForm.function.includes('runGenerateReport'), + }).then((res) => { + if (res === 'error') + processLog.value.push(`[${formatTime(new Date())}] ❌️隐患检测结果不存在或运行失败`) + else + processLog.value.push(`[${formatTime(new Date())}] ✅️隐患检测完成`) + return res })) await Promise.all(tasks).then((results) => { isRunningCheck.value = false + stopTimer() + processLog.value.push(`[${formatTime(new Date())}] 💬运行结束,耗时${timerDisplay.value}`) // 判定是否成功运行 - const lastRes = results[results.length - 1] - if (lastRes !== 'error') { - router.push({ - path: '/nav/hazardCheckResult', - query: { vid_file: vidPaths.value[vidPaths.value.indexOf(ruleForm.vidPath)] }, - }) + for (const res of results) { + // console.log('判定', String(res)) + if (res === 'error') { + return + } } - }) - stopTimer() + router.push({ + path: '/nav/hazardCheckResult', + query: { vid_file: vidPaths.value[vidPaths.value.indexOf(ruleForm.vidPath)] }, + }) + }) } async function reloadFiles() { @@ -213,6 +243,18 @@ onMounted(() => { > {{ timerDisplay }} +
+
+ + 运行日志 + +
+
+ + {{ item }} + +
+
@@ -231,4 +273,13 @@ onMounted(() => { gap: 16px; justify-content: flex-start; } + +.log-container { + // text-align: left; + margin-top: 20px; + width: 100%; + display: flex; + flex-direction: column; + align-items: flex-start; +}