-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
368 additions
and
537 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<script setup> | ||
import { onBeforeMount, ref } from 'vue' | ||
const offlineReady = ref(false) | ||
function onOfflineReady() { | ||
offlineReady.value = true | ||
} | ||
async function close() { | ||
offlineReady.value = false | ||
} | ||
onBeforeMount(async () => { | ||
const { registerSW } = await import('virtual:pwa-register') | ||
registerSW({ | ||
immediate: true, | ||
onOfflineReady, | ||
onRegistered() { | ||
console.info('Service Worker registered') | ||
}, | ||
onRegisterError(e) { | ||
console.error('Service Worker registration error!', e) | ||
}, | ||
}) | ||
}) | ||
</script> | ||
|
||
<template lang="pug"> | ||
template(v-if="offlineReady") | ||
.pwa-toast(role="alertdialog", aria-labelledby="pwa-message") | ||
#pwa-message.mb-3 App ready to work offline | ||
button.pwa-cancel(type="button", @click="close") Close | ||
</template> | ||
|
||
<style> | ||
.pwa-toast { | ||
position: fixed; | ||
right: 0; | ||
bottom: 0; | ||
margin: 16px; | ||
padding: 12px; | ||
border: 1px solid #8885; | ||
border-radius: 4px; | ||
z-index: 100; | ||
text-align: left; | ||
box-shadow: 3px 4px 5px 0 #8885; | ||
background-color: gray; | ||
} | ||
.pwa-toast #pwa-message { | ||
margin-bottom: 8px; | ||
} | ||
.pwa-toast button { | ||
border: 1px solid #8885; | ||
outline: none; | ||
margin-right: 5px; | ||
border-radius: 2px; | ||
padding: 3px 10px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.