Merge branch 'main' into example

This commit is contained in:
Soybean
2024-06-14 00:05:12 +08:00
14 changed files with 48 additions and 13 deletions

View File

@@ -3,10 +3,18 @@ import { NButton } from 'naive-ui';
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 n = window.$notification?.create({
title: $t('system.updateTitle'),
content: $t('system.updateContent'),
@@ -32,6 +40,9 @@ export function setupAppVersionNotification() {
() => $t('system.updateConfirm')
)
]);
},
onClose() {
isShow = false;
}
});
}