From 70d6632fd0049086b57608533d10ee79625ca764 Mon Sep 17 00:00:00 2001 From: ccbikai Date: Sun, 18 May 2025 19:13:04 +0800 Subject: [PATCH] refactor: remove redundant watcher cleanup in Vue comps Removes unnecessary manual watcher cleanup via stopWatchQueryChange across multiple Vue components. Vue 3's watch() automatically handles cleanup when components are unmounted, making explicit stopWatchQueryChange calls and onBeforeUnmount handlers redundant. This change: - Improves code maintainability - Reduces boilerplate code - Follows Vue 3 best practices for reactive system cleanup --- app/components/dashboard/analysis/Counters.vue | 6 +----- app/components/dashboard/analysis/Views.vue | 6 +----- app/components/dashboard/analysis/metrics/Locations.vue | 6 +----- app/components/dashboard/analysis/metrics/Metric.vue | 6 +----- app/components/dashboard/realtime/Chart.vue | 6 +----- app/components/dashboard/realtime/Globe.vue | 6 +----- app/components/dashboard/realtime/Logs.vue | 6 +----- 7 files changed, 7 insertions(+), 35 deletions(-) diff --git a/app/components/dashboard/analysis/Counters.vue b/app/components/dashboard/analysis/Counters.vue index e6fcaac..60b2ace 100644 --- a/app/components/dashboard/analysis/Counters.vue +++ b/app/components/dashboard/analysis/Counters.vue @@ -26,17 +26,13 @@ async function getLinkCounters() { counters.value = data?.[0] } -const stopWatchQueryChange = watch([time, filters], getLinkCounters, { +watch([time, filters], getLinkCounters, { deep: true, }) onMounted(async () => { getLinkCounters() }) - -onBeforeUnmount(() => { - stopWatchQueryChange() -})