feat: add docker shell

This commit is contained in:
vben
2024-05-24 23:11:03 +08:00
parent d733987042
commit 38d58394e3
25 changed files with 394 additions and 120 deletions

View File

@@ -3,26 +3,29 @@ import type { App } from 'vue';
import { createPinia } from 'pinia';
interface SetupStoreOptions {
/**
* @zh_CN 环境
*/
env: string;
/**
* @zh_CN 应用名,由于 @vben/stores 是公用的后续可能有多个app为了防止多个app缓存冲突可在这里配置应用名
* 应用名将被用于持久化的前缀
*/
cachePrefix?: string;
namespace: string;
}
/**
* @zh_CN 初始化pinia
* @param app vue app 实例
*/
async function setupStore(app: App, options: SetupStoreOptions = {}) {
async function setupStore(app: App, options: SetupStoreOptions) {
const { createPersistedState } = await import('pinia-plugin-persistedstate');
const pinia = createPinia();
const { cachePrefix = 'vben-admin-pro' } = options;
const env = import.meta.env.DEV ? 'dev' : 'prod';
const { env, namespace } = options;
pinia.use(
createPersistedState({
// key $appName-$store.id
key: (storeKey) => `__${cachePrefix}-${storeKey}-${env}__`,
key: (storeKey) => `__${namespace}-${env}-${storeKey}__`,
storage: localStorage,
}),
);