From fc7167246d50dcaced7eec167b8fb964d3e62a69 Mon Sep 17 00:00:00 2001 From: sunshine <1467939124@qq.com> Date: Fri, 2 Aug 2024 09:34:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=95=E5=85=A5=E6=8C=81=E4=B9=85=E5=8C=96?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=EF=BC=8C=E8=A7=A3=E5=86=B3=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E5=90=8E=E4=B8=A2=E5=A4=B1token=EF=BC=8C=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E9=87=8D=E6=96=B0=E7=99=BB=E5=BD=95bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 ++- src/store/index.ts | 2 ++ src/store/modules/user.ts | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) 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;