Files
komari-theme-purcarte/src/config/hooks.ts
Montia37 1c1f739043 feat(theme): 新增主题可配置项,优化代码逻辑和样式
-  在 `komari-theme.json` 中添加了新的配置选项
- 支持自定义标题栏、内容区、实例页面和通用UI元素
- 优化部分组件调用逻辑
- 优化页面样式
2025-08-15 19:27:55 +08:00

27 lines
678 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { useContext } from "react";
import type { ConfigOptions } from "./default";
import { ConfigContext } from "./ConfigContext";
/**
* 使用全局配置 Hook用于获取当前应用配置
* @returns 配置对象
*/
export function useAppConfig(): ConfigOptions {
return useContext(ConfigContext);
}
/**
* 使用特定配置项 Hook直接获取某个配置项的值
* @param key 配置项键名
* @returns 配置项的值
*/
export function useConfigItem<K extends keyof ConfigOptions>(
key: K
): ConfigOptions[K] {
const config = useContext(ConfigContext);
return config[key];
}
// 导出配置类型
export type { ConfigOptions } from "./default";