Skip to content

Commit 4258650

Browse files
committed
fix(projects): fix update notifications
1 parent 37c2930 commit 4258650

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/plugins/app.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,18 @@ export function setupAppErrorHandle(app: App) {
1010
};
1111
}
1212

13-
// Update check interval in milliseconds
14-
const UPDATE_CHECK_INTERVAL = 3 * 60 * 1000;
15-
1613
export function setupAppVersionNotification() {
17-
const canAutoUpdateApp = import.meta.env.VITE_AUTOMATICALLY_DETECT_UPDATE === 'Y';
14+
// Update check interval in milliseconds
15+
const UPDATE_CHECK_INTERVAL = 3 * 60 * 1000;
1816

17+
const canAutoUpdateApp = import.meta.env.VITE_AUTOMATICALLY_DETECT_UPDATE === 'Y' && import.meta.env.PROD;
1918
if (!canAutoUpdateApp) return;
2019

2120
let isShow = false;
2221
let updateInterval: ReturnType<typeof setInterval> | undefined;
2322

24-
// Check if updates should be checked
25-
const shouldCheckForUpdates = [!isShow, document.visibilityState === 'visible', !import.meta.env.DEV].every(Boolean);
26-
2723
const checkForUpdates = async () => {
28-
if (!shouldCheckForUpdates) return;
24+
if (isShow) return;
2925

3026
const buildTime = await getHtmlBuildTime();
3127

@@ -49,6 +45,7 @@ export function setupAppVersionNotification() {
4945
{
5046
onClick() {
5147
window.$notification?.destroy(key);
48+
isShow = false;
5249
}
5350
},
5451
() => $t('system.updateCancel')
@@ -79,7 +76,7 @@ export function setupAppVersionNotification() {
7976
};
8077

8178
// If updates should be checked, set up the visibility change listener and start the update interval
82-
if (shouldCheckForUpdates) {
79+
if (!isShow && document.visibilityState === 'visible') {
8380
// Check for updates when the document is visible
8481
document.addEventListener('visibilitychange', () => {
8582
if (document.visibilityState === 'visible') {

0 commit comments

Comments
 (0)