44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
|
|
// 测试模拟数据功能
|
||
|
|
const mockAPI = require('./src/api/mockData.ts')
|
||
|
|
|
||
|
|
console.log('🧪 测试模拟数据API...')
|
||
|
|
|
||
|
|
// 测试登录功能
|
||
|
|
console.log('\n1. 测试登录功能')
|
||
|
|
mockAPI.mockAuthAPI.login({ username: 'admin', password: 'admin123' })
|
||
|
|
.then(response => {
|
||
|
|
console.log('✅ 登录成功:', response.data.admin.username)
|
||
|
|
return mockAPI.mockAuthAPI.getCurrentUser()
|
||
|
|
})
|
||
|
|
.then(response => {
|
||
|
|
console.log('✅ 获取当前用户成功:', response.data.admin.nickname)
|
||
|
|
})
|
||
|
|
.catch(error => {
|
||
|
|
console.log('❌ 登录测试失败:', error.message)
|
||
|
|
})
|
||
|
|
|
||
|
|
// 测试用户列表
|
||
|
|
console.log('\n2. 测试用户列表')
|
||
|
|
mockAPI.mockUserAPI.getUsers({ page: 1, pageSize: 5 })
|
||
|
|
.then(response => {
|
||
|
|
console.log('✅ 获取用户列表成功:', response.data.list.length + '个用户')
|
||
|
|
})
|
||
|
|
.catch(error => {
|
||
|
|
console.log('❌ 用户列表测试失败:', error.message)
|
||
|
|
})
|
||
|
|
|
||
|
|
// 测试系统统计
|
||
|
|
console.log('\n3. 测试系统统计')
|
||
|
|
mockAPI.mockSystemAPI.getSystemStats()
|
||
|
|
.then(response => {
|
||
|
|
console.log('✅ 获取系统统计成功:')
|
||
|
|
console.log(' - 用户数:', response.data.userCount)
|
||
|
|
console.log(' - 商家数:', response.data.merchantCount)
|
||
|
|
console.log(' - 旅行数:', response.data.travelCount)
|
||
|
|
console.log(' - 动物数:', response.data.animalCount)
|
||
|
|
})
|
||
|
|
.catch(error => {
|
||
|
|
console.log('❌ 系统统计测试失败:', error.message)
|
||
|
|
})
|
||
|
|
|
||
|
|
console.log('\n🎉 模拟数据测试完成!')
|