fix(aiot): 边缘设备API切换到WVP直调,ROI下拉框改为动态加载

- edge/index.ts: requestClient → wvpRequestClient,路径改为 /api/ai/device/*
- roi/index.vue: 移除硬编码 edge-001 选项,从 WVP 动态加载设备列表
- 新建 ROI 默认 deviceId 取设备列表第一项,兜底 edge

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-02 16:49:08 +08:00
parent c7afa34f03
commit 71fd2a8576
2 changed files with 27 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
import type { PageParam, PageResult } from '@vben/request';
import { requestClient } from '#/api/request';
import { wvpRequestClient } from '#/api/aiot/request';
export namespace AiotEdgeApi {
/** 边缘设备 VO */
@@ -34,22 +34,23 @@ export namespace AiotEdgeApi {
/** 分页查询边缘设备列表 */
export function getDevicePage(params: PageParam) {
return requestClient.get<PageResult<AiotEdgeApi.Device>>(
'/aiot/edge/device/page',
return wvpRequestClient.get<PageResult<AiotEdgeApi.Device>>(
'/api/ai/device/page',
{ params },
);
}
/** 获取设备详情 */
export function getDevice(id: string) {
return requestClient.get<AiotEdgeApi.Device>(
`/aiot/edge/device/get?id=${id}`,
export function getDevice(deviceId: string) {
return wvpRequestClient.get<AiotEdgeApi.Device>(
'/api/ai/device/get',
{ params: { deviceId } },
);
}
/** 获取设备统计 */
export function getDeviceStatistics() {
return requestClient.get<AiotEdgeApi.DeviceStatistics>(
'/aiot/edge/device/statistics',
return wvpRequestClient.get<AiotEdgeApi.DeviceStatistics>(
'/api/ai/device/statistics',
);
}

View File

@@ -35,6 +35,7 @@ import {
pushConfig,
saveRoi,
} from '#/api/aiot/device';
import { wvpRequestClient } from '#/api/aiot/request';
import RoiAlgorithmBind from './components/RoiAlgorithmBind.vue';
import RoiCanvas from './components/RoiCanvas.vue';
@@ -64,6 +65,17 @@ const selectedRoiId = ref<null | string>(null);
const selectedRoiBindings = ref<AiotDeviceApi.RoiAlgoBinding[]>([]);
const snapUrl = ref('');
const edgeDevices = ref<Array<{ deviceId: string }>>([]);
async function loadEdgeDevices() {
try {
const list = await wvpRequestClient.get<Array<{ deviceId: string }>>('/api/ai/device/list');
edgeDevices.value = (list as any) || [];
} catch {
edgeDevices.value = [{ deviceId: 'edge' }];
}
}
const selectedRoi = computed(() => {
if (!selectedRoiId.value) return null;
return roiList.value.find((r) => r.roiId === selectedRoiId.value) || null;
@@ -72,6 +84,7 @@ const selectedRoi = computed(() => {
// ==================== 初始化 ====================
onMounted(async () => {
loadEdgeDevices();
const q = route.query;
if (q.cameraCode) {
cameraCode.value = String(q.cameraCode);
@@ -187,7 +200,7 @@ async function onRoiDrawn(data: { coordinates: string; roi_type: string }) {
priority: 0,
enabled: 1,
description: '',
deviceId: 'edge', // 默认关联边缘设备
deviceId: edgeDevices.value[0]?.deviceId || 'edge', // 默认关联边缘设备
};
try {
await saveRoi(newRoi);
@@ -416,11 +429,12 @@ function handlePush() {
placeholder="选择边缘设备"
@change="updateRoiData(selectedRoi!)"
>
<Select.Option value="edge-001">edge-001默认</Select.Option>
<!-- 未来支持动态加载 -->
<Select.Option v-for="dev in edgeDevices" :key="dev.deviceId" :value="dev.deviceId">
{{ dev.deviceId }}
</Select.Option>
</Select>
<div style="margin-top: 4px; font-size: 12px; color: #999">
关联的边缘推理节点默认 edge-001
关联的边缘推理节点
</div>
</Form.Item>
<Form.Item label="颜色">