-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.vue
42 lines (35 loc) · 1.02 KB
/
app.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<script setup lang="ts">
import { ref } from 'vue';
import { useMedicineStore } from '@/store';
import ReloadPrompt from '@/components/reload-prompt.vue';
import type { Medicine } from '@/types';
import CurrentMedicine from '@/components/current-medicine.vue';
// import {registerServiceWorker} from './service/notification';
const medicineStore = useMedicineStore();
const currentMedicine = ref<Medicine | undefined>();
onBeforeMount(() => {
medicineStore.init();
});
onMounted(() => {
// registerServiceWorker();
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'visible') {
currentMedicine.value = medicineStore.getCurrentMedicine();
}
});
setInterval(() => {
currentMedicine.value = medicineStore.getCurrentMedicine();
}, 60000);
});
</script>
<template lang="pug">
vite-pwa-manifest
.container.mx-auto.h-full
router-view
current-medicine(
v-if="currentMedicine"
:medicine="currentMedicine"
@dismiss="currentMedicine = null"
)
reload-prompt
</template>