From 0e73aa2b8d5bf657d78f0f265986599970f38ae7 Mon Sep 17 00:00:00 2001 From: 16337 <1633794139@qq.com> Date: Tue, 10 Mar 2026 16:29:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=A0=8F=E4=BD=8D=E7=BD=AE=E8=B0=83=E6=95=B4=20+=20HEAD?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E6=A3=80=E6=B5=8B=E6=88=AA=E5=9B=BE=E7=8A=B6?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 状态栏位置调整 - 列顺序改为:应用名 -> 流ID -> 状态 -> 拉流地址 -> ROI 2. 状态检测优化 - 使用 HEAD 请求替代 GET,避免下载完整图片 - 使用 fetch API 直接发送 HEAD 请求到 /snap/image - 大幅提升状态检测性能 Co-Authored-By: Claude Opus 4.6 --- .../src/views/aiot/device/camera/index.vue | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/apps/web-antd/src/views/aiot/device/camera/index.vue b/apps/web-antd/src/views/aiot/device/camera/index.vue index 21411bed0..e827097e2 100644 --- a/apps/web-antd/src/views/aiot/device/camera/index.vue +++ b/apps/web-antd/src/views/aiot/device/camera/index.vue @@ -36,10 +36,14 @@ import { pushAllConfig, saveCamera, } from '#/api/aiot/device'; -import { wvpRequestClient } from '#/api/aiot/request'; +import { wvpRequestClient, getWvpToken } from '#/api/aiot/request'; defineOptions({ name: 'AiotDeviceCamera' }); +import { useAppConfig } from '@vben/hooks'; + +const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD); + const router = useRouter(); // ==================== 列表状态 ==================== @@ -54,9 +58,9 @@ const total = ref(0); const searchQuery = ref(''); const columns = [ + { title: '应用名', dataIndex: 'app', width: 100 }, + { title: '流ID', dataIndex: 'stream', width: 100 }, { title: '状态', key: 'status', width: 60, align: 'center' as const }, - { title: '应用名', dataIndex: 'app', width: 120 }, - { title: '流ID', dataIndex: 'stream', width: 150 }, { title: '拉流地址', dataIndex: 'srcUrl', ellipsis: true }, { title: 'ROI', key: 'roiCount', width: 80, align: 'center' as const }, { title: '操作', key: 'actions', width: 240, fixed: 'right' as const }, @@ -138,21 +142,19 @@ function loadRoiCounts() { } } -function loadCameraStatus() { +async function loadCameraStatus() { for (const cam of cameraList.value) { const cameraCode = cam.cameraCode; if (!cameraCode) continue; - wvpRequestClient - .get('/aiot/device/roi/snap/image', { - params: { cameraCode }, - responseType: 'blob', - }) - .then(() => { - cameraStatus.value = { ...cameraStatus.value, [cameraCode]: true }; - }) - .catch(() => { - cameraStatus.value = { ...cameraStatus.value, [cameraCode]: false }; - }); + // 使用 fetch HEAD 请求检测截图是否可用,避免下载完整图片 + try { + const token = await getWvpToken(); + const url = `${apiURL}/aiot/device/roi/snap/image?cameraCode=${encodeURIComponent(cameraCode)}&access-token=${encodeURIComponent(token)}`; + const res = await fetch(url, { method: 'HEAD' }); + cameraStatus.value = { ...cameraStatus.value, [cameraCode]: res.ok }; + } catch { + cameraStatus.value = { ...cameraStatus.value, [cameraCode]: false }; + } } }