57 lines
1.3 KiB
Plaintext
57 lines
1.3 KiB
Plaintext
/**
|
||
* 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)
|
||
}
|
||
} |