forked from jsnbuchanan/crowd-funder-for-time-pwa
Fix to new routing rules
This commit is contained in:
@@ -112,20 +112,31 @@ const router = createRouter({
|
|||||||
|
|
||||||
router.beforeEach(async (to) => {
|
router.beforeEach(async (to) => {
|
||||||
// redirect to start page if app is uninitialized
|
// redirect to start page if app is uninitialized
|
||||||
const publicPages = ["/start"];
|
const publicPages = ["/start", "/account", "/import-account"];
|
||||||
const authRequired = !publicPages.includes(to.path);
|
const isPublic = publicPages.includes(to.path);
|
||||||
|
const appStore = useAppStore();
|
||||||
|
console.log("to:", to.path);
|
||||||
let return_path = "/start";
|
let return_path = "/start";
|
||||||
if (authRequired) {
|
if (isPublic) {
|
||||||
switch (useAppStore().condition) {
|
console.log(appStore.condition);
|
||||||
|
switch (appStore.condition) {
|
||||||
case "uninitialized":
|
case "uninitialized":
|
||||||
return_path = "/start";
|
return_path = "";
|
||||||
break;
|
break;
|
||||||
case "registering":
|
case "registering":
|
||||||
return_path = useAppStore().lastView;
|
return_path = to.path;
|
||||||
break;
|
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;
|
export default router;
|
||||||
|
|||||||
@@ -4,19 +4,17 @@ import { defineStore } from "pinia";
|
|||||||
export const useAppStore = defineStore({
|
export const useAppStore = defineStore({
|
||||||
id: "app",
|
id: "app",
|
||||||
state: () => ({
|
state: () => ({
|
||||||
condition: JSON.parse(
|
_condition:
|
||||||
typeof localStorage["condition"] == "undefined"
|
typeof localStorage["condition"] == "undefined"
|
||||||
? "uninitialized"
|
? "uninitialized"
|
||||||
: localStorage["condition"]
|
: localStorage["condition"],
|
||||||
),
|
_lastView:
|
||||||
lastView: JSON.parse(
|
|
||||||
typeof localStorage["lastView"] == "undefined"
|
typeof localStorage["lastView"] == "undefined"
|
||||||
? "/start"
|
? "/start"
|
||||||
: localStorage["lastView"]
|
: localStorage["lastView"],
|
||||||
),
|
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
condition: (state) => state.condition,
|
condition: (state) => state._condition,
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
reset() {
|
reset() {
|
||||||
|
|||||||
Reference in New Issue
Block a user