/
App.vue
77 lines (73 loc) · 1.42 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<template>
<v-app v-if="!isAuthenticated">
<v-main>
<router-view />
</v-main>
</v-app>
<v-app v-else>
<navbar />
<v-main>
<v-container fluid>
<router-view/>
</v-container>
</v-main>
<v-snackbar
v-model="snackbar"
:color="notificationColor"
:timeout="notificationTimeout"
top
>
{{ notification }}
<template v-slot:action="{ attrs }">
<v-btn
color="white"
text
v-bind="attrs"
@click="snackbar = false"
>
<translate>Close</translate>
</v-btn>
</template>
</v-snackbar>
</v-app>
</template>
<script>
import { mapGetters } from 'vuex'
import { bus } from '@/main'
import Navbar from '@/components/layout/Navbar'
export default {
name: 'App',
computed: {
...mapGetters({
isAuthenticated: 'auth/isAuthenticated'
})
},
components: {
Navbar
},
created () {
// this.$store.dispatch('auth/initialize')
bus.$on('notification', this.showNotification)
},
data: () => ({
snackbar: false,
notification: '',
notificationColor: 'success',
notificationTimeout: 2000
}),
methods: {
showNotification (options) {
if (this.isAuthenticated) {
this.notification = options.msg
this.notificationColor = (options.type) ? options.type : 'success'
this.snackbar = true
}
}
}
}
</script>
<style scoped>
.v-main {
background-color: #f7f8fa;
}
</style>