生产管理系统 - 企业管理页面联调

This commit is contained in:
2025-11-03 17:23:49 +08:00
parent 45c2309662
commit 0305bd64a7
7 changed files with 773 additions and 495 deletions

View File

@@ -0,0 +1,37 @@
/**
* filekorolheader: API配置文件 - API客户端配置和认证处理
* 功能API基础配置、认证头部处理、错误处理
* 路径:/lib/api/config
* 规范遵循crop-x/docs/开发项目规范.md统一API调用配置
*/
import { getAuthToken } from '@/utils/token';
// API基础URL配置 - 开发环境直接使用真实API地址避免重定向问题
export const API_BASE_URL = 'https://gitea-admin-hm-smart-agri-app.dev.maimaiag.com';
// 获取认证头部
export const getAuthHeaders = () => {
const token = getAuthToken();
const headers: Record<string, string> = {
'Content-Type': 'application/json',
'Accept': 'application/json',
// 添加缓存控制头部
'Cache-Control': 'no-store, no-cache, must-revalidate',
'Pragma': 'no-cache',
'Expires': '0',
};
if (token) {
headers['Authorization'] = `Bearer ${token}`;
}
return headers;
};
// API请求配置
export const apiConfig = {
baseURL: API_BASE_URL,
timeout: 30000, // 30秒超时
headers: getAuthHeaders(),
};