<?php
require __DIR__ . '/../../app/bootstrap.php';
require __DIR__ . '/../../app/database.php';
require_login();

if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
    http_response_code(405);
    exit('Method Not Allowed');
}
require_csrf();
$taskId = isset($_POST['id']) ? (int)$_POST['id'] : 0;
if ($taskId <= 0) {
    redirect('/admin/site-build/index.php?mode=tasklist');
}

try {
    delete_article_generation_task($taskId);
    log_admin_action('article_task_delete', '删除文章任务 ID:' . $taskId);
    redirect('/admin/site-build/index.php?mode=tasklist');
} catch (Exception $e) {
    redirect('/admin/site-build/index.php?mode=tasklist');
}
