Flesh out a bit more of the import and also refactor the router

This commit is contained in:
Matthew Aaron Raymer
2022-12-21 18:02:19 +08:00
parent 07f763e167
commit 65381e103c
2 changed files with 46 additions and 38 deletions

View File

@@ -115,22 +115,20 @@ router.beforeEach(async (to, from, next) => {
const publicPages = ["/start", "/account", "/import-account"];
const isPublic = publicPages.includes(to.path);
const appStore = useAppStore();
let return_path = "/start";
if (to.path === "/" && appStore.condition == "registered") {
return_path = "/account";
}
if (isPublic) {
console.log(to);
if (to.path === "/" && appStore.condition === "registered") {
next({ path: "/account" });
} else if (isPublic) {
switch (appStore.condition) {
case "uninitialized":
return_path = "";
break;
case "registered":
next();
break;
default:
next();
break;
}
}
if (return_path == "") {
return;
} else if (appStore.condition === "uninitialized") {
next({ path: "/start" });
} else {
next();
}