support keyword crawl

This commit is contained in:
2025-09-26 10:39:36 +08:00
parent 499454ff27
commit a36d730384
12 changed files with 2370 additions and 505 deletions

View File

@@ -36,7 +36,15 @@ function cancelTask(taskId) {
})
.then(response => {
if (response.ok) {
location.reload();
// 显示取消中的提示
const cancelButton = document.querySelector(`a[href="javascript:void(0)"][onclick="cancelTask(${taskId})"]`);
if (cancelButton) {
cancelButton.textContent = '取消中...';
cancelButton.style.pointerEvents = 'none';
cancelButton.style.opacity = '0.5';
}
// 5秒后刷新页面以查看状态更新
setTimeout(() => location.reload(), 2000);
} else {
alert('取消任务失败');
}
@@ -48,6 +56,37 @@ function cancelTask(taskId) {
}
}
function rerunTask(taskId) {
if (confirm('确定要重新执行这个任务吗?这将重置任务状态并重新开始爬取。')) {
fetch(`/admin/core/crawltask/${taskId}/rerun/`, {
method: 'POST',
headers: {
'X-CSRFToken': getCookie('csrftoken'),
'Content-Type': 'application/x-www-form-urlencoded',
},
})
.then(response => {
if (response.ok) {
// 显示重新执行中的提示
const rerunButton = document.querySelector(`a[href="javascript:void(0)"][onclick="rerunTask(${taskId})"]`);
if (rerunButton) {
rerunButton.textContent = '重新执行中...';
rerunButton.style.pointerEvents = 'none';
rerunButton.style.opacity = '0.5';
}
// 2秒后刷新页面以查看状态更新
setTimeout(() => location.reload(), 2000);
} else {
alert('重新执行任务失败');
}
})
.catch(error => {
console.error('Error:', error);
alert('重新执行任务失败');
});
}
}
function viewResults(taskId) {
window.open(`/admin/core/crawltask/${taskId}/results/`, '_blank');
}
@@ -81,4 +120,4 @@ function autoRefreshRunningTasks() {
// 页面加载完成后执行
document.addEventListener('DOMContentLoaded', function() {
autoRefreshRunningTasks();
});
});