|
|
@ -112,20 +112,31 @@ const router = createRouter({ |
|
|
|
|
|
|
|
router.beforeEach(async (to) => { |
|
|
|
// redirect to start page if app is uninitialized
|
|
|
|
const publicPages = ["/start"]; |
|
|
|
const authRequired = !publicPages.includes(to.path); |
|
|
|
|
|
|
|
const publicPages = ["/start", "/account", "/import-account"]; |
|
|
|
const isPublic = publicPages.includes(to.path); |
|
|
|
const appStore = useAppStore(); |
|
|
|
console.log("to:", to.path); |
|
|
|
let return_path = "/start"; |
|
|
|
if (authRequired) { |
|
|
|
switch (useAppStore().condition) { |
|
|
|
if (isPublic) { |
|
|
|
console.log(appStore.condition); |
|
|
|
switch (appStore.condition) { |
|
|
|
case "uninitialized": |
|
|
|
return_path = "/start"; |
|
|
|
return_path = ""; |
|
|
|
break; |
|
|
|
case "registering": |
|
|
|
return_path = useAppStore().lastView; |
|
|
|
return_path = to.path; |
|
|
|
break; |
|
|
|
} |
|
|
|
} else { |
|
|
|
switch (appStore.condition) { |
|
|
|
case "registered": |
|
|
|
return_path = to.path; |
|
|
|
} |
|
|
|
} |
|
|
|
if (return_path == "") { |
|
|
|
return; |
|
|
|
} else { |
|
|
|
return return_path; |
|
|
|
} |
|
|
|
return return_path; |
|
|
|
}); |
|
|
|
export default router; |
|
|
|