修复系统概览数据不准确的查询。修复交叉评查意见列表的数量查询。优化全局消息提示的层级。优化提交意见进行局部更新。
This commit is contained in:
+18
-6
@@ -20,6 +20,9 @@ export type QueryParams = Record<string, string | number | boolean | undefined>;
|
||||
// const API_BASE_URL = 'http://172.18.0.100:3000';
|
||||
// const API_BASE_URL = 'http://172.16.0.119:9000/admin';
|
||||
|
||||
// 调试:打印当前API_BASE_URL的值
|
||||
console.log('🔍 axios-client.ts - API_BASE_URL.value:', API_BASE_URL.value);
|
||||
|
||||
// 文档URL前缀 (从配置文件导入)
|
||||
// export const DOCUMENT_URL = 'http://nas.7bm.co:9000/docauditai/';
|
||||
export { DOCUMENT_URL };
|
||||
@@ -32,7 +35,7 @@ const DEFAULT_TIMEOUT = 30000; // 增加到30秒
|
||||
|
||||
// 创建 axios 实例
|
||||
const axiosInstance = axios.create({
|
||||
baseURL: API_BASE_URL,
|
||||
baseURL: API_BASE_URL.value === '/api' ? '' : API_BASE_URL.value, // 如果是相对路径,则不设置baseURL
|
||||
timeout: DEFAULT_TIMEOUT, // 增加超时时间
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -97,10 +100,17 @@ function buildUrl(endpoint: string, params?: QueryParams): string {
|
||||
if (endpoint.startsWith('http')) {
|
||||
fullUrl = endpoint;
|
||||
} else {
|
||||
// 确保API_BASE_URL格式正确
|
||||
const baseUrl = API_BASE_URL.endsWith('/') ? API_BASE_URL.slice(0, -1) : API_BASE_URL;
|
||||
const path = endpoint.startsWith('/') ? endpoint : `/${endpoint}`;
|
||||
fullUrl = `${baseUrl}${path}`;
|
||||
// 处理相对路径的情况
|
||||
if (API_BASE_URL.value === '/api') {
|
||||
// 如果是相对路径,直接使用endpoint
|
||||
const path = endpoint.startsWith('/') ? endpoint : `/${endpoint}`;
|
||||
fullUrl = path;
|
||||
} else {
|
||||
// 确保API_BASE_URL格式正确
|
||||
const baseUrl = API_BASE_URL.value.endsWith('/') ? API_BASE_URL.value.slice(0, -1) : API_BASE_URL.value;
|
||||
const path = endpoint.startsWith('/') ? endpoint : `/${endpoint}`;
|
||||
fullUrl = `${baseUrl}${path}`;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -189,6 +199,8 @@ export async function apiRequest<T>(
|
||||
if (USE_MOCK_DATA) {
|
||||
return getMockResponse<T>(endpoint);
|
||||
}
|
||||
|
||||
console.log('api-base-url-----------',API_BASE_URL.value)
|
||||
|
||||
try {
|
||||
// 构建 URL
|
||||
@@ -387,4 +399,4 @@ export async function downloadFile(path: string): Promise<Blob> {
|
||||
console.error('下载文件失败:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user