Deploy Life of Mellow PWA
This commit is contained in:
parent
0f46afd829
commit
cb004ca019
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"name": "Life of Mellow",
|
||||||
|
"short_name": "Mellow",
|
||||||
|
"description": "A cozy village sim — guide your Mellows to gather, build and thrive through the seasons.",
|
||||||
|
"start_url": "./",
|
||||||
|
"scope": "./",
|
||||||
|
"display": "standalone",
|
||||||
|
"orientation": "any",
|
||||||
|
"background_color": "#bfe0f0",
|
||||||
|
"theme_color": "#8db26a",
|
||||||
|
"categories": ["games", "entertainment"],
|
||||||
|
"icons": [
|
||||||
|
{ "src": "icon-192.png", "sizes": "192x192", "type": "image/png", "purpose": "any" },
|
||||||
|
{ "src": "icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "any" },
|
||||||
|
{ "src": "icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
/* Life of Mellow — service worker (offline app shell) */
|
||||||
|
const CACHE = 'mellow-v1';
|
||||||
|
const ASSETS = ['./', './index.html', './manifest.json', './icon-192.png', './icon-512.png'];
|
||||||
|
|
||||||
|
self.addEventListener('install', (e) => {
|
||||||
|
e.waitUntil(
|
||||||
|
caches.open(CACHE).then((c) => c.addAll(ASSETS)).then(() => self.skipWaiting())
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
self.addEventListener('activate', (e) => {
|
||||||
|
e.waitUntil(
|
||||||
|
caches.keys()
|
||||||
|
.then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k))))
|
||||||
|
.then(() => self.clients.claim())
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
self.addEventListener('fetch', (e) => {
|
||||||
|
if (e.request.method !== 'GET') return;
|
||||||
|
e.respondWith(
|
||||||
|
caches.match(e.request).then((hit) =>
|
||||||
|
hit || fetch(e.request).then((res) => {
|
||||||
|
const copy = res.clone();
|
||||||
|
caches.open(CACHE).then((c) => c.put(e.request, copy)).catch(() => {});
|
||||||
|
return res;
|
||||||
|
}).catch(() => caches.match('./index.html'))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue