/
App.vue
66 lines (62 loc) · 1.56 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
<template>
<v-app>
<v-app-bar app color="green">
<v-toolbar-title class="headline text-uppercase">
<v-btn text to="/">Vue Screencasts</v-btn>
</v-toolbar-title>
<v-btn text to="/admin/videos" v-if="currentUser.admin">Admin</v-btn>
<v-spacer></v-spacer>
<div v-if="currentUser.name">
{{ currentUser.name }}
<v-btn text class="mr-2" @click="logoutUser">Logout</v-btn>
</div>
<div v-else>
<v-btn text class="mr-2" to="/login">Login</v-btn>
<v-btn text class="mr-2" to="/registration">Register</v-btn>
</div>
</v-app-bar>
<v-content>
<router-view />
</v-content>
<v-snackbar
v-for="(snackbar, index) in snackbars.filter(s => s.showing)"
:key="snackbar.text + Math.random()"
v-model="snackbar.showing"
:timeout="snackbar.timeout"
:color="snackbar.color"
:style="`bottom: ${(index * 60) + 8}px`"
>
{{snackbar.text}}
<v-btn text @click="snackbar.showing = false">
Close
</v-btn>
</v-snackbar>
</v-app>
</template>
<script>
import { mapState } from 'vuex';
export default {
name: 'App',
created(){
this.$store.dispatch('loadVideos');
this.$store.dispatch('loadCurrentUser');
this.$store.dispatch('tags/loadAll');
},
components: {
},
computed: {
...mapState({
currentUser: 'currentUser',
snackbars: state => state.snackbar.snackbars
})
},
data: () => ({
//
}),
methods: {
logoutUser() {
this.$store.dispatch("logoutUser");
}
},
};
</script>