mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-04 04:51:16 +08:00
Enable PWA (#2142) by lukew3
* add pwa files * Added better 512px icon! (#2146) * updated icon Co-authored-by: Estebene <49330942+Estebene@users.noreply.github.com> Co-authored-by: Jack <bartnikjack@gmail.com>
This commit is contained in:
parent
ee143b4f12
commit
1bca5888f2
4 changed files with 36 additions and 0 deletions
BIN
static/images/mt-icon-512.png
Normal file
BIN
static/images/mt-icon-512.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.2 KiB |
|
@ -54,6 +54,7 @@
|
|||
crossorigin="anonymous"
|
||||
referrerpolicy="no-referrer"
|
||||
/>
|
||||
<link rel="manifest" href="manifest.json" />
|
||||
<meta name="name" content="Monkeytype" />
|
||||
<meta name="image" content="https://monkeytype.com/mtsocial.png" />
|
||||
<meta
|
||||
|
@ -94,6 +95,11 @@
|
|||
id="adScript"
|
||||
async
|
||||
></script>
|
||||
<script>
|
||||
if ("serviceWorker" in navigator) {
|
||||
navigator.serviceWorker.register("sw.js");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<div class="customBackground"></div>
|
||||
|
||||
|
|
15
static/manifest.json
Normal file
15
static/manifest.json
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"short_name": "MT",
|
||||
"name": "Monkeytype",
|
||||
"start_url": "/",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/images/mt-icon-512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png"
|
||||
}
|
||||
],
|
||||
"background_color": "#323437",
|
||||
"display": "standalone",
|
||||
"theme_color": "#323437"
|
||||
}
|
15
static/sw.js
Normal file
15
static/sw.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
self.addEventListener("install", function (event) {
|
||||
event.waitUntil(
|
||||
caches.open("sw-cache").then(function (cache) {
|
||||
return cache.add("index.html");
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener("fetch", function (event) {
|
||||
event.respondWith(
|
||||
caches.match(event.request).then(function (response) {
|
||||
return response || fetch(event.request);
|
||||
})
|
||||
);
|
||||
});
|
Loading…
Reference in a new issue