mirror of
				https://github.com/soybeanjs/soybean-admin.git
				synced 2025-11-04 15:53:43 +08:00 
			
		
		
		
	optimize(projects): optimize setupAppVersionNotification
				
					
				
			This commit is contained in:
		@@ -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;
 | 
			
		||||
        }
 | 
			
		||||
      });
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user