|
|
@ -2,35 +2,11 @@ import { |
|
|
|
createRouter, |
|
|
|
createWebHistory, |
|
|
|
createMemoryHistory, |
|
|
|
NavigationGuardNext, |
|
|
|
RouteLocationNormalized, |
|
|
|
RouteRecordRaw, |
|
|
|
} from "vue-router"; |
|
|
|
import { accountsDBPromise } from "../db/index"; |
|
|
|
import { logger } from "../utils/logger"; |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* @param to :RouteLocationNormalized |
|
|
|
* @param from :RouteLocationNormalized |
|
|
|
* @param next :NavigationGuardNext |
|
|
|
*/ |
|
|
|
const enterOrStart = async ( |
|
|
|
to: RouteLocationNormalized, |
|
|
|
from: RouteLocationNormalized, |
|
|
|
next: NavigationGuardNext, |
|
|
|
) => { |
|
|
|
// one of the few times we use accountsDBPromise directly; try to avoid more usage
|
|
|
|
const accountsDB = await accountsDBPromise; |
|
|
|
const num_accounts = await accountsDB.accounts.count(); |
|
|
|
|
|
|
|
if (num_accounts > 0) { |
|
|
|
next(); |
|
|
|
} else { |
|
|
|
next({ name: "start" }); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
const routes: Array<RouteRecordRaw> = [ |
|
|
|
{ |
|
|
|
path: "/account", |
|
|
@ -216,7 +192,6 @@ const routes: Array<RouteRecordRaw> = [ |
|
|
|
path: "/projects", |
|
|
|
name: "projects", |
|
|
|
component: () => import("../views/ProjectsView.vue"), |
|
|
|
beforeEnter: enterOrStart, |
|
|
|
}, |
|
|
|
{ |
|
|
|
path: "/quick-action-bvc", |
|
|
|