Skip to content

Commit ac86247

Browse files
committed
fix(projects): fix update notifications. fixed #691, fixed #692
1 parent c9433e1 commit ac86247

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/plugins/app.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,14 @@ export function setupAppErrorHandle(app: App) {
1414
const UPDATE_CHECK_INTERVAL = 3 * 60 * 1000;
1515

1616
export function setupAppVersionNotification() {
17-
const canAutoUpdateApp = import.meta.env.VITE_AUTOMATICALLY_DETECT_UPDATE === 'Y';
18-
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

@@ -47,6 +43,7 @@ export function setupAppVersionNotification() {
4743
{
4844
onClick() {
4945
n?.destroy();
46+
isShow = false;
5047
}
5148
},
5249
() => $t('system.updateCancel')
@@ -77,7 +74,7 @@ export function setupAppVersionNotification() {
7774
};
7875

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

0 commit comments

Comments
 (0)