Files
martial-admin-mini/config/env.config.js
宅房 6d42c4a5ed fix: 修复API模式配置和GET请求参数问题
🐛 修复的问题:
1. 切换 dataMode 从 'mock' 改为 'api'
2. 修复所有GET请求使用 params 而不是 data
   - api/athlete.js: getMyAthletes, getAthletesForAdmin, getVenues, getProjects
   - api/score.js: getDeductions
3. 修复 utils/request.js 支持 params 参数
   - GET 请求使用 params 作为查询参数
   - POST/PUT/DELETE 请求使用 data 作为请求体

 现在可以正确调用后端API接口

📋 测试步骤:
1. 确保后端服务运行在 http://localhost:8080
2. 刷新小程序页面
3. 查看控制台调试信息
4. 验证接口调用

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-11 18:58:30 +08:00

76 lines
1.6 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.
/**
* 环境配置文件
* 控制应用的数据源模式Mock数据 或 真实API
*
* 使用说明:
* 1. Mock模式UI演示、前端独立开发设置 dataMode: 'mock'
* 2. API模式真实数据对接设置 dataMode: 'api'
* 3. 可在代码中动态切换模式
*/
const ENV_CONFIG = {
// 开发环境配置
development: {
// 数据模式: 'mock' | 'api'
// mock - 使用本地Mock数据保护UI版本
// api - 调用真实后端接口
dataMode: 'api',
// API基础路径dataMode为'api'时使用)
apiBaseURL: 'http://localhost:8080',
// 是否开启调试模式
debug: true,
// 请求超时时间(毫秒)
timeout: 30000,
// 是否模拟网络延迟仅Mock模式
mockDelay: 300
},
// 测试环境配置
test: {
dataMode: 'api',
apiBaseURL: 'http://test-api.yourdomain.com',
debug: true,
timeout: 30000,
mockDelay: 0
},
// 生产环境配置
production: {
dataMode: 'api',
apiBaseURL: 'https://api.yourdomain.com',
debug: false,
timeout: 30000,
mockDelay: 0
}
}
// 获取当前环境(开发/测试/生产)
const env = process.env.NODE_ENV || 'development'
// 导出当前环境的配置
export default {
...ENV_CONFIG[env],
env
}
/**
* 快速切换数据模式示例:
*
* // 在代码中使用
* import config from '@/config/env.config.js'
*
* if (config.dataMode === 'mock') {
* console.log('当前使用Mock数据')
* } else {
* console.log('当前使用真实API')
* }
*
* // 查看当前环境
* console.log('当前环境:', config.env)
* console.log('数据模式:', config.dataMode)
*/