Compare commits

...

6 Commits

Author SHA1 Message Date
yangsy
54591f401f refactor: remove console.log 2025-12-01 15:33:47 +08:00
yangsy
2116631ba6 fix: avoid mutation error from interrupting query 2025-12-01 15:22:50 +08:00
yangsy
b4e2926f08 fix: sync camera & channels 2025-12-01 15:20:11 +08:00
yangsy
168d11c71b style 2025-12-01 14:43:58 +08:00
yangsy
b0c0b88091 fix: /syncCamera 2025-12-01 14:43:42 +08:00
yangsy
f7d1d2d44c fix(security-box-info-card): access status 2025-12-01 11:30:08 +08:00
7 changed files with 52 additions and 24 deletions

View File

@@ -55,9 +55,10 @@ export const syncCameraApi = async (options?: { stationCode?: string; signal?: A
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmCamera/syncCamera`;
const resp = await client.get<void>(endpoint, { signal });
const [err] = resp;
if (err) {
const resp = await client.get<boolean>(endpoint, { signal });
const [err, data] = resp;
if (err || !data) {
throw err;
}
return data;
};

View File

@@ -20,7 +20,7 @@ const cardShow = computed(() => {
// 门禁状态 (switches[0]: 0=关闭/失效, 1=打开/生效)
const accessControlStatus = computed(() => {
if (!switches?.value || switches.value.length === 0) return null;
return switches.value[0] === 1 ? '打开' : '关闭';
return switches.value[0] === 0 ? '打开' : '关闭';
});
// 防雷状态 (switches[1]: 0=关闭/失效, 1=打开/生效)

View File

@@ -262,7 +262,7 @@ const scrollDeviceTreeToSelectedDevice = () => {
<template>
<div style="height: 100%; display: flex; flex-direction: column">
<div style="flex-shrink: 0; padding: 12px">
<div style="padding: 12px; flex-shrink: 0">
<NInput v-model:value="searchInput" placeholder="搜索设备名称、设备ID或IP地址" clearable />
<NFlex justify="space-between" align="center">
<NRadioGroup v-model:value="statusInput">
@@ -277,13 +277,13 @@ const scrollDeviceTreeToSelectedDevice = () => {
</NFlex>
</div>
<div style="flex: 1; min-height: 0; display: flex; overflow: hidden">
<div style="flex: 0 0 auto; height: 100%">
<div style="min-height: 0; overflow: hidden; flex: 1; display: flex">
<div style="height: 100%; flex: 0 0 auto">
<NTabs v-model:value="activeTab" animated type="line" placement="left" style="height: 100%">
<NTab v-for="pane in deviceTabPanes" :key="pane.name" :name="pane.name" :tab="pane.tab"></NTab>
</NTabs>
</div>
<div style="flex: 1 1 auto; min-width: 0">
<div style="min-width: 0; flex: 1 1 auto">
<NTree
:ref="'deviceTreeInst'"
v-model:expanded-keys="expandedKeys"

View File

@@ -40,7 +40,7 @@ export function useLineAlarmsQuery() {
queryFn: async ({ signal }) => {
console.time('useLineALarmCountsQuery');
for (const station of stationList.value) {
await getStationAlarmCounts({ station, signal });
await getStationAlarmCounts({ station, signal }).catch(() => {});
}
console.timeEnd('useLineALarmCountsQuery');
// pollingStore.updateAlarmQueryUpdatedAt();

View File

@@ -47,7 +47,7 @@ export function useLineDevicesQuery() {
queryFn: async ({ signal }) => {
console.time('useLineDevicesQuery');
for (const station of stationList.value) {
await getStationDevices({ station, signal });
await getStationDevices({ station, signal }).catch(() => {});
}
console.timeEnd('useLineDevicesQuery');
// pollingStore.updateDeviceQueryUpdatedAt();

View File

@@ -20,7 +20,7 @@ export function useLineStationsQuery() {
staleTime: getAppEnvConfig().requestInterval * 500,
queryFn: async ({ signal }) => {
console.time('useStationListQuery');
await getStationList({ signal });
await getStationList({ signal }).catch(() => {});
console.timeEnd('useStationListQuery');
pollingStore.updateDeviceQueryStamp();
pollingStore.updateAlarmQueryStamp();

View File

@@ -70,15 +70,29 @@ const { mutate: syncCamera, isPending: cameraSyncing } = useMutation({
const stationCodes = Object.entries(stationSelection.value)
.filter(([, selected]) => selected)
.map(([code]) => code);
for (const stationCode of stationCodes) {
await syncCameraApi({ stationCode });
await sleep(5000);
}
const results = await Promise.allSettled(stationCodes.map((stationCode) => syncCameraApi({ stationCode })));
return results.map((result, index) => ({ ...result, stationCode: stationCodes[index] }));
},
onSuccess: () => {
window.$message.success('摄像机同步成功');
pollingStore.disablePolling();
pollingStore.enablePolling();
onSuccess: (results) => {
const successCount = results.filter((result) => result.status === 'fulfilled').length;
const failures = results.filter((result) => result.status === 'rejected');
const failureCount = failures.length;
if (failureCount > 0) {
const failedStations = failures.map((f) => stationList.value.find((s) => s.code === f.stationCode)?.name).join('、');
if (successCount === 0) {
window.$message.error('摄像机同步全部失败');
window.$message.error(`${failedStations}`);
} else {
window.$message.warning(`摄像机同步完成:成功${successCount}个车站,失败${failureCount}个车站`);
window.$message.warning(`${failedStations}`);
}
} else {
window.$message.success('摄像机同步成功');
}
if (successCount > 0) {
pollingStore.disablePolling();
pollingStore.enablePolling();
}
onFinish();
},
onError: (error) => {
@@ -92,12 +106,25 @@ const { mutate: syncNvrChannels, isPending: nvrChannelsSyncing } = useMutation({
const stationCodes = Object.entries(stationSelection.value)
.filter(([, selected]) => selected)
.map(([code]) => code);
for (const stationCode of stationCodes) {
await syncNvrChannelsApi({ stationCode });
}
const results = await Promise.allSettled(stationCodes.map((stationCode) => syncNvrChannelsApi({ stationCode })));
return results.map((result, index) => ({ ...result, stationCode: stationCodes[index] }));
},
onSuccess: () => {
window.$message.info('正在同步录像机通道,可能需要一些时间');
onSuccess: (results) => {
const successCount = results.filter((result) => result.status === 'fulfilled').length;
const failures = results.filter((result) => result.status === 'rejected');
const failureCount = failures.length;
if (failureCount > 0) {
const failedStations = failures.map((f) => stationList.value.find((s) => s.code === f.stationCode)?.name).join('、');
if (successCount === 0) {
window.$message.error('录像机通道同步全部失败');
window.$message.error(`${failedStations}`);
} else {
window.$message.warning(`录像机通道同步完成:成功${successCount}个车站,失败${failureCount}个车站`);
window.$message.warning(`${failedStations}`);
}
} else {
window.$message.success('录像机通道同步成功');
}
onFinish();
},
onError: (error) => {