Skip to content

Commit 5fdde7f

Browse files
authored
Merge pull request #7 from niivue/feature/pwd
add basic pwa support
2 parents e2ca1ce + fbb42d0 commit 5fdde7f

File tree

5 files changed

+49
-4
lines changed

5 files changed

+49
-4
lines changed

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<meta charset="UTF-8" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<link rel="stylesheet" href="./niivue.css" />
8+
<link rel="manifest" href="./manifest.json" />
89
<title>brain2print</title>
910
</head>
1011

main.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,30 @@ const pipelinesBaseUrl = new URL(`${viteBaseUrl}pipelines`, document.location.or
2121
setCuberillePipelinesUrl(pipelinesBaseUrl)
2222
setMeshFiltersPipelinesUrl(pipelinesBaseUrl)
2323

24+
self.addEventListener("install", (event) => {
25+
event.waitUntil(
26+
caches.open("app-static-v1").then((cache) => {
27+
return cache.addAll([
28+
"./",
29+
"./index.html",
30+
"./manifest.json",
31+
"./models",
32+
"./pipelines",
33+
"./assets",
34+
"./t1_crop.nii.gz",
35+
"./niivue.css"]);
36+
})
37+
);
38+
});
39+
40+
self.addEventListener("fetch", (event) => {
41+
event.respondWith(
42+
caches.match(event.request).then((response) => {
43+
return response || fetch(event.request);
44+
})
45+
);
46+
});
47+
2448
async function main() {
2549
const niimath = new Niimath()
2650
await niimath.init()

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/icon.png

85 KB
Loading

public/manifest.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "brain2print",
3+
"short_name": "brain2print",
4+
"start_url": "./index.html",
5+
"display": "standalone",
6+
"background_color": "#ffffff",
7+
"theme_color": "#333333",
8+
"icons": [
9+
{
10+
"src": "icon.png",
11+
"sizes": "192x192",
12+
"type": "image/png"
13+
},
14+
{
15+
"src": "icon.png",
16+
"sizes": "512x512",
17+
"type": "image/png"
18+
}
19+
]
20+
}

0 commit comments

Comments
 (0)