From 8cb36b67758c35f4417169cea56034380ca331bb Mon Sep 17 00:00:00 2001 From: hello8693 <1320998105@qq.com> Date: Thu, 22 Aug 2024 18:48:46 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=B7=BB=E5=8A=A0pinia-plugin-persist?= =?UTF-8?q?edstate=E4=BE=9D=E8=B5=96=E5=B9=B6=E5=90=AF=E7=94=A8=E6=8C=81?= =?UTF-8?q?=E4=B9=85=E5=8C=96=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + src/renderer/src/stores/app.js | 3 ++- src/renderer/src/stores/index.js | 8 +++++++- yarn.lock | 5 +++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9f2e257..a199367 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "date-fns": "^3.6.0", "github-markdown-css": "^5.5.1", "moment": "^2.30.1", + "pinia-plugin-persistedstate": "^3.2.1", "roboto-fontface": "*", "uuid": "^9.0.1", "vite-plugin-svg-icons": "^2.0.1", diff --git a/src/renderer/src/stores/app.js b/src/renderer/src/stores/app.js index 6586792..7cc8c00 100644 --- a/src/renderer/src/stores/app.js +++ b/src/renderer/src/stores/app.js @@ -8,5 +8,6 @@ export const useAppStore = defineStore('app', { roomName: '考场名称', message: '考试提醒信息', examInfos: [] - }) + }), + persist: true }); diff --git a/src/renderer/src/stores/index.js b/src/renderer/src/stores/index.js index 9f894dc..1f18b21 100644 --- a/src/renderer/src/stores/index.js +++ b/src/renderer/src/stores/index.js @@ -1,4 +1,10 @@ // Utilities import { createPinia } from 'pinia'; -export default createPinia(); +import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'; + +const pinia = createPinia(); + +pinia.use(piniaPluginPersistedstate); + +export default pinia; diff --git a/yarn.lock b/yarn.lock index 43cb2ee..d847b0f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4576,6 +4576,11 @@ picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.3.1: resolved "https://registry.npmmirror.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== +pinia-plugin-persistedstate@^3.2.1: + version "3.2.1" + resolved "https://registry.npmmirror.com/pinia-plugin-persistedstate/-/pinia-plugin-persistedstate-3.2.1.tgz#66780602aecd6c7b152dd7e3ddc249a1f7a13fe5" + integrity sha512-MK++8LRUsGF7r45PjBFES82ISnPzyO6IZx3CH5vyPseFLZCk1g2kgx6l/nW8pEBKxxd4do0P6bJw+mUSZIEZUQ== + pinia@^2.1.7: version "2.2.0" resolved "https://registry.npmmirror.com/pinia/-/pinia-2.2.0.tgz#cd006f7c1365ae326b9f95f622b7ad1078c398a4"