fix(SubTabContainer): 移除外层 Suspense,Tab 内容直接展示
- SubTabContainer 内部为每个 Tab 添加 Suspense fallback={null}
- 移除 Company/index.tsx 外层 Suspense 和 TabLoadingFallback
- 切换一级 Tab 时不再显示整体 loading,直接展示内容
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,53 +1,35 @@
|
||||
import { getApiBase } from '../utils/apiConfig';
|
||||
// src/services/financialService.js
|
||||
/**
|
||||
* 完整的财务数据服务层
|
||||
* 对应Flask后端的所有财务API接口
|
||||
*/
|
||||
|
||||
import { logger } from '../utils/logger';
|
||||
|
||||
const isProduction = process.env.NODE_ENV === 'production';
|
||||
const API_BASE_URL = getApiBase();
|
||||
import axios from '@utils/axiosConfig';
|
||||
|
||||
/**
|
||||
* 统一的 API 请求函数
|
||||
* axios 拦截器已自动处理日志记录
|
||||
*/
|
||||
const apiRequest = async (url, options = {}) => {
|
||||
try {
|
||||
logger.debug('financialService', 'API请求', {
|
||||
url: `${API_BASE_URL}${url}`,
|
||||
method: options.method || 'GET'
|
||||
});
|
||||
const { method = 'GET', body, ...rest } = options;
|
||||
|
||||
const response = await fetch(`${API_BASE_URL}${url}`, {
|
||||
...options,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...options.headers,
|
||||
},
|
||||
credentials: 'include', // 包含 cookies,以便后端识别登录状态
|
||||
});
|
||||
const config = {
|
||||
method,
|
||||
url,
|
||||
...rest,
|
||||
};
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
logger.error('financialService', 'apiRequest', new Error(`HTTP ${response.status}`), {
|
||||
url,
|
||||
status: response.status,
|
||||
errorText: errorText.substring(0, 200)
|
||||
});
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
// 如果有 body,根据方法设置 data 或 params
|
||||
if (body) {
|
||||
if (method === 'GET') {
|
||||
config.params = typeof body === 'string' ? JSON.parse(body) : body;
|
||||
} else {
|
||||
config.data = typeof body === 'string' ? JSON.parse(body) : body;
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
logger.debug('financialService', 'API响应', {
|
||||
url,
|
||||
success: data.success,
|
||||
hasData: !!data.data
|
||||
});
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
logger.error('financialService', 'apiRequest', error, { url });
|
||||
throw error;
|
||||
}
|
||||
|
||||
const response = await axios(config);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const financialService = {
|
||||
|
||||
Reference in New Issue
Block a user