From ac86247876e4b48d5d8bea9c9f6c5e081c92e937 Mon Sep 17 00:00:00 2001 From: Soybean Date: Sun, 19 Jan 2025 22:01:02 +0800 Subject: [PATCH] fix(projects): fix update notifications. fixed #691, fixed #692 --- src/plugins/app.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/plugins/app.ts b/src/plugins/app.ts index e59f6160..724e9a1e 100644 --- a/src/plugins/app.ts +++ b/src/plugins/app.ts @@ -14,18 +14,14 @@ export function setupAppErrorHandle(app: App) { const UPDATE_CHECK_INTERVAL = 3 * 60 * 1000; export function setupAppVersionNotification() { - const canAutoUpdateApp = import.meta.env.VITE_AUTOMATICALLY_DETECT_UPDATE === 'Y'; - + const canAutoUpdateApp = import.meta.env.VITE_AUTOMATICALLY_DETECT_UPDATE === 'Y' && import.meta.env.PROD; if (!canAutoUpdateApp) return; let isShow = false; let updateInterval: ReturnType | undefined; - // Check if updates should be checked - const shouldCheckForUpdates = [!isShow, document.visibilityState === 'visible', !import.meta.env.DEV].every(Boolean); - const checkForUpdates = async () => { - if (!shouldCheckForUpdates) return; + if (isShow) return; const buildTime = await getHtmlBuildTime(); @@ -47,6 +43,7 @@ export function setupAppVersionNotification() { { onClick() { n?.destroy(); + isShow = false; } }, () => $t('system.updateCancel') @@ -77,7 +74,7 @@ export function setupAppVersionNotification() { }; // If updates should be checked, set up the visibility change listener and start the update interval - if (shouldCheckForUpdates) { + if (!isShow && document.visibilityState === 'visible') { // Check for updates when the document is visible document.addEventListener('visibilitychange', () => { if (document.visibilityState === 'visible') {