diff --git a/icons/icon-192.png b/icons/icon-192.png new file mode 100644 index 0000000..991ab68 Binary files /dev/null and b/icons/icon-192.png differ diff --git a/icons/icon-512.png b/icons/icon-512.png new file mode 100644 index 0000000..83a013b Binary files /dev/null and b/icons/icon-512.png differ diff --git a/index.html b/index.html index da04a95..6d2766d 100644 --- a/index.html +++ b/index.html @@ -7,8 +7,11 @@ content="width=device-width, initial-scale=1.0, user-scalable=no" /> + 梅子的成语填字 - + + +
@@ -158,7 +161,12 @@
- - + + + diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..f0562c3 --- /dev/null +++ b/manifest.json @@ -0,0 +1,24 @@ +{ + "name": "梅子的成语填字", + "short_name": "成语填字", + "description": "每天练习成语填字,越练越强!", + "start_url": "/", + "display": "standalone", + "background_color": "#1a1a2e", + "theme_color": "#1a1a2e", + "orientation": "portrait", + "icons": [ + { + "src": "icons/icon-192.png?v=3", + "sizes": "192x192", + "type": "image/png", + "purpose": "any maskable" + }, + { + "src": "icons/icon-512.png?v=3", + "sizes": "512x512", + "type": "image/png", + "purpose": "any maskable" + } + ] +} diff --git a/sw.js b/sw.js new file mode 100644 index 0000000..c2f8173 --- /dev/null +++ b/sw.js @@ -0,0 +1,33 @@ +const CACHE_NAME = 'chengyu-v1'; +const ASSETS = [ + '/', + '/index.html', + '/style.css', + '/app.js', + '/data.js', + '/manifest.json', + '/icons/icon-192.png', + '/icons/icon-512.png' +]; + +self.addEventListener('install', e => { + e.waitUntil( + caches.open(CACHE_NAME).then(cache => cache.addAll(ASSETS)) + ); + self.skipWaiting(); +}); + +self.addEventListener('activate', e => { + e.waitUntil( + caches.keys().then(keys => + Promise.all(keys.filter(k => k !== CACHE_NAME).map(k => caches.delete(k))) + ) + ); + self.clients.claim(); +}); + +self.addEventListener('fetch', e => { + e.respondWith( + caches.match(e.request).then(cached => cached || fetch(e.request)) + ); +});