-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathapp.vue
60 lines (54 loc) · 1.53 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<template>
<div>
<NuxtPwaManifest />
<div class="min-h-screen bg-gray-950">
<NuxtLayout v-if="serialStore.hasSerial" class="h-full">
<NuxtPage />
</NuxtLayout>
<div v-else>
No WebSerial
</div>
<UNotifications />
</div>
</div>
</template>
<script setup>
import { Direct } from './src/communication/direct';
import { FourWay } from './src/communication/four_way';
import Msp from './src/communication/msp';
const { $pwa } = useNuxtApp();
const toast = useToast();
onMounted(() => {
if ($pwa.offlineReady) {
toast.add({
icon: 'i-material-symbols-install-desktop',
color: 'green',
title: 'Installation',
description: 'App successfully installed. Offline work available.'
});
}
if ($pwa.needRefresh) {
toast.add({
icon: 'i-material-symbols-cloud-sync',
color: 'green',
title: 'Update',
description: 'Update avaiable, please reload.',
timeout: 3,
callback: () => {
window.location.reload();
}
});
}
});
const serialStore = useSerialStore();
const { log, logWarning, logError } = useLogStore();
if (navigator && 'serial' in navigator) {
serialStore.hasSerial = true;
Msp.init(log, logWarning, logError);
FourWay.init(log, logWarning, logError);
Direct.init(log, logWarning, logError);
log('initializing...');
} else {
logError('WebSerial not supported, use other browser!');
}
</script>