diff --git a/package.json b/package.json index e207eec..649e546 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,8 @@ "dayjs": "^1.11.9", "element-plus": "^2.7.6", "mqtt": "4.1.0", - "pinia": "2.0.17", + "pinia": "2.0.28", + "pinia-plugin-persistedstate": "^3.1.0", "tslib": "^2.6.2", "uview-plus": "^3.1.45", "vue": "3.4.23", diff --git a/src/store/index.ts b/src/store/index.ts index 7f06d64..755e335 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,4 +1,6 @@ import { createPinia } from "pinia" +import piniaPluginPersistedState from 'pinia-plugin-persistedstate' const store = createPinia() +store.use(piniaPluginPersistedState) export default store \ No newline at end of file diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index b44c1cd..d4ff043 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -91,6 +91,10 @@ const useUserStore = defineStore("user", { }); }, }, + persist: { + key: 'user', + storage: localStorage + } }); export default useUserStore;