mirror of
https://github.com/MoonTechLab/LunaTV.git
synced 2026-06-09 18:33:14 +08:00
release 100.1.3
- 修复首页热门数据在番剧接口失败时一并空白:改为 Promise.allSettled - 番剧日历改走服务端代理 /api/bangumi/calendar,规避 bgm.tv CORS Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
## [100.1.3] - 2026-05-28
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- 修复首页热门电影、热门剧集、热门综艺在番剧接口失败时一并空白的问题
|
||||||
|
- 番剧日历改为通过服务端代理请求,规避 bgm.tv 的 CORS 限制
|
||||||
|
|
||||||
## [100.1.2] - 2026-03-15
|
## [100.1.2] - 2026-03-15
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
100.1.2
|
100.1.3
|
||||||
|
|||||||
43
src/app/api/bangumi/calendar/route.ts
Normal file
43
src/app/api/bangumi/calendar/route.ts
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import { NextResponse } from 'next/server';
|
||||||
|
|
||||||
|
import { getCacheTime } from '@/lib/config';
|
||||||
|
|
||||||
|
export const runtime = 'nodejs';
|
||||||
|
|
||||||
|
export async function GET() {
|
||||||
|
const controller = new AbortController();
|
||||||
|
const timeoutId = setTimeout(() => controller.abort(), 10000);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch('https://api.bgm.tv/calendar', {
|
||||||
|
signal: controller.signal,
|
||||||
|
headers: {
|
||||||
|
'User-Agent':
|
||||||
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36',
|
||||||
|
Accept: 'application/json',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`HTTP error! Status: ${response.status}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
const cacheTime = await getCacheTime();
|
||||||
|
|
||||||
|
return NextResponse.json(data, {
|
||||||
|
headers: {
|
||||||
|
'Cache-Control': `public, max-age=${cacheTime}, s-maxage=${cacheTime}`,
|
||||||
|
'CDN-Cache-Control': `public, s-maxage=${cacheTime}`,
|
||||||
|
'Vercel-CDN-Cache-Control': `public, s-maxage=${cacheTime}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: '获取番剧日历失败', details: (error as Error).message },
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -72,9 +72,10 @@ function HomeClient() {
|
|||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
// 并行获取热门电影、热门剧集和热门综艺
|
// 并行获取热门电影、热门剧集、热门综艺和番剧日历
|
||||||
const [moviesData, tvShowsData, varietyShowsData, bangumiCalendarData] =
|
// 使用 allSettled 避免单个请求失败导致全部数据为空
|
||||||
await Promise.all([
|
const [moviesRes, tvShowsRes, varietyShowsRes, bangumiRes] =
|
||||||
|
await Promise.allSettled([
|
||||||
getDoubanCategories({
|
getDoubanCategories({
|
||||||
kind: 'movie',
|
kind: 'movie',
|
||||||
category: '热门',
|
category: '热门',
|
||||||
@@ -85,19 +86,32 @@ function HomeClient() {
|
|||||||
GetBangumiCalendarData(),
|
GetBangumiCalendarData(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (moviesData.code === 200) {
|
if (moviesRes.status === 'fulfilled' && moviesRes.value.code === 200) {
|
||||||
setHotMovies(moviesData.list);
|
setHotMovies(moviesRes.value.list);
|
||||||
|
} else if (moviesRes.status === 'rejected') {
|
||||||
|
console.error('获取热门电影失败:', moviesRes.reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tvShowsData.code === 200) {
|
if (tvShowsRes.status === 'fulfilled' && tvShowsRes.value.code === 200) {
|
||||||
setHotTvShows(tvShowsData.list);
|
setHotTvShows(tvShowsRes.value.list);
|
||||||
|
} else if (tvShowsRes.status === 'rejected') {
|
||||||
|
console.error('获取热门剧集失败:', tvShowsRes.reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (varietyShowsData.code === 200) {
|
if (
|
||||||
setHotVarietyShows(varietyShowsData.list);
|
varietyShowsRes.status === 'fulfilled' &&
|
||||||
|
varietyShowsRes.value.code === 200
|
||||||
|
) {
|
||||||
|
setHotVarietyShows(varietyShowsRes.value.list);
|
||||||
|
} else if (varietyShowsRes.status === 'rejected') {
|
||||||
|
console.error('获取热门综艺失败:', varietyShowsRes.reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
setBangumiCalendarData(bangumiCalendarData);
|
if (bangumiRes.status === 'fulfilled') {
|
||||||
|
setBangumiCalendarData(bangumiRes.value);
|
||||||
|
} else {
|
||||||
|
console.error('获取番剧日历失败:', bangumiRes.reason);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取推荐数据失败:', error);
|
console.error('获取推荐数据失败:', error);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -23,7 +23,10 @@ export interface BangumiCalendarData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function GetBangumiCalendarData(): Promise<BangumiCalendarData[]> {
|
export async function GetBangumiCalendarData(): Promise<BangumiCalendarData[]> {
|
||||||
const response = await fetch('https://api.bgm.tv/calendar');
|
const response = await fetch('/api/bangumi/calendar');
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`获取番剧日历失败: HTTP ${response.status}`);
|
||||||
|
}
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
const filteredData = data.map((item: BangumiCalendarData) => ({
|
const filteredData = data.map((item: BangumiCalendarData) => ({
|
||||||
...item,
|
...item,
|
||||||
|
|||||||
@@ -10,6 +10,20 @@ export interface ChangelogEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const changelog: ChangelogEntry[] = [
|
export const changelog: ChangelogEntry[] = [
|
||||||
|
{
|
||||||
|
version: "100.1.3",
|
||||||
|
date: "2026-05-28",
|
||||||
|
added: [
|
||||||
|
// 无新增内容
|
||||||
|
],
|
||||||
|
changed: [
|
||||||
|
// 无变更内容
|
||||||
|
],
|
||||||
|
fixed: [
|
||||||
|
"修复首页热门电影、热门剧集、热门综艺在番剧接口失败时一并空白的问题",
|
||||||
|
"番剧日历改为通过服务端代理请求,规避 bgm.tv 的 CORS 限制"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
version: "100.1.2",
|
version: "100.1.2",
|
||||||
date: "2026-03-15",
|
date: "2026-03-15",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
|
|
||||||
const CURRENT_VERSION = '100.1.2';
|
const CURRENT_VERSION = '100.1.3';
|
||||||
|
|
||||||
// 导出当前版本号供其他地方使用
|
// 导出当前版本号供其他地方使用
|
||||||
export { CURRENT_VERSION };
|
export { CURRENT_VERSION };
|
||||||
|
|||||||
Reference in New Issue
Block a user