diff --git a/src/app/api/ad-filter/route.ts b/src/app/api/ad-filter/route.ts
index 33a7033..7de486e 100644
--- a/src/app/api/ad-filter/route.ts
+++ b/src/app/api/ad-filter/route.ts
@@ -7,17 +7,30 @@ export const runtime = 'nodejs';
/**
* GET /api/ad-filter
* 获取自定义去广告代码配置(公开接口,无需认证)
- * 返回代码内容和版本号,客户端通过版本号判断是否需要更新缓存
+ * 支持两种模式:
+ * - 不带参数:只返回版本号,用于检查更新
+ * - ?full=true:返回完整代码和版本号
*/
-export async function GET() {
+export async function GET(request: Request) {
try {
const config = await getConfig();
+ const { searchParams } = new URL(request.url);
+ const full = searchParams.get('full') === 'true';
- // 返回自定义去广告代码和版本号
- return NextResponse.json({
- code: config.SiteConfig?.CustomAdFilterCode || '',
- version: config.SiteConfig?.CustomAdFilterVersion || 0,
- });
+ const version = config.SiteConfig?.CustomAdFilterVersion || 0;
+
+ if (full) {
+ // 返回完整代码和版本号
+ return NextResponse.json({
+ code: config.SiteConfig?.CustomAdFilterCode || '',
+ version,
+ });
+ } else {
+ // 只返回版本号
+ return NextResponse.json({
+ version,
+ });
+ }
} catch (error) {
console.error('获取去广告代码配置失败:', error);
return NextResponse.json(
diff --git a/src/app/douban/page.tsx b/src/app/douban/page.tsx
index 281bf21..2a4e8f0 100644
--- a/src/app/douban/page.tsx
+++ b/src/app/douban/page.tsx
@@ -232,7 +232,7 @@ function DoubanPageClient() {
snapshot1.selectedWeekday === snapshot2.selectedWeekday &&
snapshot1.currentPage === snapshot2.currentPage &&
JSON.stringify(snapshot1.multiLevelSelection) ===
- JSON.stringify(snapshot2.multiLevelSelection)
+ JSON.stringify(snapshot2.multiLevelSelection)
);
},
[]
@@ -715,12 +715,12 @@ function DoubanPageClient() {
return type === 'movie'
? '电影'
: type === 'tv'
- ? '电视剧'
- : type === 'anime'
- ? '动漫'
- : type === 'show'
- ? '综艺'
- : '自定义';
+ ? '电视剧'
+ : type === 'anime'
+ ? '动漫'
+ : type === 'show'
+ ? '综艺'
+ : '自定义';
};
const getPageDescription = () => {
@@ -786,24 +786,24 @@ function DoubanPageClient() {
{loading || !selectorsReady
? // 显示骨架屏
- skeletonData.map((index) =>
)
+ skeletonData.map((index) =>
)
: // 显示实际数据
- doubanData.map((item, index) => (
-
-
-
- ))}
+ doubanData.map((item, index) => (
+
+
+
+ ))}
{/* 加载更多指示器 */}
diff --git a/src/app/page.tsx b/src/app/page.tsx
index 3d4198f..44d026e 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -110,36 +110,39 @@ function HomeClient() {
}, []);
// 处理收藏数据更新的函数
- const updateFavoriteItems = useCallback(async (allFavorites: Record) => {
- const allPlayRecords = await getAllPlayRecords();
+ const updateFavoriteItems = useCallback(
+ async (allFavorites: Record) => {
+ const allPlayRecords = await getAllPlayRecords();
- // 根据保存时间排序(从近到远)
- const sorted = Object.entries(allFavorites)
- .sort(([, a], [, b]) => b.save_time - a.save_time)
- .map(([key, fav]) => {
- const plusIndex = key.indexOf('+');
- const source = key.slice(0, plusIndex);
- const id = key.slice(plusIndex + 1);
+ // 根据保存时间排序(从近到远)
+ const sorted = Object.entries(allFavorites)
+ .sort(([, a], [, b]) => b.save_time - a.save_time)
+ .map(([key, fav]) => {
+ const plusIndex = key.indexOf('+');
+ const source = key.slice(0, plusIndex);
+ const id = key.slice(plusIndex + 1);
- // 查找对应的播放记录,获取当前集数
- const playRecord = allPlayRecords[key];
- const currentEpisode = playRecord?.index;
+ // 查找对应的播放记录,获取当前集数
+ const playRecord = allPlayRecords[key];
+ const currentEpisode = playRecord?.index;
- return {
- id,
- source,
- title: fav.title,
- year: fav.year,
- poster: fav.cover,
- episodes: fav.total_episodes,
- source_name: fav.source_name,
- currentEpisode,
- search_title: fav?.search_title,
- origin: fav?.origin,
- } as FavoriteItem;
- });
- setFavoriteItems(sorted);
- }, []);
+ return {
+ id,
+ source,
+ title: fav.title,
+ year: fav.year,
+ poster: fav.cover,
+ episodes: fav.total_episodes,
+ source_name: fav.source_name,
+ currentEpisode,
+ search_title: fav?.search_title,
+ origin: fav?.origin,
+ } as FavoriteItem;
+ });
+ setFavoriteItems(sorted);
+ },
+ []
+ );
// 当切换到收藏夹时加载收藏数据(使用 ref 防止重复加载)
useEffect(() => {
@@ -256,30 +259,30 @@ function HomeClient() {
{loading
? // 加载状态显示灰色占位数据
- Array.from({ length: 8 }).map((_, index) => (
-
- ))
+ Array.from({ length: 8 }).map((_, index) => (
+
+ ))
: hotMovies.map((movie) => (
-
-
-
- ))}
+
+
+
+ ))}
@@ -300,29 +303,29 @@ function HomeClient() {
{loading
? Array.from({ length: 8 }).map((_, index) => (
-
- ))
+
+ ))
: hotTvShows.map((tvShow) => (
-
-
-
- ))}
+
+
+
+ ))}
@@ -343,29 +346,29 @@ function HomeClient() {
{loading
? Array.from({ length: 8 }).map((_, index) => (
-
- ))
+
+ ))
: hotVarietyShows.map((varietyShow) => (
-
-
-
- ))}
+
+
+
+ ))}
@@ -414,9 +417,9 @@ function HomeClient() {
// 找到当前星期对应的番剧数据,并过滤掉没有图片的
const todayAnimes =
- bangumiCalendarData.find(
- (item) => item.weekday.en === currentWeekday
- )?.items.filter((anime) => anime.images) || [];
+ bangumiCalendarData
+ .find((item) => item.weekday.en === currentWeekday)
+ ?.items.filter((anime) => anime.images) || [];
return todayAnimes.map((anime, index) => (