feat: add manifest metadata fields and enable install prompt button in app template

- Extend manifest.json with id, orientation, scope, theme/background colors, related_applications, screenshots, dir, lang, launch_path, display_override, and short_name for full PWA compliance
- Move manifest link element to head section and add missing rel attribute
- Comment out push.js script tag to disable legacy push functionality
- Refactor beforeinstallprompt handler: remove preventDefault call, show install button immediately on event, and clean up nested DOMContentLoaded listener
This commit is contained in:
2025-02-17 21:31:17 +00:00
parent b301648f02
commit 24d2243afb
2 changed files with 30 additions and 12 deletions
+16 -11
View File
@@ -3,9 +3,12 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="manifest" href="/manifest.json" />
<title>Snek</title>
<style>{{highlight_styles}}</style>
<!--
<script src="/push.js"></script>
-->
<script src="/fancy-button.js"></script>
<script src="/upload-button.js"></script>
<script src="/generic-form.js"></script>
@@ -13,7 +16,7 @@
<script src="/schedule.js"></script>
<script src="/app.js"></script>
<link rel="stylesheet" href="/base.css">
<link rel="manifest" href="/manifest.json" />
<link rel="icon" type="image/png" href="/image/snek1.png" sizes="32x32">
</head>
<body>
@@ -45,20 +48,22 @@
</main>
<script>
let installPrompt = null
window.addEventListener("beforeinstallprompt", async(event) => {
event.preventDefault();
installPrompt = event;
document.addEventListener("DOMContentLoaded", () => {
alert("Jaaah")
window.addEventListener("beforeinstallprompt", (e) => {
//e.preventDefault();
installPrompt = e;
//document.addEventListener("DOMContentLoaded", () => {
const button = document.getElementById("install-button")
button.addEventListener("click", async ()=>{
const result = await installPrompt.prompt()
console.info(result.outcome)
})
button.style.display = 'inline-block'
button.addEventListener("click", async ()=>{
const result = await installPrompt.prompt()
console.info(result.outcome)
})
});
})
;
</script>
</body>