Added user data loader
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
31
src/App.vue
31
src/App.vue
@@ -1,12 +1,39 @@
|
||||
<template>
|
||||
<div id="app">
|
||||
<router-view/>
|
||||
|
||||
<md-snackbar md-position="center" :md-duration="4000" :md-active.sync="showWelcome">
|
||||
<span>Welcome back {{ $store.state.auth.name }}!</span>
|
||||
</md-snackbar>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
<script>
|
||||
|
||||
</style>
|
||||
import {mapState} from 'vuex';
|
||||
|
||||
export default {
|
||||
name: "App",
|
||||
data() {
|
||||
return {
|
||||
showWelcome: false
|
||||
}
|
||||
},
|
||||
computed: mapState('auth', ['name']),
|
||||
mounted() {
|
||||
this.$store.dispatch("auth/loadUserData").catch(() => {
|
||||
this.$router.push({name: "Welcome"});
|
||||
})
|
||||
},
|
||||
watch: {
|
||||
name(newValue, oldValue) {
|
||||
if (oldValue === '') {
|
||||
this.showWelcome = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
#app {
|
||||
|
||||
Reference in New Issue
Block a user