From 8b2bca9eef30233351ff759441f786fed33e193f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=A8=E9=9C=96=E9=93=83?= Date: Sat, 23 May 2026 12:57:51 +0800 Subject: [PATCH] refactor(timestamp): migrate pageTheme constants to Timestamp feature Remove config/pageTheme.ts and move DATE_FORMAT, ZONES, UnitType, ZoneType to pages/Timestamp/constants.ts for better feature cohesion. --- config/pageTheme.ts | 56 ------------------------ pages/Timestamp/LiveClock.tsx | 2 +- pages/Timestamp/ResultView.tsx | 4 +- pages/Timestamp/constants.ts | 6 +++ pages/Timestamp/index.tsx | 2 +- pages/Timestamp/useTimestampConverter.ts | 4 +- 6 files changed, 12 insertions(+), 62 deletions(-) delete mode 100644 config/pageTheme.ts create mode 100644 pages/Timestamp/constants.ts diff --git a/config/pageTheme.ts b/config/pageTheme.ts deleted file mode 100644 index f3f9b80..0000000 --- a/config/pageTheme.ts +++ /dev/null @@ -1,56 +0,0 @@ -export const DATE_FORMAT = 'YYYY/MM/DD HH:mm:ss'; - -export const ZONES = ['Asia/Shanghai', 'America/New_York', 'Europe/London'] as const; - -export type UnitType = 'ms' | 's'; -export type ZoneType = (typeof ZONES)[number]; - -export const THEME_COLORS = { - primary: '#1976d2', - primaryDark: '#1565c0', - primaryLight: '#42a5f5', - success: '#2e7d32', - successDark: '#1b5e20', - successLight: '#4caf50', - warning: '#e65100', - warningDark: '#bf360c', - warningLight: '#ff9800', - error: '#c62828', - errorDark: '#b71c1c', - errorLight: '#f44336', - purple: '#6a1b9a', - purpleDark: '#4a148c', - purpleLight: '#9c27b0', - indigo: '#303f9f', - indigoDark: '#1a237e', - indigoLight: '#7986cb', - white: '#FFFFFF', - black: '#000000', -} as const; - -export const STATUS_COLORS = { - success: THEME_COLORS.success, - warning: THEME_COLORS.warning, - error: THEME_COLORS.error, - info: THEME_COLORS.primary, -} as const; - -export const timestampPageStyles = { - primaryColor: THEME_COLORS.primary, -}; - -export const storageCleanerPageStyles = { - warningColor: THEME_COLORS.warning, -}; - -export const qrCodePageStyles = { - primaryColor: THEME_COLORS.success, -}; - -export const textStatisticsPageStyles = { - primaryColor: THEME_COLORS.purple, -}; - -export const base64ConverterPageStyles = { - primaryColor: THEME_COLORS.indigo, -}; diff --git a/pages/Timestamp/LiveClock.tsx b/pages/Timestamp/LiveClock.tsx index d23a21c..9a651dc 100644 --- a/pages/Timestamp/LiveClock.tsx +++ b/pages/Timestamp/LiveClock.tsx @@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useRef, useState } from 'react'; import { Clock } from 'lucide-react'; import CopyButton from '@/components/CopyButton'; import { useSnackbar } from '@/components/GlobalSnackbar'; -import type { UnitType } from '@/config/pageTheme'; +import type { UnitType } from './constants'; import { useLazyTranslation } from '@/utils/useLazyTranslation'; import { cn } from '@/lib/utils'; // 引入标准的 shadcn 工具函数 diff --git a/pages/Timestamp/ResultView.tsx b/pages/Timestamp/ResultView.tsx index ffaf6d0..582b169 100644 --- a/pages/Timestamp/ResultView.tsx +++ b/pages/Timestamp/ResultView.tsx @@ -1,8 +1,8 @@ import React, { useMemo } from 'react'; import dayjs from '@/utils/dayjs'; import CopyButton from '@/components/CopyButton'; -import type { UnitType } from '@/config/pageTheme'; -import { DATE_FORMAT } from '@/config/pageTheme'; // 彻底移除了非语义的 timestampPageStyles 依赖 +import type { UnitType } from './constants'; +import { DATE_FORMAT } from './constants'; import { useLazyTranslation } from '@/utils/useLazyTranslation'; import { cn } from '@/lib/utils'; // shadcn 核心类名合并工具 diff --git a/pages/Timestamp/constants.ts b/pages/Timestamp/constants.ts new file mode 100644 index 0000000..ae08b00 --- /dev/null +++ b/pages/Timestamp/constants.ts @@ -0,0 +1,6 @@ +export const DATE_FORMAT = 'YYYY/MM/DD HH:mm:ss'; + +export const ZONES = ['Asia/Shanghai', 'America/New_York', 'Europe/London'] as const; + +export type UnitType = 'ms' | 's'; +export type ZoneType = (typeof ZONES)[number]; diff --git a/pages/Timestamp/index.tsx b/pages/Timestamp/index.tsx index 7f77db4..7a5f44b 100644 --- a/pages/Timestamp/index.tsx +++ b/pages/Timestamp/index.tsx @@ -1,7 +1,7 @@ import { Clock } from 'lucide-react'; import PageHeader from '@/components/PageHeader'; import SwitchButtonGroup from '@/components/SwitchButtonGroup'; -import { ZONES } from '@/config/pageTheme'; +import { ZONES } from './constants'; import LiveClock from './LiveClock'; import ResultView from './ResultView'; import { useTimestampConverter } from './useTimestampConverter'; diff --git a/pages/Timestamp/useTimestampConverter.ts b/pages/Timestamp/useTimestampConverter.ts index 52de1f6..da3c771 100644 --- a/pages/Timestamp/useTimestampConverter.ts +++ b/pages/Timestamp/useTimestampConverter.ts @@ -1,7 +1,7 @@ import { useCallback, useMemo, useState } from 'react'; import dayjs from '@/utils/dayjs'; -import type { UnitType, ZoneType } from '@/config/pageTheme'; -import { DATE_FORMAT } from '@/config/pageTheme'; +import type { UnitType, ZoneType } from './constants'; +import { DATE_FORMAT } from './constants'; import { useLazyTranslation } from '@/utils/useLazyTranslation'; import { useContextMenuData } from '@/utils/useContextMenuData';