import type { StorageType } from './index'; export interface GetEnumParams { /** 单个枚举 code */ code?: string; /** 多个枚举 code,与 code 互斥 */ codes?: string[]; /** 单值查询,返回 [label, option],与 values 互斥 */ value?: string | number; /** 多值查询,返回 [labels[], options[]],与 value 互斥 */ values?: (string | number)[]; /** 为 true 时返回 value-label 组合形式 */ compose?: boolean; /** 存储类型,默认 indexedDB */ storage?: StorageType; /** 缓存 key,默认 zat-design-pro-component-cacheKey */ cacheKey?: string; } /** * 在函数/回调中获取枚举数据,无需在 React 组件内使用。 * * 枚举数据由 ProConfigProvider 初始化时写入 storage。 * * **同步优先策略**: * - 内存缓存命中时直接返回值,无需 `await` * - localStorage/sessionStorage 首次调用同步读取并预热内存缓存 * - indexedDB 首次调用(内存未命中)返回 Promise,需 `await` 兜底 * * 典型用法:在 ProConfigProvider 初始化完成后,事件回调/工具函数中直接调用无需 await: * * @example * // 获取全部枚举(内存命中时同步返回) * const allEnums = getEnum(config); * * // 获取单个枚举 options * const [cityOptions, getLabel] = getEnum({ code: 'city', ...config }); * * // 获取多个枚举 * const { city, status } = getEnum({ codes: ['city', 'status'], ...config }); * * // 根据值查询 label * const [label, option] = getEnum({ code: 'city', value: 'sh', ...config }); * * // indexedDB 首次加载时兜底(数据未预热时需 await) * const allEnums = await getEnum(config); */ declare function getEnum(params?: GetEnumParams): any; export default getEnum;