mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender-pwa.git
synced 2026-01-18 03:42:26 +01:00
feat:#18 added default page setting
This commit is contained in:
@@ -16,12 +16,14 @@
|
||||
|
||||
import { defineStore } from "pinia";
|
||||
import { useLocalStorage } from "@vueuse/core";
|
||||
import router from "@/router";
|
||||
|
||||
const settingsStore = defineStore("settingsStore", {
|
||||
state: () => {
|
||||
return {
|
||||
locale: useLocalStorage("locale", "en"), //useLocalStorage takes in a key of 'count' and default value of 0
|
||||
isDark: true,
|
||||
defaultPage: useLocalStorage("defaultPage", ""),
|
||||
};
|
||||
},
|
||||
actions: {
|
||||
@@ -33,8 +35,23 @@ const settingsStore = defineStore("settingsStore", {
|
||||
},
|
||||
getDarkMode(): boolean {
|
||||
return this.isDark;
|
||||
}
|
||||
},
|
||||
setDefaultPage(page: string) {
|
||||
this.defaultPage = page;
|
||||
},
|
||||
getDefaultPageOptions(): string[] {
|
||||
// get a string array of all the route names
|
||||
const options: string[] = [];
|
||||
router.getRoutes().forEach((route) => {
|
||||
if (route.name) {
|
||||
if (typeof route.name === "string") {
|
||||
options.push(route.name);
|
||||
}
|
||||
}
|
||||
});
|
||||
return options;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default settingsStore;
|
||||
export default settingsStore;
|
||||
Reference in New Issue
Block a user