refactor: 摄像头管理页面移除状态栏、拉流和导出按钮

- 删除"状态"列(拉流中/未拉流)
- 删除操作栏中"拉流"和"导出"按钮,保留ROI配置、编辑、删除
- 删除搜索栏中"拉流状态"筛选
- 清理无用import和方法(toggleStream/handleExport/startCamera/stopCamera/exportConfig)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-10 11:20:01 +08:00
parent f68b4e8b23
commit d8e1ae5dab

View File

@@ -29,14 +29,11 @@ import {
import {
deleteCamera,
exportConfig,
getCameraList,
getMediaServerList,
getRoiByCameraId,
pushAllConfig,
saveCamera,
startCamera,
stopCamera,
} from '#/api/aiot/device';
defineOptions({ name: 'AiotDeviceCamera' });
@@ -52,15 +49,13 @@ const page = ref(1);
const pageSize = ref(15);
const total = ref(0);
const searchQuery = ref('');
const searchPulling = ref<string | undefined>(undefined);
const columns = [
{ title: '应用名', dataIndex: 'app', width: 120 },
{ title: '流ID', dataIndex: 'stream', width: 150 },
{ title: '拉流地址', dataIndex: 'srcUrl', ellipsis: true },
{ title: '状态', key: 'pulling', width: 100 },
{ title: 'ROI', key: 'roiCount', width: 80, align: 'center' as const },
{ title: '操作', key: 'actions', width: 340, fixed: 'right' as const },
{ title: '操作', key: 'actions', width: 240, fixed: 'right' as const },
];
// ==================== 编辑弹窗状态 ====================
@@ -114,10 +109,6 @@ async function loadData() {
page: page.value,
count: pageSize.value,
query: searchQuery.value || undefined,
pulling:
searchPulling.value === undefined
? undefined
: searchPulling.value === 'true',
});
cameraList.value = res.list || [];
total.value = res.total || 0;
@@ -288,23 +279,6 @@ function handleDelete(row: AiotDeviceApi.Camera) {
});
}
// ==================== 拉流控制 ====================
async function toggleStream(row: AiotDeviceApi.Camera) {
try {
if (row.pulling) {
await stopCamera(row.id!);
message.success('已停止拉流');
} else {
await startCamera(row.id!);
message.success('开始拉流');
}
loadData();
} catch {
message.error('操作失败');
}
}
// ==================== ROI 配置跳转 ====================
function handleRoiConfig(row: AiotDeviceApi.Camera) {
@@ -317,29 +291,6 @@ function handleRoiConfig(row: AiotDeviceApi.Camera) {
});
}
// ==================== 配置导出 ====================
async function handleExport(row: AiotDeviceApi.Camera) {
const cameraCode = row.cameraCode;
if (!cameraCode) {
message.warning('摄像头编码为空,无法导出');
return;
}
try {
const data = await exportConfig(cameraCode);
const json = JSON.stringify(data, null, 2);
const blob = new Blob([json], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `config_${cameraCode}.json`;
a.click();
URL.revokeObjectURL(url);
} catch {
message.error('导出失败');
}
}
// ==================== 同步全局配置 ====================
const syncing = ref(false);
@@ -401,17 +352,6 @@ onMounted(() => {
allow-clear
@press-enter="loadData"
/>
<Select
v-model:value="searchPulling"
placeholder="拉流状态"
style="width: 130px"
allow-clear
:options="[
{ value: 'true', label: '拉流中' },
{ value: 'false', label: '未拉流' },
]"
@change="loadData"
/>
<Button type="primary" @click="loadData">查询</Button>
</div>
<Space>
@@ -442,12 +382,7 @@ onMounted(() => {
size="middle"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'pulling'">
<Tag :color="record.pulling ? 'success' : 'default'">
{{ record.pulling ? '拉流中' : '未拉流' }}
</Tag>
</template>
<template v-else-if="column.key === 'roiCount'">
<template v-if="column.key === 'roiCount'">
<Badge
:count="roiCounts[record.cameraCode] ?? 0"
:number-style="{ backgroundColor: '#1677ff' }"
@@ -464,15 +399,6 @@ onMounted(() => {
ROI配置
</Button>
<Button size="small" @click="handleEdit(record)">编辑</Button>
<Button
:type="record.pulling ? 'default' : 'primary'"
:danger="record.pulling"
size="small"
@click="toggleStream(record)"
>
{{ record.pulling ? '停止' : '拉流' }}
</Button>
<Button size="small" @click="handleExport(record)">导出</Button>
<Button size="small" danger @click="handleDelete(record)">
删除
</Button>