Files
ShaFaFanXin/前端/utils/api-test.uts
2026-01-27 18:06:04 +08:00

57 lines
1.3 KiB
Plaintext
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 { getCaseList, getBanners, getActiveServices } from '@/api/index.uts'
// 测试案例列表API
export const testCaseListAPI = async () => {
try {
console.log('测试案例列表API...')
const res = await getCaseList()
console.log('案例列表API响应:', res)
return res
} catch (error) {
console.error('案例列表API错误:', error)
throw error
}
}
// 测试轮播图API
export const testBannersAPI = async () => {
try {
console.log('测试轮播图API...')
const res = await getBanners()
console.log('轮播图API响应:', res)
return res
} catch (error) {
console.error('轮播图API错误:', error)
throw error
}
}
// 测试服务列表API
export const testServicesAPI = async () => {
try {
console.log('测试服务列表API...')
const res = await getActiveServices()
console.log('服务列表API响应:', res)
return res
} catch (error) {
console.error('服务列表API错误:', error)
throw error
}
}
// 运行所有测试
export const runAllTests = async () => {
console.log('开始API对接测试...')
try {
await testBannersAPI()
await testCaseListAPI()
await testServicesAPI()
console.log('所有API测试完成')
} catch (error) {
console.error('API测试失败:', error)
}
}