修复代码质量问题并更新任务进度
修复内容: - API 采集器添加 30 秒超时控制 (AbortController) - 采集服务优化批量插入,修复 URL 为空时的去重逻辑 - 整理类型定义,将 ProcessedContent 移至 types/index.ts - 添加 ReportStatus 和 ReportGenerationOptions 类型 更新任务进度: - 任务 01-05 标记为已完成 - 任务 06-09 待开发 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d8553c06fa
commit
bb9d691f7a
5 files changed
+64
-61
No files matched your search
@@ -27,12 +27,17 @@ export class ApiCollector extends BaseCollector {
|
||||
});
|
||||
}
|
||||
|
||||
// 设置超时控制
|
||||
const controller = new AbortController();
|
||||
const timeout = setTimeout(() => controller.abort(), 30000);
|
||||
|
||||
const options: RequestInit = {
|
||||
method: this.apiConfig.method || 'GET',
|
||||
headers: {
|
||||
'User-Agent': 'News-Aggregator/1.0',
|
||||
...this.apiConfig.headers,
|
||||
},
|
||||
signal: controller.signal,
|
||||
};
|
||||
|
||||
if (this.apiConfig.body && this.apiConfig.method === 'POST') {
|
||||
@@ -44,7 +49,12 @@ export class ApiCollector extends BaseCollector {
|
||||
}
|
||||
|
||||
// 发送请求
|
||||
const response = await fetch(url.toString(), options);
|
||||
let response: Response;
|
||||
try {
|
||||
response = await fetch(url.toString(), options);
|
||||
} finally {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
||||
|
||||
Reference in new issue
Block a user