From e412e2d765ab43a25da9a47751aef1d22b15cb3a Mon Sep 17 00:00:00 2001 From: shinya Date: Tue, 8 Jul 2025 13:23:27 +0800 Subject: [PATCH] feat: add right sidebar collapse --- src/app/api/admin/source/route.ts | 3 +- src/app/api/admin/user/route.ts | 3 +- src/app/api/favorites/route.ts | 3 +- src/app/api/playrecords/route.ts | 2 +- src/app/play/page.tsx | 109 +++++++++++++++++++++++------- src/lib/db.ts | 6 +- src/lib/redis.db.ts | 3 +- src/lib/types.ts | 3 - 8 files changed, 97 insertions(+), 35 deletions(-) diff --git a/src/app/api/admin/source/route.ts b/src/app/api/admin/source/route.ts index 2b871e9..1c24663 100644 --- a/src/app/api/admin/source/route.ts +++ b/src/app/api/admin/source/route.ts @@ -3,7 +3,8 @@ import { NextResponse } from 'next/server'; import { getConfig } from '@/lib/config'; -import { getStorage, IStorage } from '@/lib/db'; +import { getStorage } from '@/lib/db'; +import { IStorage } from '@/lib/types'; export const runtime = 'edge'; diff --git a/src/app/api/admin/user/route.ts b/src/app/api/admin/user/route.ts index 1e4383a..e4ce7a3 100644 --- a/src/app/api/admin/user/route.ts +++ b/src/app/api/admin/user/route.ts @@ -3,7 +3,8 @@ import { NextResponse } from 'next/server'; import { getConfig } from '@/lib/config'; -import { getStorage, IStorage } from '@/lib/db'; +import { getStorage } from '@/lib/db'; +import { IStorage } from '@/lib/types'; export const runtime = 'edge'; diff --git a/src/app/api/favorites/route.ts b/src/app/api/favorites/route.ts index 72cdccb..8f806fd 100644 --- a/src/app/api/favorites/route.ts +++ b/src/app/api/favorites/route.ts @@ -2,7 +2,8 @@ import { NextRequest, NextResponse } from 'next/server'; -import { db, Favorite } from '@/lib/db'; +import { db } from '@/lib/db'; +import { Favorite } from '@/lib/types'; export const runtime = 'edge'; diff --git a/src/app/api/playrecords/route.ts b/src/app/api/playrecords/route.ts index d0146ea..2fafd96 100644 --- a/src/app/api/playrecords/route.ts +++ b/src/app/api/playrecords/route.ts @@ -3,7 +3,7 @@ import { NextRequest, NextResponse } from 'next/server'; import { db } from '@/lib/db'; -import { PlayRecord } from '@/lib/db'; +import { PlayRecord } from '@/lib/types'; export const runtime = 'edge'; diff --git a/src/app/play/page.tsx b/src/app/play/page.tsx index ed75c51..e0da896 100644 --- a/src/app/play/page.tsx +++ b/src/app/play/page.tsx @@ -109,6 +109,10 @@ function PlayPageClient() { null ); + // 折叠状态(仅在 lg 及以上屏幕有效) + const [isEpisodeSelectorCollapsed, setIsEpisodeSelectorCollapsed] = + useState(false); + // 播放进度保存相关 const saveIntervalRef = useRef(null); const lastSaveTimeRef = useRef(0); @@ -1207,7 +1211,7 @@ function PlayPageClient() { return ( -
+
{/* 第一行:影片标题 */}

@@ -1220,30 +1224,89 @@ function PlayPageClient() {

{/* 第二行:播放器和选集 */} -
- {/* 播放器 */} -
-
+
+ {/* 折叠控制 - 仅在 lg 及以上屏幕显示 */} +
+
- {/* 选集和换源 */} -
- +
+ {/* 播放器 */} +
+
+
+ + {/* 选集和换源 - 在移动端始终显示,在 lg 及以上可折叠 */} +
+ +
diff --git a/src/lib/db.ts b/src/lib/db.ts index 88d0b89..5f8f9fb 100644 --- a/src/lib/db.ts +++ b/src/lib/db.ts @@ -1,10 +1,8 @@ /* eslint-disable no-console, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ +import { AdminConfig } from './admin.types'; import { RedisStorage } from './redis.db'; -import { AdminConfig, Favorite, IStorage, PlayRecord } from './types'; - -// 重新导出类型,保持向后兼容 -export type { AdminConfig, Favorite, IStorage, PlayRecord }; +import { Favorite, IStorage, PlayRecord } from './types'; // storage type 常量: 'localstorage' | 'database',默认 'localstorage' const STORAGE_TYPE = diff --git a/src/lib/redis.db.ts b/src/lib/redis.db.ts index ddb936f..d5f05c9 100644 --- a/src/lib/redis.db.ts +++ b/src/lib/redis.db.ts @@ -2,7 +2,8 @@ import { createClient, RedisClientType } from 'redis'; -import { AdminConfig, Favorite, IStorage, PlayRecord } from './types'; +import { AdminConfig } from './admin.types'; +import { Favorite, IStorage, PlayRecord } from './types'; // 搜索历史最大条数 const SEARCH_HISTORY_LIMIT = 20; diff --git a/src/lib/types.ts b/src/lib/types.ts index 6e40d21..d69cf4c 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -109,6 +109,3 @@ export interface DoubanResult { message: string; list: DoubanItem[]; } - -// 导出AdminConfig类型 -export { AdminConfig };