-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApp.vue
More file actions
43 lines (38 loc) · 1 KB
/
Copy pathApp.vue
File metadata and controls
43 lines (38 loc) · 1 KB
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
<template>
<RouterView />
</template>
<script setup>
import { useEmitter } from '@/composables/useEmitter';
import { useKeepAwake } from '@/composables/useKeepAwake';
import { useSettingsStore } from '@/stores/settings';
import { log } from '@/utils/log';
import { isMobile } from '@/utils/platform';
import { stringify } from '@/utils/stringify';
import { toast } from '@/utils/toast';
import { useEventListener } from '@vueuse/core';
import { storeToRefs } from 'pinia';
useKeepAwake();
const { settings } = storeToRefs(useSettingsStore());
useEmitter(log, '*', (level, ...args) => {
if (settings.value.logAsNotification) {
let type;
switch (level) {
case 'warn':
type = 'warning';
break;
case 'error':
type = 'error';
break;
default:
type = 'info';
break;
}
toast(args.map(stringify).join(' '), { type });
}
});
if (isMobile) {
useEventListener('error', ({ message }) => {
toast(message, { type: 'error' });
});
}
</script>