From fbbef8b3148c71ef16294316f326ce4cb328e106 Mon Sep 17 00:00:00 2001 From: dap <15891557205@163.com> Date: Thu, 25 Dec 2025 20:22:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4SecureLS=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E5=B9=B6=E4=BD=BF=E7=94=A8localStorage=E6=9B=BF?= =?UTF-8?q?=E4=BB=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 由于vite8报错找不到SecureLS构造器,移除对SecureLS的依赖 在开发和生产环境统一使用localStorage作为存储方案 --- packages/stores/src/setup.ts | 38 +++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/packages/stores/src/setup.ts b/packages/stores/src/setup.ts index b18c27e3..5269571f 100644 --- a/packages/stores/src/setup.ts +++ b/packages/stores/src/setup.ts @@ -3,7 +3,8 @@ import type { Pinia } from 'pinia'; import type { App } from 'vue'; import { createPinia } from 'pinia'; -import SecureLS from 'secure-ls'; +// vite8报错找不到构造器? +// import SecureLS from 'secure-ls'; let pinia: Pinia; @@ -21,27 +22,28 @@ export async function initStores(app: App, options: InitStoreOptions) { const { createPersistedState } = await import('pinia-plugin-persistedstate'); pinia = createPinia(); const { namespace } = options; - const ls = new SecureLS({ - encodingType: 'aes', - encryptionSecret: import.meta.env.VITE_APP_STORE_SECURE_KEY, - isCompression: true, - // @ts-ignore secure-ls does not have a type definition for this - metaKey: `${namespace}-secure-meta`, - }); + // const ls = new SecureLS({ + // encodingType: 'aes', + // encryptionSecret: import.meta.env.VITE_APP_STORE_SECURE_KEY, + // isCompression: true, + // // @ts-ignore secure-ls does not have a type definition for this + // metaKey: `${namespace}-secure-meta`, + // }); pinia.use( createPersistedState({ // key $appName-$store.id key: (storeKey) => `${namespace}-${storeKey}`, - storage: import.meta.env.DEV - ? localStorage - : { - getItem(key) { - return ls.get(key); - }, - setItem(key, value) { - ls.set(key, value); - }, - }, + storage: localStorage, + // storage: import.meta.env.DEV + // ? localStorage + // : { + // getItem(key) { + // return ls.get(key); + // }, + // setItem(key, value) { + // ls.set(key, value); + // }, + // }, }), ); app.use(pinia);