forked from jsnbuchanan/crowd-funder-for-time-pwa
Adding an appStore Pinia datastore
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { createPinia } from "pinia";
|
import { createPinia } from "pinia";
|
||||||
import { createApp } from "vue";
|
import { createApp } from "vue";
|
||||||
|
import { useAppStore } from "./store/app";
|
||||||
import App from "./App.vue";
|
import App from "./App.vue";
|
||||||
import "./registerServiceWorker";
|
import "./registerServiceWorker";
|
||||||
import router from "./router";
|
import router from "./router";
|
||||||
|
|||||||
21
src/store/app.ts
Normal file
21
src/store/app.ts
Normal 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");
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user