mirror of
https://gitee.com/dapppp/ruoyi-plus-vben5.git
synced 2026-03-25 22:34:32 +08:00
fix: 移除SecureLS依赖并使用localStorage替代
由于vite8报错找不到SecureLS构造器,移除对SecureLS的依赖 在开发和生产环境统一使用localStorage作为存储方案
This commit is contained in:
@@ -3,7 +3,8 @@ import type { Pinia } from 'pinia';
|
|||||||
import type { App } from 'vue';
|
import type { App } from 'vue';
|
||||||
|
|
||||||
import { createPinia } from 'pinia';
|
import { createPinia } from 'pinia';
|
||||||
import SecureLS from 'secure-ls';
|
// vite8报错找不到构造器?
|
||||||
|
// import SecureLS from 'secure-ls';
|
||||||
|
|
||||||
let pinia: Pinia;
|
let pinia: Pinia;
|
||||||
|
|
||||||
@@ -21,27 +22,28 @@ export async function initStores(app: App, options: InitStoreOptions) {
|
|||||||
const { createPersistedState } = await import('pinia-plugin-persistedstate');
|
const { createPersistedState } = await import('pinia-plugin-persistedstate');
|
||||||
pinia = createPinia();
|
pinia = createPinia();
|
||||||
const { namespace } = options;
|
const { namespace } = options;
|
||||||
const ls = new SecureLS({
|
// const ls = new SecureLS({
|
||||||
encodingType: 'aes',
|
// encodingType: 'aes',
|
||||||
encryptionSecret: import.meta.env.VITE_APP_STORE_SECURE_KEY,
|
// encryptionSecret: import.meta.env.VITE_APP_STORE_SECURE_KEY,
|
||||||
isCompression: true,
|
// isCompression: true,
|
||||||
// @ts-ignore secure-ls does not have a type definition for this
|
// // @ts-ignore secure-ls does not have a type definition for this
|
||||||
metaKey: `${namespace}-secure-meta`,
|
// metaKey: `${namespace}-secure-meta`,
|
||||||
});
|
// });
|
||||||
pinia.use(
|
pinia.use(
|
||||||
createPersistedState({
|
createPersistedState({
|
||||||
// key $appName-$store.id
|
// key $appName-$store.id
|
||||||
key: (storeKey) => `${namespace}-${storeKey}`,
|
key: (storeKey) => `${namespace}-${storeKey}`,
|
||||||
storage: import.meta.env.DEV
|
storage: localStorage,
|
||||||
? localStorage
|
// storage: import.meta.env.DEV
|
||||||
: {
|
// ? localStorage
|
||||||
getItem(key) {
|
// : {
|
||||||
return ls.get(key);
|
// getItem(key) {
|
||||||
},
|
// return ls.get(key);
|
||||||
setItem(key, value) {
|
// },
|
||||||
ls.set(key, value);
|
// setItem(key, value) {
|
||||||
},
|
// ls.set(key, value);
|
||||||
},
|
// },
|
||||||
|
// },
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
app.use(pinia);
|
app.use(pinia);
|
||||||
|
|||||||
Reference in New Issue
Block a user