🍎 Makes app installable
This commit is contained in:
+2
-1
@@ -2,7 +2,8 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/png" href="/logo_512.png" />
|
||||
<link rel="icon" type="image/png" href="/logo512.png" />
|
||||
<link rel="manifest" href="/manifest.json">
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 151 KiB |
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"short_name": "Quadruped Controller",
|
||||
"name": "Quadruped Controller",
|
||||
"icons": [
|
||||
{
|
||||
"src": "logo512.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
],
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#ffffff"
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
const CACHE_NAME = 'v1';
|
||||
const urlsToCache = ['/', '/index.html', '/stl.zip'];
|
||||
|
||||
self.addEventListener('install', (event) => {
|
||||
event.waitUntil(
|
||||
caches.open(CACHE_NAME).then((cache) => {
|
||||
return cache.addAll(urlsToCache);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
// self.addEventListener('fetch', (event) => {
|
||||
// event.respondWith(
|
||||
// caches.match(event.request).then((response) => {
|
||||
// if (response) {
|
||||
// return response;
|
||||
// }
|
||||
// return fetch(event.request).then((response) => {
|
||||
// if (!response || response.status !== 200 || response.type !== 'basic') {
|
||||
// return response;
|
||||
// }
|
||||
// var responseToCache = response.clone();
|
||||
// caches.open(CACHE_NAME).then((cache) => {
|
||||
// cache.put(event.request, responseToCache);
|
||||
// });
|
||||
// return response;
|
||||
// });
|
||||
// })
|
||||
// );
|
||||
// });
|
||||
|
||||
self.addEventListener('activate', (event) => {
|
||||
var cacheWhitelist = ['v1'];
|
||||
event.waitUntil(
|
||||
caches.keys().then((cacheNames) => {
|
||||
return Promise.all(
|
||||
cacheNames.map((cacheName) => {
|
||||
if (cacheWhitelist.indexOf(cacheName) === -1) {
|
||||
return caches.delete(cacheName);
|
||||
}
|
||||
})
|
||||
);
|
||||
})
|
||||
);
|
||||
});
|
||||
@@ -2,6 +2,12 @@ import './app.css';
|
||||
import './index.css';
|
||||
import App from './App.svelte';
|
||||
|
||||
if ('serviceWorker' in navigator) {
|
||||
window.addEventListener('load', () => {
|
||||
navigator.serviceWorker.register('/sw.js');
|
||||
});
|
||||
}
|
||||
|
||||
const app = new App({
|
||||
target: document.getElementById('app') as HTMLElement
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user