mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-20 08:52:59 +00:00
add pwa functionality
This commit is contained in:
@@ -17,6 +17,9 @@
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
{#await import("$lib/components/PwaStatus.svelte") then { default: PwaStatus }}
|
||||
<PwaStatus />
|
||||
{/await}
|
||||
{#if browser && !("serial" in navigator)}
|
||||
<abbr
|
||||
title="Your browser does not support serial connections. Try using Chrome instead."
|
||||
|
||||
36
src/lib/components/PwaStatus.svelte
Normal file
36
src/lib/components/PwaStatus.svelte
Normal file
@@ -0,0 +1,36 @@
|
||||
<script>
|
||||
import {useRegisterSW} from "virtual:pwa-register/svelte"
|
||||
|
||||
const {needRefresh, updateServiceWorker, offlineReady} = useRegisterSW()
|
||||
</script>
|
||||
|
||||
{#if !$needRefresh}
|
||||
<button title="Update ready" class="icon" on:click={() => updateServiceWorker(true)}>update</button>
|
||||
{:else if $offlineReady}
|
||||
<div title="App can now be used offline" class="icon">offline_pin</div>
|
||||
{:else}
|
||||
<div title="Waiting to be offline ready..." class="icon working">offline_bolt</div>
|
||||
{/if}
|
||||
|
||||
<style lang="scss">
|
||||
button {
|
||||
cursor: pointer;
|
||||
color: var(--md-sys-color-on-background);
|
||||
background: transparent;
|
||||
border: none;
|
||||
}
|
||||
|
||||
@keyframes working {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.working {
|
||||
animation: working 1s ease alternate-reverse infinite;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user