Adding an appStore Pinia datastore

This commit is contained in:
Matthew Aaron Raymer
2022-12-05 17:50:28 +08:00
parent 3c843b2f16
commit ed23317b0f
2 changed files with 22 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
import { createPinia } from "pinia";
import { createApp } from "vue";
import { useAppStore } from "./store/app";
import App from "./App.vue";
import "./registerServiceWorker";
import router from "./router";

21
src/store/app.ts Normal file
View File

@@ -0,0 +1,21 @@
// @ts-check
import { defineStore } from "pinia";
export const useAppStore = defineStore({
id: "account",
state: () => ({
condition: JSON.parse(
typeof localStorage["app_condition"] == "undefined"
? "uninitialized"
: localStorage["app_condition"]
),
}),
getters: {
condition: (state) => state.condition,
},
actions: {
reset() {
localStorage.removeItem("app_condition");
},
},
});