fix: 修复设备查询缓存键冲突问题
- 将查询键中的设备ID改为由车站编码和设备ID组成的唯一键,防止不同车站下相同设备ID导致的数据混淆。 - 同时更新相关监控逻辑,当车站或设备IP变化时重置页面状态。
This commit is contained in:
@@ -92,6 +92,8 @@ const abortController = ref<AbortController>(new AbortController());
|
||||
|
||||
const NVR_RECORD_CHECK_KEY = 'nvr-record-check-query';
|
||||
|
||||
const deviceUniqueKey = computed(() => [station.value.code, ndmDevice.value.id]);
|
||||
|
||||
const DAY_OFFSET = 90;
|
||||
|
||||
const {
|
||||
@@ -99,7 +101,7 @@ const {
|
||||
isFetching: loading,
|
||||
refetch: refetchRecordChecks,
|
||||
} = useQuery({
|
||||
queryKey: computed(() => [NVR_RECORD_CHECK_KEY, ndmDevice.value.id, ndmDevice.value.lastDiagTime]),
|
||||
queryKey: computed(() => [NVR_RECORD_CHECK_KEY, deviceUniqueKey.value, ndmDevice.value.lastDiagTime]),
|
||||
enabled: computed(() => activeRequests.value),
|
||||
refetchInterval: 30 * 1000,
|
||||
gcTime: 0,
|
||||
@@ -408,13 +410,13 @@ const ndmRecordChecksPaged = computed(() => {
|
||||
return ndmRecordChecksFiltered.value.slice(startIndex, endIndex);
|
||||
});
|
||||
|
||||
// 当设备ID、最后诊断时间或筛选类型变化时,重置分页为第一页
|
||||
watch([() => ndmDevice.value.id, () => ndmDevice.value.lastDiagTime, filterType, searchInputDebounced], () => {
|
||||
// 当车站号、设备IP、最后诊断时间或筛选类型变化时,重置分页为第一页
|
||||
watch([() => station.value.code, () => ndmDevice.value.ipAddress, () => ndmDevice.value.lastDiagTime, filterType, searchInputDebounced], () => {
|
||||
page.value = 1;
|
||||
});
|
||||
|
||||
// 当设备ID变化时,重置搜索内容,并将筛选类型重置为「全部」
|
||||
watch([() => ndmDevice.value.id], () => {
|
||||
// 当车站号、设备IP变化时,重置搜索内容,并将筛选类型重置为「全部」
|
||||
watch([() => station.value.code, () => ndmDevice.value.ipAddress], () => {
|
||||
searchInput.value = '';
|
||||
filterType.value = 'all';
|
||||
});
|
||||
|
||||
@@ -23,8 +23,11 @@ const deviceType = computed(() => tryGetDeviceType(ndmDevice.value.deviceType));
|
||||
|
||||
const MEDIA_SERVER_ALIVE_QUERY_KEY = 'media-server-alive-query';
|
||||
const VIDEO_SERVER_ALIVE_QUERY_KEY = 'video-server-alive-query';
|
||||
|
||||
const deviceUniqueKey = computed(() => [station.value.code, ndmDevice.value.id]);
|
||||
|
||||
const { data: isMediaServerAlive } = useQuery({
|
||||
queryKey: computed(() => [MEDIA_SERVER_ALIVE_QUERY_KEY, ndmDevice.value.id, ndmDevice.value.lastDiagTime]),
|
||||
queryKey: computed(() => [MEDIA_SERVER_ALIVE_QUERY_KEY, deviceUniqueKey.value, ndmDevice.value.lastDiagTime]),
|
||||
enabled: computed(() => activeRequests.value && deviceType.value === DEVICE_TYPE_LITERALS.ndmMediaServer),
|
||||
refetchInterval: 30 * 1000,
|
||||
gcTime: 0,
|
||||
@@ -34,7 +37,7 @@ const { data: isMediaServerAlive } = useQuery({
|
||||
},
|
||||
});
|
||||
const { data: isSipServerAlive } = useQuery({
|
||||
queryKey: computed(() => [VIDEO_SERVER_ALIVE_QUERY_KEY, ndmDevice.value.id, ndmDevice.value.lastDiagTime]),
|
||||
queryKey: computed(() => [VIDEO_SERVER_ALIVE_QUERY_KEY, deviceUniqueKey.value, ndmDevice.value.lastDiagTime]),
|
||||
enabled: computed(() => activeRequests.value && deviceType.value === DEVICE_TYPE_LITERALS.ndmVideoServer),
|
||||
refetchInterval: 30 * 1000,
|
||||
gcTime: 0,
|
||||
|
||||
@@ -25,8 +25,10 @@ const showCard = computed(() => deviceType.value === DEVICE_TYPE_LITERALS.ndmMed
|
||||
|
||||
const SERVER_STREAM_PUSH_KEY = 'server-stream-push-query';
|
||||
|
||||
const deviceUniqueKey = computed(() => [station.value.code, ndmDevice.value.id]);
|
||||
|
||||
const { data: streamPushes } = useQuery({
|
||||
queryKey: computed(() => [SERVER_STREAM_PUSH_KEY, ndmDevice.value.id, ndmDevice.value.lastDiagTime]),
|
||||
queryKey: computed(() => [SERVER_STREAM_PUSH_KEY, deviceUniqueKey.value, ndmDevice.value.lastDiagTime]),
|
||||
enabled: computed(() => activeRequests.value && showCard.value),
|
||||
refetchInterval: 30 * 1000,
|
||||
gcTime: 0,
|
||||
|
||||
Reference in New Issue
Block a user