2025-10-27 10:46:49 +08:00
|
|
|
|
// 任务清理API服务
|
|
|
|
|
|
import request from './request'
|
2025-11-03 18:09:23 +08:00
|
|
|
|
import { getApiBaseURL } from '@/utils/apiHelper'
|
2025-10-27 10:46:49 +08:00
|
|
|
|
|
|
|
|
|
|
export const cleanupApi = {
|
|
|
|
|
|
// 获取清理统计信息
|
|
|
|
|
|
getCleanupStats() {
|
|
|
|
|
|
return request({
|
|
|
|
|
|
url: '/api/cleanup/cleanup-stats',
|
|
|
|
|
|
method: 'GET'
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 执行完整清理
|
|
|
|
|
|
performFullCleanup() {
|
|
|
|
|
|
return request({
|
|
|
|
|
|
url: '/api/cleanup/full-cleanup',
|
|
|
|
|
|
method: 'POST'
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 清理指定用户任务
|
|
|
|
|
|
cleanupUserTasks(username) {
|
|
|
|
|
|
return request({
|
|
|
|
|
|
url: `/api/cleanup/user-tasks/${username}`,
|
|
|
|
|
|
method: 'POST'
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 获取清理统计信息(原始fetch方式,用于测试)
|
|
|
|
|
|
async getCleanupStatsRaw() {
|
|
|
|
|
|
try {
|
2025-11-03 18:09:23 +08:00
|
|
|
|
const response = await fetch(`${getApiBaseURL()}/cleanup/cleanup-stats`)
|
2025-10-27 10:46:49 +08:00
|
|
|
|
if (response.ok) {
|
|
|
|
|
|
return await response.json()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
throw new Error('获取统计信息失败')
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('获取统计信息失败:', error)
|
|
|
|
|
|
throw error
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 执行完整清理(原始fetch方式,用于测试)
|
|
|
|
|
|
async performFullCleanupRaw() {
|
|
|
|
|
|
try {
|
2025-11-03 18:09:23 +08:00
|
|
|
|
const response = await fetch(`${getApiBaseURL()}/cleanup/full-cleanup`, {
|
2025-10-27 10:46:49 +08:00
|
|
|
|
method: 'POST',
|
|
|
|
|
|
headers: {
|
|
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
|
return await response.json()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
throw new Error('执行完整清理失败')
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('执行完整清理失败:', error)
|
|
|
|
|
|
throw error
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 清理指定用户任务(原始fetch方式,用于测试)
|
|
|
|
|
|
async cleanupUserTasksRaw(username) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const response = await fetch(`/api/cleanup/user-tasks/${username}`, {
|
|
|
|
|
|
method: 'POST',
|
|
|
|
|
|
headers: {
|
|
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
|
return await response.json()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
throw new Error('清理用户任务失败')
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('清理用户任务失败:', error)
|
|
|
|
|
|
throw error
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default cleanupApi
|