优化称重首页图每秒刷新

This commit is contained in:
zc
2026-03-17 16:28:54 +08:00
parent 05c6cf6b1c
commit 2dc2d4887d

View File

@@ -299,6 +299,7 @@ const formData = reactive({
const imgData = reactive({
imgUrl: 'http://localhost:6609/file/001.bmp', // 样图URL
baseUrl: 'http://localhost:6609/file/001.bmp' // 基础URL
})
//比对结果
@@ -540,14 +541,28 @@ watch(activeStep, (newVal) => {
}
})
// 图片刷新定时器
let imageRefreshTimer: any = null
// 组件挂载时
onMounted(async () => {
await loadFlvJs()
// 启动图片自动刷新,每秒更新一次
imageRefreshTimer = setInterval(() => {
// 添加时间戳参数,避免浏览器缓存
imgData.imgUrl = `${imgData.baseUrl}?t=${Date.now()}`
}, 1000)
})
// 组件卸载时
onBeforeUnmount(() => {
stopCamera()
// 清除图片刷新定时器
if (imageRefreshTimer) {
clearInterval(imageRefreshTimer)
imageRefreshTimer = null
}
})
const workOrderResp = ref<WorkOrderResp>({