-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.vue
More file actions
37 lines (32 loc) · 816 Bytes
/
app.vue
File metadata and controls
37 lines (32 loc) · 816 Bytes
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
<template>
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
<PrimeToast position="top-right" />
</template>
<script setup lang="ts">
import PrimeToast from 'primevue/toast';
import { storeToRefs } from 'pinia';
import { useMainStore } from '~/stores/main';
const mainStore = useMainStore();
const { notifications} = storeToRefs(mainStore);
const { vueApp } = useNuxtApp();
// Синхронизация уведомлений
watch(
notifications,
(messages) => {
if (messages.length > 0) {
messages.forEach((item) => {
vueApp.config.globalProperties.$toast.add({
severity: item.type,
summary: item.message,
detail: item.detail,
life: item.life,
});
});
mainStore.clearNotifications();
}
},
{ deep: true },
);
</script>