Browse Source

Adding an appStore Pinia datastore

kb/add-usage-guide
Matthew Aaron Raymer 2 years ago
parent
commit
ed23317b0f
  1. 1
      src/main.ts
  2. 21
      src/store/app.ts

1
src/main.ts

@ -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

@ -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");
},
},
});
Loading…
Cancel
Save