From c7beebf6e0efc2081e42c8630dfacdde63e0d5a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=A8=E9=9C=96=E9=93=83?= Date: Fri, 22 May 2026 17:36:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=A1=86=E5=92=8C=E6=8C=89=E9=92=AE=E5=9C=A8=E6=9A=97=E8=89=B2?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8B=E7=9A=84=E6=A0=B7=E5=BC=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 为 :root 和 .dark 添加 color-scheme,使浏览器表单控件默认样式适配暗色模式 - 将 bg-primary 搭配 text-white 的按钮改为 text-primary-foreground - 替换残留的 hover:bg-blue-700、text-blue-500、bg-gray-200 等硬编码颜色 - 同步更新 TextInputArea 单元测试 --- components/PageSkeleton.tsx | 20 ++++++++++---------- components/TextInputArea.tsx | 2 +- components/__tests__/TextInputArea.test.tsx | 2 +- pages/Base64Converter/FileMode.tsx | 2 +- pages/Base64Converter/ImageMode.tsx | 2 +- pages/JsonTools/JsonFormatSection.tsx | 2 +- pages/StorageCleaner/AutoRefreshToggle.tsx | 2 +- pages/Timestamp/LiveClock.tsx | 2 +- pages/Timestamp/index.tsx | 2 +- src/index.css | 7 +++++++ 10 files changed, 25 insertions(+), 18 deletions(-) diff --git a/components/PageSkeleton.tsx b/components/PageSkeleton.tsx index 55565e4..2814850 100644 --- a/components/PageSkeleton.tsx +++ b/components/PageSkeleton.tsx @@ -17,13 +17,13 @@ function DashboardCardSkeleton() {
-
+
-
-
+
+
-
+
); @@ -36,21 +36,21 @@ function ToolPageSkeleton() { return (
{/* 标题区域 */} -
+
{/* 输入区域 */} -
+
{/* 控制栏 */}
-
-
+
+
-
+
{/* 结果区域 */} -
+
); } diff --git a/components/TextInputArea.tsx b/components/TextInputArea.tsx index a7d78c7..8200026 100644 --- a/components/TextInputArea.tsx +++ b/components/TextInputArea.tsx @@ -152,7 +152,7 @@ function ActionButton({ typeof action.disabled === 'function' ? action.disabled(value) : action.disabled || !value; const typeClasses: Record = { - primary: 'bg-primary text-white hover:bg-primary/90', + primary: 'bg-primary text-primary-foreground hover:bg-primary/90', danger: 'text-red-600 hover:bg-red-500/10', default: 'text-muted-foreground hover:bg-muted', }; diff --git a/components/__tests__/TextInputArea.test.tsx b/components/__tests__/TextInputArea.test.tsx index 10388a2..9941e42 100644 --- a/components/__tests__/TextInputArea.test.tsx +++ b/components/__tests__/TextInputArea.test.tsx @@ -334,7 +334,7 @@ describe('TextInputArea 组件', () => { ); const btn = screen.getByText('主要'); - expect(btn).toHaveClass('bg-primary', 'text-white'); + expect(btn).toHaveClass('bg-primary', 'text-primary-foreground'); }); }); diff --git a/pages/Base64Converter/FileMode.tsx b/pages/Base64Converter/FileMode.tsx index c0da7cc..685bdda 100644 --- a/pages/Base64Converter/FileMode.tsx +++ b/pages/Base64Converter/FileMode.tsx @@ -195,7 +195,7 @@ export default function FileMode() { }} /> {isLoading ? ( -
+
) : info ? (
diff --git a/pages/Base64Converter/ImageMode.tsx b/pages/Base64Converter/ImageMode.tsx index 87a3d05..1f68cef 100644 --- a/pages/Base64Converter/ImageMode.tsx +++ b/pages/Base64Converter/ImageMode.tsx @@ -202,7 +202,7 @@ export default function ImageMode() { }} /> {isLoading ? ( -
+
) : info ? (
{result && ( diff --git a/pages/JsonTools/JsonFormatSection.tsx b/pages/JsonTools/JsonFormatSection.tsx index aa036bd..437b199 100644 --- a/pages/JsonTools/JsonFormatSection.tsx +++ b/pages/JsonTools/JsonFormatSection.tsx @@ -90,7 +90,7 @@ export default function JsonFormatSection() { type="checkbox" checked={sortKeys} onChange={(e) => setSortKeys(e.target.checked)} - className="h-4 w-4 rounded border-input text-blue-500 focus:ring-primary" + className="h-4 w-4 rounded border-input text-primary focus:ring-primary" /> {t('jsonFormat:sortKeys')} diff --git a/pages/StorageCleaner/AutoRefreshToggle.tsx b/pages/StorageCleaner/AutoRefreshToggle.tsx index c8c9d40..3b49c8a 100644 --- a/pages/StorageCleaner/AutoRefreshToggle.tsx +++ b/pages/StorageCleaner/AutoRefreshToggle.tsx @@ -19,7 +19,7 @@ export default function AutoRefreshToggle({ autoRefresh, onChange }: AutoRefresh onChange={(e) => onChange(e.target.checked)} className="sr-only peer" /> -
+
); diff --git a/pages/Timestamp/LiveClock.tsx b/pages/Timestamp/LiveClock.tsx index d74e134..fc9b43b 100644 --- a/pages/Timestamp/LiveClock.tsx +++ b/pages/Timestamp/LiveClock.tsx @@ -47,7 +47,7 @@ const LiveClock = React.memo(({ unit, onUseNow }: LiveClockProps) => { diff --git a/pages/Timestamp/index.tsx b/pages/Timestamp/index.tsx index 714167b..469002b 100644 --- a/pages/Timestamp/index.tsx +++ b/pages/Timestamp/index.tsx @@ -98,7 +98,7 @@ export default function Index() { {/* 立即转换 */} diff --git a/src/index.css b/src/index.css index 110f4d6..e7e4950 100644 --- a/src/index.css +++ b/src/index.css @@ -4,6 +4,7 @@ @layer base { :root { + color-scheme: light; --background: 0 0% 100%; --foreground: 222.2 84% 4.9%; @@ -36,6 +37,7 @@ } .dark { + color-scheme: dark; --background: 222.2 84% 4.9%; --foreground: 210 40% 98%; @@ -74,4 +76,9 @@ background-color: hsl(var(--background)); color: hsl(var(--foreground)); } + input, + textarea, + select { + color: hsl(var(--foreground)); + } }