refactor: 移除polling-store,重构setting-store

This commit is contained in:
yangsy
2026-01-19 15:15:38 +08:00
parent b7b6b216fb
commit 6771abec31
29 changed files with 197 additions and 185 deletions

View File

@@ -13,7 +13,7 @@ const props = defineProps<{
}>();
const settingStore = useSettingStore();
const { offlineDev } = storeToRefs(settingStore);
const { activeRequests } = storeToRefs(settingStore);
const queryClient = useQueryClient();
@@ -27,7 +27,7 @@ const SERVER_STREAM_PUSH_KEY = 'server-stream-push-query';
const { data: streamPushes } = useQuery({
queryKey: computed(() => [SERVER_STREAM_PUSH_KEY, ndmDevice.value.id, ndmDevice.value.lastDiagTime]),
enabled: computed(() => !offlineDev.value && showCard.value),
enabled: computed(() => activeRequests.value && showCard.value),
refetchInterval: 30 * 1000,
gcTime: 0,
queryFn: async ({ signal }) => {
@@ -35,8 +35,8 @@ const { data: streamPushes } = useQuery({
return streamPushes;
},
});
watch(offlineDev, (offline) => {
if (offline) {
watch(activeRequests, (active) => {
if (!active) {
queryClient.cancelQueries({ queryKey: [SERVER_STREAM_PUSH_KEY] });
}
});
@@ -70,7 +70,7 @@ const streamPushStat = computed(() => {
<span>推流统计</span>
</template>
<template #default>
<template v-if="offlineDev">
<template v-if="activeRequests">
<span>-</span>
</template>
<template v-else>