@ -1,12 +1,12 @@
import { createRouter , createWebHistory , RouteRecordRaw } from "vue-router" ;
import { createRouter , createWebHistory , RouteRecordRaw } from "vue-router" ;
import { useAppStore } from "../store/app" ;
import { useAppStore } from "../store/app" ;
import HomeView from "../views/HomeView.vue" ;
const routes : Array < RouteRecordRaw > = [
const routes : Array < RouteRecordRaw > = [
{
{
path : "/" ,
path : "/" ,
name : "home" ,
name : "home" ,
component : HomeView ,
component : ( ) = >
import ( /* webpackChunkName: "start" */ "../views/DiscoverView.vue" ) ,
} ,
} ,
{
{
path : "/about" ,
path : "/about" ,
@ -111,26 +111,28 @@ const router = createRouter({
routes ,
routes ,
} ) ;
} ) ;
router . beforeEach ( async ( to ) = > {
router . beforeEach ( async ( to , from , next ) = > {
const publicPages = [ "/start" , "/account" , "/import-account" ] ;
const publicPages = [ "/start" , "/account" , "/import-account" ] ;
const isPublic = publicPages . includes ( to . path ) ;
const isPublic = publicPages . includes ( to . path ) ;
const appStore = useAppStore ( ) ;
const appStore = useAppStore ( ) ;
let return_path = "/start" ;
let return_path = "/start" ;
if ( to . path === "/" && appStore . condition == "registered" ) {
return_path = "/account" ;
}
if ( isPublic ) {
if ( isPublic ) {
switch ( appStore . condition ) {
switch ( appStore . condition ) {
case "uninitialized" :
case "uninitialized" :
return_path = "" ;
return_path = "" ;
break ;
break ;
case "registered" :
case "registered" :
return_path = to . path ;
next ( ) ;
break ;
break ;
}
}
}
}
if ( return_path == "" ) {
if ( return_path == "" ) {
return ;
return ;
} else {
} else {
return return_path ;
next ( ) ;
}
}
} ) ;
} ) ;