Skip to content

Commit

Permalink
feat: ✨ Add custom page if no connection available
Browse files Browse the repository at this point in the history
  • Loading branch information
NadeigeC committed Mar 20, 2023
1 parent ac7d826 commit 925d7e9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
<script setup>
import { ref, onMounted, onBeforeUnmount } from 'vue'
import { registerSW } from 'virtual:pwa-register'
import { useAppStore } from './stores/app.js'
import HeaderMain from './components/HeaderMain.vue'
const appStore = useAppStore()
const online = ref(navigator.onLine)
const updateOnlineStatus = () => {
online.value = navigator.onLine
}
onMounted(() => {
window.addEventListener('online', updateOnlineStatus)
window.addEventListener('offline', updateOnlineStatus)
})
onBeforeUnmount(() => {
window.removeEventListener('online', updateOnlineStatus)
window.removeEventListener('offline', updateOnlineStatus)
})
registerSW({ immediate: true })
</script>
Expand Down

0 comments on commit 925d7e9

Please sign in to comment.