Files
AIGC/demo/frontend/src/api/cleanup.js

88 lines
2.0 KiB
JavaScript
Raw Normal View History

// 任务清理API服务
import request from './request'
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 {
const response = await fetch('/api/cleanup/cleanup-stats')
if (response.ok) {
return await response.json()
} else {
throw new Error('获取统计信息失败')
}
} catch (error) {
console.error('获取统计信息失败:', error)
throw error
}
},
// 执行完整清理原始fetch方式用于测试
async performFullCleanupRaw() {
try {
const response = await fetch('/api/cleanup/full-cleanup', {
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