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

@@ -2,7 +2,7 @@ import type { Preference } from '@vben-core/typings';
class PreferenceCache {
cachePrefix: string;
constructor(cachePrefix: string = 'vben-admin') {
constructor(cachePrefix: string) {
this.cachePrefix = cachePrefix;
}
@@ -24,8 +24,7 @@ class PreferenceCache {
* 获取偏好设置的缓存键
*/
getCacheKey(name: string = 'preference') {
const env = import.meta.env.DEV ? 'dev' : 'prod';
return `__${this.cachePrefix}-${name}-${env}__`;
return `__${this.cachePrefix}-${name}__`;
}
/**

View File

@@ -34,8 +34,9 @@ const defaultPreference: Preference = {
pageTransition: 'fade-slide',
pageTransitionEnable: true,
semiDarkMenu: true,
showPreference: true,
sideCollapse: false,
sideCollapseShowTitle: false,
sideCollapseShowTitle: true,
sideExpandOnHover: true,
sideExtraCollapse: true,
sideVisible: true,

View File

@@ -4,22 +4,24 @@ import { PreferenceCache } from './cache';
import { overridesPreference } from './preference';
interface SetupPreferenceOptions {
/**
* @zh_CN 环境
*/
env: string;
/**
* @zh_CN 应用名,由于 @vben/preference 是公用的后续可能有多个app为了防止多个app缓存冲突可在这里配置应用名
* 应用名将被用于持久化的前缀
*/
cachePrefix?: string;
namespace: string;
/**
* @zh_CN app自行覆盖偏好设置
*/
overrides?: DeepPartial<Preference>;
}
async function setupPreference(options: SetupPreferenceOptions = {}) {
const { cachePrefix = 'vben-admin-pro', overrides = {} } = options;
const cache = new PreferenceCache(cachePrefix);
async function setupPreference(options: SetupPreferenceOptions) {
const { env, namespace, overrides = {} } = options;
const cache = new PreferenceCache(`${namespace}-${env}`);
overridesPreference(overrides, cache);
}