mirror of
https://github.com/MoonTechLab/LunaTV.git
synced 2026-02-28 15:54:43 +08:00
feat: concurrent refresh
This commit is contained in:
@@ -23,18 +23,20 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
}
|
||||
|
||||
for (const liveInfo of config.LiveConfig || []) {
|
||||
if (liveInfo.disabled) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
const nums = await refreshLiveChannels(liveInfo);
|
||||
liveInfo.channelNumber = nums;
|
||||
} catch (error) {
|
||||
console.error('刷新直播源失败:', error);
|
||||
liveInfo.channelNumber = 0;
|
||||
}
|
||||
}
|
||||
// 并发刷新所有启用的直播源
|
||||
const refreshPromises = (config.LiveConfig || [])
|
||||
.filter(liveInfo => !liveInfo.disabled)
|
||||
.map(async (liveInfo) => {
|
||||
try {
|
||||
const nums = await refreshLiveChannels(liveInfo);
|
||||
liveInfo.channelNumber = nums;
|
||||
} catch (error) {
|
||||
liveInfo.channelNumber = 0;
|
||||
}
|
||||
});
|
||||
|
||||
// 等待所有刷新任务完成
|
||||
await Promise.all(refreshPromises);
|
||||
|
||||
// 保存配置
|
||||
await db.saveAdminConfig(config);
|
||||
|
||||
@@ -7,11 +7,11 @@ import Hls from 'hls.js';
|
||||
import { Radio, Tv } from 'lucide-react';
|
||||
import { Suspense, useEffect, useRef, useState } from 'react';
|
||||
|
||||
import { processImageUrl } from '@/lib/utils';
|
||||
import { parseCustomTimeFormat } from '@/lib/time';
|
||||
import { processImageUrl } from '@/lib/utils';
|
||||
|
||||
import PageLayout from '@/components/PageLayout';
|
||||
import EpgScrollableRow from '@/components/EpgScrollableRow';
|
||||
import PageLayout from '@/components/PageLayout';
|
||||
|
||||
// 扩展 HTMLVideoElement 类型以支持 hls 属性
|
||||
declare global {
|
||||
@@ -139,7 +139,7 @@ function LivePageClient() {
|
||||
|
||||
const cleanedPrograms: Array<{ start: string; end: string; title: string }> = [];
|
||||
let removedCount = 0;
|
||||
let dateFilteredCount = programs.length - todayPrograms.length;
|
||||
const dateFilteredCount = programs.length - todayPrograms.length;
|
||||
|
||||
for (let i = 0; i < sortedPrograms.length; i++) {
|
||||
const currentProgram = sortedPrograms[i];
|
||||
|
||||
Reference in New Issue
Block a user