fix: When refreshing the page, the topic is wrong
This commit is contained in:
@@ -4,10 +4,6 @@ import { PreferenceCache } from './cache';
|
||||
import { overridesPreference } from './preference';
|
||||
|
||||
interface SetupPreferenceOptions {
|
||||
/**
|
||||
* @zh_CN 环境
|
||||
*/
|
||||
env: string;
|
||||
/**
|
||||
* @zh_CN 应用名,由于 @vben/preference 是公用的,后续可能有多个app,为了防止多个app缓存冲突,可在这里配置应用名
|
||||
* 应用名将被用于持久化的前缀
|
||||
@@ -20,8 +16,8 @@ interface SetupPreferenceOptions {
|
||||
}
|
||||
|
||||
async function setupPreference(options: SetupPreferenceOptions) {
|
||||
const { env, namespace, overrides = {} } = options;
|
||||
const cache = new PreferenceCache(`${namespace}-${env}`);
|
||||
const { namespace, overrides = {} } = options;
|
||||
const cache = new PreferenceCache(namespace);
|
||||
overridesPreference(overrides, cache);
|
||||
}
|
||||
|
||||
|
@@ -3,10 +3,6 @@ import type { App } from 'vue';
|
||||
import { createPinia } from 'pinia';
|
||||
|
||||
interface SetupStoreOptions {
|
||||
/**
|
||||
* @zh_CN 环境
|
||||
*/
|
||||
env: string;
|
||||
/**
|
||||
* @zh_CN 应用名,由于 @vben/stores 是公用的,后续可能有多个app,为了防止多个app缓存冲突,可在这里配置应用名
|
||||
* 应用名将被用于持久化的前缀
|
||||
@@ -21,11 +17,11 @@ interface SetupStoreOptions {
|
||||
async function setupStore(app: App, options: SetupStoreOptions) {
|
||||
const { createPersistedState } = await import('pinia-plugin-persistedstate');
|
||||
const pinia = createPinia();
|
||||
const { env, namespace } = options;
|
||||
const { namespace } = options;
|
||||
pinia.use(
|
||||
createPersistedState({
|
||||
// key $appName-$store.id
|
||||
key: (storeKey) => `__${namespace}-${env}-${storeKey}__`,
|
||||
key: (storeKey) => `__${namespace}-${storeKey}__`,
|
||||
storage: localStorage,
|
||||
}),
|
||||
);
|
||||
|
Reference in New Issue
Block a user