Add PWA support

This commit is contained in:
kwaroran
2024-09-10 22:09:58 +09:00
parent 17af14b1ee
commit 3ae2c11ca4
8 changed files with 300 additions and 84 deletions

BIN
public/logo_192.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

BIN
public/logo_512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@@ -35,6 +35,36 @@ self.addEventListener('fetch', (event) => {
}
case "init":{
event.respondWith(new Response("v2"))
break
}
case 'share':{
event.respondWith((async () => {
const formData = await event.request.formData();
/**
* @type {File}
*/
const character = formData.get('character')
const preset = formData.get('preset')
const module = formData.get('module')
if(character){
const buf = await character.arrayBuffer()
await registerCache(`/sw/share/character`, buf, true)
return Response.redirect("/#share_character", 303)
}
if(preset){
const buf = await preset.arrayBuffer()
await registerCache(`/sw/share/preset`, buf, true)
return Response.redirect("/#share_preset", 303)
}
if(module){
const buf = await module.arrayBuffer()
await registerCache(`/sw/share/module`, buf, true)
return Response.redirect("/#share_module", 303)
}
return Response.redirect("/", 303)
})())
break
}
default: {
event.respondWith(new Response(