初始化提交

This commit is contained in:
史悦
2026-01-07 16:46:09 +08:00
commit 0dbb36be9d
113 changed files with 16197 additions and 0 deletions

24
frontend/src/utils/pwa.js Normal file
View File

@@ -0,0 +1,24 @@
let request;
let isInstallable = false;
// The file is not useful now.
window.addEventListener('beforeinstallprompt', (r) => {
console.log('beforeinstallprompt')
// Prevent Chrome 67 and earlier from automatically showing the prompt
r.preventDefault()
request = r
isInstallable = true;
});
export async function installPWA() {
if (request) {
console.log('start install')
let installResponse = await request.prompt();
console.info({installResponse});
return installResponse.outcome === 'accepted';
} else {
console.log('The request is not available');
return false;
}
}