diff --git a/renderer/plugins/pinia.ts b/renderer/plugins/pinia.ts index f00b209..08b0373 100644 --- a/renderer/plugins/pinia.ts +++ b/renderer/plugins/pinia.ts @@ -1,3 +1,6 @@ import { createPinia } from 'pinia' +import piniaPluginPersistedstate from 'pinia-plugin-persistedstate' -export default createPinia() +const pinia = createPinia() +pinia.use(piniaPluginPersistedstate) +export default pinia diff --git a/src/stores/counter.ts b/src/stores/counter.ts new file mode 100644 index 0000000..e9482ad --- /dev/null +++ b/src/stores/counter.ts @@ -0,0 +1,14 @@ +import { defineStore } from 'pinia' + +export const useCounterStore = defineStore('counter', { + state: () => ({ count: 0 }), + actions: { + increment() { + this.count++ + }, + reset() { + this.count = 0 + }, + }, + persist: true, +})