Skip to content

Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.

fix(dashboard): prevent polling timers from running during SSR

Timothy Yin7df5662ea754
diff --git a/.nuxtrc b/.nuxtrc
index 640f280a..6415c6ec 100644
--- a/.nuxtrc
+++ b/.nuxtrc
@@ -1 +1 @@
-setups.@nuxt/test-utils="4.0.3"
\ No newline at end of file
+setups.@nuxt/test-utils="4.3.3"
\ No newline at end of file
diff --git a/app/components/dashboard/RecentActivity.vue b/app/components/dashboard/RecentActivity.vue
index 8a7543b9..5b3d753e 100644
--- a/app/components/dashboard/RecentActivity.vue
+++ b/app/components/dashboard/RecentActivity.vue
@@ -27,13 +27,7 @@ const {
refresh,
} = await useFetch('/api/queue/recent')
-const refreshInterval = setInterval(() => {
- refresh()
-}, 5000)
-
-onBeforeUnmount(() => {
- clearInterval(refreshInterval)
-})
+useIntervalFn(refresh, 5000)
const items = computed<ActivityItem[]>(
() => (activityData.value?.tasks as ActivityItem[] | undefined) || [],
diff --git a/app/pages/dashboard/index.vue b/app/pages/dashboard/index.vue
index b708b0e9..d98b53d6 100644
--- a/app/pages/dashboard/index.vue
+++ b/app/pages/dashboard/index.vue
@@ -32,11 +32,7 @@ const refreshData = async () => {
}
}
-const refreshInterval = setInterval(refreshData, 5000)
-
-onBeforeUnmount(() => {
- clearInterval(refreshInterval)
-})
+useIntervalFn(refreshData, 5000)
const systemStatus = computed(() => {
if (!dashboardStats.value) return 'unknown'
diff --git a/app/pages/dashboard/queue.vue b/app/pages/dashboard/queue.vue
index 5f66f1f2..f88de7a3 100644
--- a/app/pages/dashboard/queue.vue
+++ b/app/pages/dashboard/queue.vue
@@ -269,10 +269,7 @@ const columns = computed<TableColumn<any>[]>(() => [
])
// 自动刷新
-const refreshInterval = setInterval(refreshData, 10000) // 每10秒刷新一次
-onBeforeUnmount(() => {
- clearInterval(refreshInterval)
-})
+useIntervalFn(refreshData, 10000) // 每10秒刷新一次
</script>
<template>
diff --git a/package.json b/package.json
index a9e0bfef..f1f88f67 100644
--- a/package.json
+++ b/package.json
@@ -21,8 +21,8 @@
"build:deps": "pnpm --filter @chronoframe/webgl-image build",
"dev": "run-p dev:dep dev:wait-only",
"dev:dep": "pnpm --filter @chronoframe/webgl-image dev",
- "dev:only": "nuxt dev --host",
- "dev:wait-only": "wait-on packages/webgl-image/dist && nuxt dev --host",
+ "dev:only": "nuxt dev",
+ "dev:wait-only": "wait-on packages/webgl-image/dist && nuxt dev",
"lint": "oxlint",
"lint:fix": "oxlint --fix",
"fmt": "oxfmt",