From ed23317b0f4347fea00d7c327a8cb3992b7e2250 Mon Sep 17 00:00:00 2001 From: Matthew Aaron Raymer Date: Mon, 5 Dec 2022 17:50:28 +0800 Subject: [PATCH] Adding an appStore Pinia datastore --- src/main.ts | 1 + src/store/app.ts | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/store/app.ts diff --git a/src/main.ts b/src/main.ts index 01814f63f..738a07911 100644 --- a/src/main.ts +++ b/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"; diff --git a/src/store/app.ts b/src/store/app.ts new file mode 100644 index 000000000..364adae51 --- /dev/null +++ b/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"); + }, + }, +});