mirror of
https://github.com/fankes/komari-theme-purcarte.git
synced 2025-10-20 04:19:22 +08:00
feat(theme): 新增主题可配置项,优化代码逻辑和样式
- 在 `komari-theme.json` 中添加了新的配置选项 - 支持自定义标题栏、内容区、实例页面和通用UI元素 - 优化部分组件调用逻辑 - 优化页面样式
This commit is contained in:
26
src/config/hooks.ts
Normal file
26
src/config/hooks.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
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";
|
Reference in New Issue
Block a user