pwa - the SIMPLIEST fix
This commit is contained in:
parent
9bbc8cd0b3
commit
578e8089c7
1 changed files with 1 additions and 27 deletions
28
src/app.html
28
src/app.html
|
|
@ -10,6 +10,7 @@
|
|||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||
<meta name="apple-mobile-web-app-title" content="Fooder" />
|
||||
<link rel="apple-touch-icon" href="%sveltekit.assets%/icons/apple-touch-icon-180x180.png" />
|
||||
<link rel="manifest" href="%sveltekit.assets%/manifest.json" />
|
||||
|
||||
<!-- Android PWA -->
|
||||
<meta name="mobile-web-app-capable" content="yes" />
|
||||
|
|
@ -19,33 +20,6 @@
|
|||
|
||||
<title>Fooder</title>
|
||||
%sveltekit.head%
|
||||
<script>
|
||||
// iOS PWA: intercept internal <a> clicks in capture phase so Safari never
|
||||
// processes them as "real" navigations (which causes the browser chrome to appear).
|
||||
if (window.navigator.standalone) {
|
||||
document.addEventListener('click', function (e) {
|
||||
var node = e.target;
|
||||
while (node) {
|
||||
if (node.nodeName === 'A' && node.href) {
|
||||
try {
|
||||
var url = new URL(node.href);
|
||||
if (
|
||||
url.origin === window.location.origin &&
|
||||
!node.download &&
|
||||
node.target !== '_blank'
|
||||
) {
|
||||
e.preventDefault();
|
||||
history.pushState(null, '', url.pathname + url.search + url.hash);
|
||||
window.dispatchEvent(new PopStateEvent('popstate', { state: null }));
|
||||
}
|
||||
} catch (_) {}
|
||||
break;
|
||||
}
|
||||
node = node.parentElement;
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover" class="bg-zinc-950 text-zinc-100 antialiased">
|
||||
<div style="display: contents">%sveltekit.body%</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue