From f93198ebee8615debee4ee88520da88e643471ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolphe=20Br=C3=A9ard?= Date: Sun, 30 Jul 2023 16:40:58 +0200 Subject: [PATCH] Use accounts from the storage --- src/router/index.js | 17 +++++++++++++++-- src/views/MainView.vue | 34 +++++++++++++++------------------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index b29970c..76c9bb7 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,13 +1,26 @@ import {createRouter, createMemoryHistory} from 'vue-router'; +import { useStorage } from '@vueuse/core' import MainView from '../views/MainView.vue'; import AddAccountView from '../views/AddAccountView.vue'; +const accounts = useStorage('sake-accounts', []); const router = createRouter({ history: createMemoryHistory(), routes: [ - {path: '/', component: MainView}, - {path: '/add-account', component: AddAccountView}, + { + path: '/', + component: MainView, + beforeEnter: (to, from) => { + if (!accounts.value.length) { + return '/add-account'; + } + } + }, + { + path: '/add-account', + component: AddAccountView + }, ] }); diff --git a/src/views/MainView.vue b/src/views/MainView.vue index 71b3c73..969fcc4 100644 --- a/src/views/MainView.vue +++ b/src/views/MainView.vue @@ -1,33 +1,29 @@