fix:#18 reroute for default page only applies to empty paths

This commit is contained in:
Elmar Kresse
2024-07-21 22:21:14 +02:00
parent 059b8ca24b
commit 5330ade54e
8 changed files with 80 additions and 23 deletions

View File

@@ -23,7 +23,7 @@ const settingsStore = defineStore("settingsStore", {
return {
locale: useLocalStorage("locale", "en"), //useLocalStorage takes in a key of 'count' and default value of 0
isDark: true,
defaultPage: useLocalStorage("defaultPage", ""),
defaultPage: useLocalStorage("defaultPage", {label: "Home", value: "/home"}),
};
},
actions: {
@@ -36,19 +36,31 @@ const settingsStore = defineStore("settingsStore", {
getDarkMode(): boolean {
return this.isDark;
},
setDefaultPage(page: string) {
setDefaultPage(page: {
label: string;
value: string;
}) {
this.defaultPage = page;
},
getDefaultPageOptions(): string[] {
getDefaultPageOptions(): {
label: string;
value: string;
}[] {
// get a string array of all the route names
const options: string[] = [];
const options: {
label: string;
value: string;
}[] = [];
router.getRoutes().forEach((route) => {
if (route.name) {
if (typeof route.name === "string") {
options.push(route.name);
options.push({
label: route.name,
value: route.path,
});
}
}
}
});
});
return options;
},
},