From d677ca9877dadd4f2adbf707c315e06d30068f51 Mon Sep 17 00:00:00 2001 From: shinya Date: Thu, 26 Jun 2025 21:00:11 +0800 Subject: [PATCH] feat: dark mode --- package.json | 1 + pnpm-lock.yaml | 14 ++++++++ src/app/aggregate/page.tsx | 4 +-- src/app/detail/page.tsx | 16 ++++----- src/app/douban/page.tsx | 4 +-- src/app/globals.css | 47 +++++++++++++++++++++++++++ src/app/layout.tsx | 20 ++++++++---- src/app/page.tsx | 32 ++++++++++-------- src/app/search/page.tsx | 22 ++++++++----- src/components/AggregateCard.tsx | 2 +- src/components/CapsuleSwitch.tsx | 6 ++-- src/components/ContinueWatching.tsx | 14 ++++---- src/components/DemoCard.tsx | 2 +- src/components/DoubanCardSkeleton.tsx | 4 +-- src/components/MobileBottomNav.tsx | 14 ++++++-- src/components/MobileHeader.tsx | 9 ++++- src/components/PageLayout.tsx | 6 +++- src/components/ScrollableRow.tsx | 8 ++--- src/components/Sidebar.tsx | 22 ++++++------- src/components/ThemeProvider.tsx | 9 +++++ src/components/ThemeToggle.tsx | 45 +++++++++++++++++++++++++ src/components/VideoCard.tsx | 10 +++--- tailwind.config.ts | 1 + 23 files changed, 234 insertions(+), 78 deletions(-) create mode 100644 src/components/ThemeProvider.tsx create mode 100644 src/components/ThemeToggle.tsx diff --git a/package.json b/package.json index 5c11c20..0db82fe 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "media-icons": "^1.1.5", "next": "^14.2.23", "next-pwa": "^5.6.0", + "next-themes": "^0.4.6", "react": "^18.2.0", "react-dom": "^18.2.0", "react-icons": "^5.4.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4fad0fb..f7c79cb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -38,6 +38,9 @@ importers: next-pwa: specifier: ^5.6.0 version: 5.6.0(@babel/core@7.27.4)(@types/babel__core@7.20.5)(next@14.2.30(@babel/core@7.27.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(webpack@5.99.9) + next-themes: + specifier: ^0.4.6 + version: 0.4.6(react-dom@18.3.1(react@18.3.1))(react@18.3.1) react: specifier: ^18.2.0 version: 18.3.1 @@ -3656,6 +3659,12 @@ packages: peerDependencies: next: '*' + next-themes@0.4.6: + resolution: {integrity: sha512-pZvgD5L0IEvX5/9GWyHMf3m8BKiVQwsCMHfoFosXtXBMnaS0ZnIJ9ST4b4NqLVKDEm8QBxoNNGNaBv2JNF6XNA==} + peerDependencies: + react: ^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc + react-dom: ^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc + next@14.2.30: resolution: {integrity: sha512-+COdu6HQrHHFQ1S/8BBsCag61jZacmvbuL2avHvQFbWa2Ox7bE+d8FyNgxRLjXQ5wtPyQwEmk85js/AuaG2Sbg==} engines: {node: '>=18.17.0'} @@ -9311,6 +9320,11 @@ snapshots: minimist: 1.2.8 next: 14.2.30(@babel/core@7.27.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + next-themes@0.4.6(react-dom@18.3.1(react@18.3.1))(react@18.3.1): + dependencies: + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + next@14.2.30(@babel/core@7.27.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1): dependencies: '@next/env': 14.2.30 diff --git a/src/app/aggregate/page.tsx b/src/app/aggregate/page.tsx index ff6f045..b170bd2 100644 --- a/src/app/aggregate/page.tsx +++ b/src/app/aggregate/page.tsx @@ -143,7 +143,7 @@ function AggregatePageClient() { className='absolute top-0 left-0 -translate-x-[40%] -translate-y-[30%] sm:-translate-x-[180%] sm:-translate-y-1/2 p-2 rounded transition-colors' > {/* 名称 */} diff --git a/src/app/detail/page.tsx b/src/app/detail/page.tsx index f344613..51b9dcf 100644 --- a/src/app/detail/page.tsx +++ b/src/app/detail/page.tsx @@ -137,7 +137,7 @@ function DetailPageClient() { className='absolute top-0 left-0 -translate-x-[40%] -translate-y-[30%] sm:-translate-x-[180%] sm:-translate-y-1/2 p-2 rounded transition-colors' >
从头开始 @@ -252,10 +252,10 @@ function DetailPageClient() { {/* 爱心按钮 */} @@ -240,7 +244,7 @@ function SearchPageClient() { setSearchQuery(item); router.push(`/search?q=${encodeURIComponent(item)}`); }} - className='px-4 py-2 bg-gray-500/10 hover:bg-gray-300 rounded-full text-sm text-gray-700 transition-colors duration-200' + className='px-4 py-2 bg-gray-500/10 hover:bg-gray-300 rounded-full text-sm text-gray-700 transition-colors duration-200 dark:bg-gray-700/50 dark:hover:bg-gray-600 dark:text-gray-300' > {item} diff --git a/src/components/AggregateCard.tsx b/src/components/AggregateCard.tsx index 2888828..f4b4192 100644 --- a/src/components/AggregateCard.tsx +++ b/src/components/AggregateCard.tsx @@ -114,7 +114,7 @@ const AggregateCard: React.FC = ({ {/* 标题 */}
- + {first.title}
diff --git a/src/components/CapsuleSwitch.tsx b/src/components/CapsuleSwitch.tsx index 9cd0d2e..a5d136a 100644 --- a/src/components/CapsuleSwitch.tsx +++ b/src/components/CapsuleSwitch.tsx @@ -15,7 +15,7 @@ const CapsuleSwitch: React.FC = ({ }) => { return (
@@ -25,8 +25,8 @@ const CapsuleSwitch: React.FC = ({ onClick={() => onChange(opt.value)} className={`w-16 px-3 py-1 text-xs sm:w-20 sm:py-2 sm:text-sm rounded-full font-medium transition-all duration-200 ${ active === opt.value - ? 'bg-white text-gray-900 shadow-sm' - : 'text-gray-700 hover:text-gray-900' + ? 'bg-white text-gray-900 shadow-sm dark:bg-gray-500 dark:text-gray-100' + : 'text-gray-700 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100' }`} > {opt.label} diff --git a/src/components/ContinueWatching.tsx b/src/components/ContinueWatching.tsx index d5a7489..3e6b9d8 100644 --- a/src/components/ContinueWatching.tsx +++ b/src/components/ContinueWatching.tsx @@ -72,10 +72,12 @@ export default function ContinueWatching({ className }: ContinueWatchingProps) { return (
-

继续观看

+

+ 继续观看 +

{!loading && playRecords.length > 0 && (
@@ -153,9 +153,9 @@ export default function ScrollableRow({ >
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index fbb4dcb..1a81652 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -164,11 +164,10 @@ const Sidebar = ({ onToggle, activePath = '/' }: SidebarProps) => {
+ ); +} diff --git a/src/components/VideoCard.tsx b/src/components/VideoCard.tsx index 606f46f..fdc645f 100644 --- a/src/components/VideoCard.tsx +++ b/src/components/VideoCard.tsx @@ -227,7 +227,7 @@ export default function VideoCard({ {/* 播放进度条 */} {progress !== undefined && ( -
+
{/* 信息层 */} -
+
- + {title} {source && ( - - + + {source_name} diff --git a/tailwind.config.ts b/tailwind.config.ts index 55cb3fb..2362275 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -2,6 +2,7 @@ import type { Config } from 'tailwindcss'; import defaultTheme from 'tailwindcss/defaultTheme'; const config: Config = { + darkMode: 'class', content: [ './src/pages/**/*.{js,ts,jsx,tsx,mdx}', './src/components/**/*.{js,ts,jsx,tsx,mdx}',