Files
xk-admin/packages/preference/src/setup.ts

31 lines
862 B
TypeScript
Raw Normal View History

2024-05-19 21:20:42 +08:00
import type { DeepPartial, Preference } from '@vben-core/typings';
import { PreferenceCache } from './cache';
import { overridesPreference } from './preference';
interface SetupPreferenceOptions {
2024-05-24 23:11:03 +08:00
/**
* @zh_CN
*/
env: string;
2024-05-19 21:20:42 +08:00
/**
* @zh_CN , @vben/preference appapp缓存冲突
*
*/
2024-05-24 23:11:03 +08:00
namespace: string;
2024-05-19 21:20:42 +08:00
/**
* @zh_CN app自行覆盖偏好设置
*/
overrides?: DeepPartial<Preference>;
}
2024-05-24 23:11:03 +08:00
async function setupPreference(options: SetupPreferenceOptions) {
const { env, namespace, overrides = {} } = options;
const cache = new PreferenceCache(`${namespace}-${env}`);
2024-05-19 21:20:42 +08:00
overridesPreference(overrides, cache);
}
export { setupPreference };
export type { SetupPreferenceOptions };