Skip to content

Commit

Permalink
optimize(projects): optimize setupAppVersionNotification
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Jun 13, 2024
1 parent fe15a9a commit f061d8b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/plugins/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@ import { Button } from 'ant-design-vue';
import { $t } from '../locales';

export function setupAppVersionNotification() {
let isShow = false;

document.addEventListener('visibilitychange', async () => {
const preConditions = [!isShow, document.visibilityState === 'visible', !import.meta.env.DEV];

if (!preConditions.every(Boolean)) return;

const buildTime = await getHtmlBuildTime();

if (!import.meta.env.DEV && buildTime !== BUILD_TIME && document.visibilityState === 'visible') {
if (buildTime !== BUILD_TIME) {
isShow = true;

const key = `open${Date.now()}`;

window.$notification?.open({
Expand Down Expand Up @@ -34,6 +42,9 @@ export function setupAppVersionNotification() {
() => $t('system.updateConfirm')
)
]);
},
onClose() {
isShow = false;
}
});
}
Expand Down

0 comments on commit f061d8b

Please sign in to comment.