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 @@