From 02af4b667e337b3f8043a0ed7fa645aaf6ad4a79 Mon Sep 17 00:00:00 2001 From: marcsello Date: Sun, 6 Dec 2020 03:55:59 +0100 Subject: [PATCH] Added user data loader --- src/App.vue | 31 +++++++++++++++++++++++++++++-- src/main.js | 4 ++-- src/store/auth.js | 41 +++++++++++++++++++++++++++++++---------- src/views/Dashboard.vue | 5 ++--- 4 files changed, 64 insertions(+), 17 deletions(-) diff --git a/src/App.vue b/src/App.vue index 712ea29..b571b0f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,12 +1,39 @@ - +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; + } + } + } +} +