From 0e2bafcfce9de9b0d2382ef9d7ce94037d3d706c Mon Sep 17 00:00:00 2001 From: Montia37 Date: Wed, 10 Sep 2025 00:12:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E5=8D=A1=E7=89=87=E6=98=BE=E7=A4=BA=E6=8E=A7=E5=88=B6=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +- komari-theme.json | 19 ++++--- src/components/sections/StatsBar.tsx | 75 +++++++++++++++++----------- src/config/default.ts | 7 ++- src/hooks/useTheme.ts | 62 ++++++++++++++++++++--- src/pages/Home.tsx | 15 ++---- 6 files changed, 125 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index 796cc03..74f73ee 100644 --- a/README.md +++ b/README.md @@ -70,10 +70,11 @@ | 磨砂玻璃背景色 | `blurBackgroundColor` | `string` | `rgba(255, 255, 255, 0.5)\|rgba(0, 0, 0, 0.5)` | 调整模糊背景色,推荐 rgba 颜色值,使用“\|”分隔亮色模式和暗色模式的颜色值(eg: rgba(255, 255, 255, 0.5)\|rgba(0, 0, 0, 0.5)) | | 启用标签透明背景 | `enableTransparentTags` | `switch` | `true` | 启用后标签将使用较为透明的背景色,当背景情况复杂导致标签难以辨识时建议关闭 | | 标签默认颜色列表 | `tagDefaultColorList` | `string` | `ruby,gray,gold,bronze,brown,yellow,amber,orange,tomato,red` | 标签默认颜色列表,展示的标签将按顺序调用该颜色池,逗号分隔(可用的颜色列表请参考:https://www.radix-ui.com/themes/docs/theme/color ,改完没有生效则说明填写有误) | +| 默认主题颜色 | `selectThemeColor` | `select` | `gray` | 设置默认主题颜色,颜色对照请参考:https://www.radix-ui.com/themes/docs/theme/color | | 启用 localStorage 配置 | `enableLocalStorage` | `switch` | `true` | 启用后将优先使用用户浏览器本地配置的视图和外观设置。关闭后将强制使用下方的主题配置,本地可调整但刷新即恢复 | | 默认展示视图 | `selectedDefaultView` | `select` | `grid` | 设置默认展示视图为网格或表格 | | 默认外观 | `selectedDefaultAppearance` | `select` | `system` | 设置默认外观为浅色、深色或系统主题 | -| 默认主题颜色 | `selectThemeColor` | `select` | `gray` | 设置默认主题颜色,颜色对照请参考:https://www.radix-ui.com/themes/docs/theme/color | +| 状态卡片显示控制 | `statusCardsVisibility` | `string` | `currentTime:true,currentOnline:true,regionOverview:true,trafficOverview:true,networkSpeed:true` | 控制状态卡片的显示与隐藏,格式为 卡片名称:显示状态(true/false),多个卡片使用逗号分隔,支持的卡片名称包括 currentTime(当前时间), currentOnline(当前在线), regionOverview(点亮地区), trafficOverview(流量概览), networkSpeed(网络速率) | #### 标题栏设置 diff --git a/komari-theme.json b/komari-theme.json index 8b3262d..3a12b17 100644 --- a/komari-theme.json +++ b/komari-theme.json @@ -69,6 +69,14 @@ "default": "ruby,gray,gold,bronze,brown,yellow,amber,orange,tomato,red", "help": "标签默认颜色列表,展示的标签将按顺序调用该颜色池,逗号分隔(可用的颜色列表请参考:https://www.radix-ui.com/themes/docs/theme/color,改完没有生效则说明填写有误)" }, + { + "key": "selectThemeColor", + "name": "默认主题颜色", + "type": "select", + "options": "gray,gold,bronze,brown,yellow,amber,orange,tomato,red,ruby,crimson,pink,plum,purple,violet,iris,indigo,blue,cyan,teal,jade,green,grass,lime,mint,sky", + "default": "gray", + "help": "设置默认主题颜色,颜色对照请参考:https://www.radix-ui.com/themes/docs/theme/color" + }, { "key": "enableLocalStorage", "name": "启用 localStorage 配置", @@ -93,12 +101,11 @@ "help": "设置默认外观为浅色、深色或系统主题" }, { - "key": "selectThemeColor", - "name": "默认主题颜色", - "type": "select", - "options": "gray,gold,bronze,brown,yellow,amber,orange,tomato,red,ruby,crimson,pink,plum,purple,violet,iris,indigo,blue,cyan,teal,jade,green,grass,lime,mint,sky", - "default": "gray", - "help": "设置默认主题颜色,颜色对照请参考:https://www.radix-ui.com/themes/docs/theme/color" + "key": "statusCardsVisibility", + "name": "状态卡片显示控制", + "type": "string", + "default": "currentTime:true,currentOnline:true,regionOverview:true,trafficOverview:true,networkSpeed:true", + "help": "控制状态卡片的显示与隐藏,格式为 卡片名称:显示状态(true/false),多个卡片使用逗号分隔,支持的卡片名称包括 currentTime(当前时间), currentOnline(当前在线), regionOverview(点亮地区), trafficOverview(流量概览), networkSpeed(网络速率)" }, { "name": "标题栏设置", diff --git a/src/components/sections/StatsBar.tsx b/src/components/sections/StatsBar.tsx index 335dd93..b8a8b31 100644 --- a/src/components/sections/StatsBar.tsx +++ b/src/components/sections/StatsBar.tsx @@ -15,11 +15,11 @@ import { useIsMobile } from "@/hooks/useMobile"; interface StatsBarProps { displayOptions: { - time: boolean; - online: boolean; - regions: boolean; - traffic: boolean; - speed: boolean; + currentTime: boolean; + currentOnline: boolean; + regionOverview: boolean; + trafficOverview: boolean; + networkSpeed: boolean; }; setDisplayOptions: (options: any) => void; stats: { @@ -58,10 +58,10 @@ export const StatsBar = ({ // 渲染统计项 const renderStatItem = (key: string) => { switch (key) { - case "time": + case "currentTime": return ( - displayOptions.time && ( -
+ displayOptions.currentTime && ( +
) ); - case "online": + case "currentOnline": return ( - displayOptions.online && ( -
+ displayOptions.currentOnline && ( +
) ); - case "regions": + case "regionOverview": return ( - displayOptions.regions && ( -
+ displayOptions.regionOverview && ( +
) ); - case "traffic": + case "trafficOverview": return ( - displayOptions.traffic && ( -
+ displayOptions.trafficOverview && ( +
) ); - case "speed": + case "networkSpeed": return ( - displayOptions.speed && ( -
+ displayOptions.networkSpeed && ( +