From 435cb1ce452bf936ebf603a0e40f48abe37899de Mon Sep 17 00:00:00 2001
From: Your Name <123456>
Date: 星期五, 26 八月 2022 10:12:43 +0800
Subject: [PATCH] 持久

---
 src/stores/userInfo.ts |    1 +
 yarn.lock              |    5 +++++
 package.json           |    1 +
 src/stores/index.ts    |    7 +++++++
 4 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/package.json b/package.json
index ae2b9ee..258bc6c 100644
--- a/package.json
+++ b/package.json
@@ -25,6 +25,7 @@
 		"mitt": "^3.0.0",
 		"nprogress": "^0.2.0",
 		"pinia": "^2.0.14",
+		"pinia-plugin-persistedstate": "^2.1.1",
 		"print-js": "^1.6.0",
 		"qrcodejs2-fixes": "^0.0.2",
 		"screenfull": "^6.0.1",
diff --git a/src/stores/index.ts b/src/stores/index.ts
index 27c377e..d9c4034 100644
--- a/src/stores/index.ts
+++ b/src/stores/index.ts
@@ -1,8 +1,15 @@
 // https://pinia.vuejs.org/
 import { createPinia } from 'pinia';
+import { createPersistedState } from 'pinia-plugin-persistedstate'
 
 // 创建
 const pinia = createPinia();
+pinia.use(createPersistedState({
+	serializer:{
+		serialize:JSON.stringify,
+		deserialize:JSON.parse,
+	}
+}))
 
 // 导出
 export default pinia;
diff --git a/src/stores/userInfo.ts b/src/stores/userInfo.ts
index 3783ffa..425b01d 100644
--- a/src/stores/userInfo.ts
+++ b/src/stores/userInfo.ts
@@ -19,6 +19,7 @@
             dataList: []
         }
     }),
+    persist:true,
     actions: {
         async setUserInfos(value: any) {
             this.userInfos.userName = value.realName;
diff --git a/yarn.lock b/yarn.lock
index 2eab5f0..d8367e9 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1846,6 +1846,11 @@
   resolved "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz"
   integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==
 
+pinia-plugin-persistedstate@^2.1.1:
+  version "2.1.1"
+  resolved "https://registry.npmmirror.com/pinia-plugin-persistedstate/-/pinia-plugin-persistedstate-2.1.1.tgz#584c416cdc278689ae9d49483621ec96dcb7d6ef"
+  integrity sha512-HUgsU5IRtM75eAQiIqzT3p1oPEuYH1/B2ipTMU++yE+FV0LkHaBswdKXs0RMWYCmugO8s62oxLTh/N1dLNp+5A==
+
 pinia@^2.0.14:
   version "2.0.14"
   resolved "https://registry.npmjs.org/pinia/-/pinia-2.0.14.tgz"

--
Gitblit v1.9.2