Icone
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
|
||||
<meta name="theme-color" content="#2563eb" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-title" content="Professeur TOP" />
|
||||
<link rel="manifest" href="/manifest.webmanifest" />
|
||||
<link rel="icon" type="image/png" sizes="192x192" href="/icons/professeur-top-install-v2-192.png" />
|
||||
<link rel="apple-touch-icon" href="/icons/professeur-top-install-v2-192.png" />
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
"display": "standalone",
|
||||
"background_color": "#f5f7fb",
|
||||
"theme_color": "#2563eb",
|
||||
"orientation": "portrait",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/icons/professeur-top-install-v2-192.png",
|
||||
|
||||
@@ -1,9 +1,38 @@
|
||||
self.addEventListener('install', () => {
|
||||
const CACHE_NAME = 'professeur-top-v3'
|
||||
const ASSETS = [
|
||||
'/',
|
||||
'/manifest.webmanifest',
|
||||
'/icons/professeur-top-install-v2-192.png',
|
||||
'/icons/professeur-top-install-v2-512.png',
|
||||
]
|
||||
|
||||
self.addEventListener('install', (event) => {
|
||||
event.waitUntil(caches.open(CACHE_NAME).then((cache) => cache.addAll(ASSETS)))
|
||||
self.skipWaiting()
|
||||
})
|
||||
|
||||
self.addEventListener('activate', (event) => {
|
||||
event.waitUntil(self.clients.claim())
|
||||
event.waitUntil(
|
||||
caches.keys().then((keys) =>
|
||||
Promise.all(keys.filter((key) => key !== CACHE_NAME).map((key) => caches.delete(key)))
|
||||
)
|
||||
)
|
||||
self.clients.claim()
|
||||
})
|
||||
|
||||
self.addEventListener('fetch', () => {})
|
||||
self.addEventListener('fetch', (event) => {
|
||||
if (event.request.method !== 'GET') return
|
||||
|
||||
const url = new URL(event.request.url)
|
||||
if (url.origin !== self.location.origin || url.pathname.startsWith('/api/')) return
|
||||
|
||||
event.respondWith(
|
||||
fetch(event.request)
|
||||
.then((response) => {
|
||||
const copy = response.clone()
|
||||
caches.open(CACHE_NAME).then((cache) => cache.put(event.request, copy))
|
||||
return response
|
||||
})
|
||||
.catch(() => caches.match(event.request).then((cached) => cached || caches.match('/')))
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user