mirror of
https://github.com/fankes/komari-theme-purcarte.git
synced 2025-12-14 21:41:20 +08:00
feat: 添加流量进度条样式选项,优化相关组件
This commit is contained in:
@@ -24,6 +24,7 @@ export interface ConfigOptions {
|
||||
enableConnectBreaks?: boolean; // 是否启用连接断点
|
||||
pingChartMaxPoints?: number; // 延迟图表最大点数
|
||||
enableSwap?: boolean; // 是否启用SWAP显示
|
||||
selectTrafficProgressStyle?: "circular" | "linear"; // 流量进度条样式
|
||||
enableListItemProgressBar?: boolean; // 是否启用列表视图进度条
|
||||
}
|
||||
|
||||
@@ -54,5 +55,6 @@ export const DEFAULT_CONFIG: ConfigOptions = {
|
||||
enableConnectBreaks: false,
|
||||
pingChartMaxPoints: 0,
|
||||
enableSwap: true,
|
||||
selectTrafficProgressStyle: "linear",
|
||||
enableListItemProgressBar: true,
|
||||
};
|
||||
|
||||
@@ -5,10 +5,11 @@ import { DEFAULT_CONFIG } from "./default";
|
||||
|
||||
/**
|
||||
* 使用全局配置 Hook,用于获取当前应用配置
|
||||
* @returns 配置对象
|
||||
* @returns 配置对象(合并了默认配置,确保所有属性都有值)
|
||||
*/
|
||||
export function useAppConfig(): ConfigOptions {
|
||||
return useContext(ConfigContext);
|
||||
export function useAppConfig(): Required<ConfigOptions> {
|
||||
const config = useContext(ConfigContext);
|
||||
return { ...DEFAULT_CONFIG, ...config } as Required<ConfigOptions>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -26,3 +27,8 @@ export function useConfigItem<K extends keyof ConfigOptions>(
|
||||
|
||||
// 导出配置类型
|
||||
export type { ConfigOptions } from "./default";
|
||||
|
||||
/**
|
||||
* 应用配置类型
|
||||
*/
|
||||
export type AppConfig = Required<ConfigOptions>;
|
||||
|
||||
Reference in New Issue
Block a user