/** * 主题检测配置选项 */ export interface DetectThemeOptions { /** * 用于检测主题的 CSS 变量名 * @default '--color-gray-bg-page' */ cssVariable?: string; /** * 亮度阈值,低于此值认为是暗色主题 * @default 145 */ darknessThreshold?: number; /** * 是否监听主题变化 * @default true */ observeChanges?: boolean; } /** * 自动检测当前主题的 Hook(单例模式) * * 所有 hook 实例共享同一个 MutationObserver 和 matchMedia 监听器, * 避免页面上多个图表时创建重复的 DOM 监听。 * * 检测策略(按优先级): * 1. 检查 `html[data-theme='dark']` 属性 * 2. 检查指定 CSS 变量的亮度值 * 3. 检查 `--color-gray-bg-page` 的亮度值 * * @param options 检测配置选项(observeChanges 为 false 时跳过监听) * @returns 检测到的主题 'light' | 'dark' * * @example * ```tsx * const theme = useDetectTheme(); * // theme: 'light' | 'dark' * * // 禁用监听(仅检测一次) * const theme = useDetectTheme({ observeChanges: false }); * ``` */ export declare const useDetectTheme: (options?: DetectThemeOptions) => 'light' | 'dark'; export default useDetectTheme;