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

89 lines
2.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 任务清理API服务
import request from './request'
import { getApiBaseURL } from '@/utils/apiHelper'
export const cleanupApi = {
// 获取清理统计信息
getCleanupStats() {
return request({
url: '/cleanup/cleanup-stats',
method: 'GET'
})
},
// 执行完整清理
performFullCleanup() {
return request({
url: '/cleanup/full-cleanup',
method: 'POST'
})
},
// 清理指定用户任务
cleanupUserTasks(username) {
return request({
url: `/cleanup/user-tasks/${username}`,
method: 'POST'
})
},
// 获取清理统计信息原始fetch方式用于测试
async getCleanupStatsRaw() {
try {
const response = await fetch(`${getApiBaseURL()}/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(`${getApiBaseURL()}/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