var dfdPrompt=null; var installPromptDiv=document.getElementById('install-prompt');
	function shouldShowInstallPrompt(){
		const oneDay=168*60*60*1000; const lastClosed=localStorage.getItem('installPromptClosed');
		if(lastClosed){
			const now=Date.now();
			return now-lastClosed>oneDay
		}return true
	}
	function showInstallPrompt(){
		if(dfdPrompt&&shouldShowInstallPrompt()){
			installPromptDiv.style.display='block'
		}
	}
	function closePrompt(){
		installPromptDiv.style.display='none';
		localStorage.setItem('installPromptClosed',Date.now())
	}
	window.addEventListener('beforeinstallprompt',function(e){
		dfdPrompt=e; e.preventDefault(); showInstallPrompt()
	});
	function addToDesktop(){
		if(dfdPrompt){
			dfdPrompt.prompt();
			dfdPrompt.userChoice.then(function(choiceResult){
				console.log(choiceResult.outcome);
				closePrompt();
				dfdPrompt=null
			})
		}else{
			console.log('添加到主屏幕的功能不可用。 ')
		}
	}
	window.onload=showInstallPrompt;