Major Changes: - Add StreamingService with OpenAI Compatible format - Upgrade Chat component V2 with Ant Design X integration - Implement AIA module with 12 intelligent agents - Update API routes to unified /api/v1 prefix - Update system documentation Backend (~1300 lines): - common/streaming: OpenAI Compatible adapter - modules/aia: 12 agents, conversation service, streaming integration - Update route versions (RVW, PKB to v1) Frontend (~3500 lines): - modules/aia: AgentHub + ChatWorkspace (100% prototype restoration) - shared/Chat: AIStreamChat, ThinkingBlock, useAIStream Hook - Update API endpoints to v1 Documentation: - AIA module status guide - Universal capabilities catalog - System overview updates - All module documentation sync Tested: Stream response verified, authentication working Status: AIA V2.0 core completed (85%)
50 lines
1002 B
TypeScript
50 lines
1002 B
TypeScript
/**
|
|
* 带认证的 Axios 实例
|
|
*
|
|
* 自动添加 Authorization header
|
|
*/
|
|
|
|
import axios from 'axios';
|
|
import { getAccessToken } from '../../framework/auth/api';
|
|
|
|
// 创建 axios 实例
|
|
const apiClient = axios.create({
|
|
timeout: 60000, // 60秒超时
|
|
});
|
|
|
|
// 请求拦截器 - 自动添加 Authorization header
|
|
apiClient.interceptors.request.use(
|
|
(config) => {
|
|
const token = getAccessToken();
|
|
if (token) {
|
|
config.headers.Authorization = `Bearer ${token}`;
|
|
}
|
|
return config;
|
|
},
|
|
(error) => {
|
|
return Promise.reject(error);
|
|
}
|
|
);
|
|
|
|
// 响应拦截器 - 处理 401 错误
|
|
apiClient.interceptors.response.use(
|
|
(response) => response,
|
|
(error) => {
|
|
if (error.response?.status === 401) {
|
|
// Token 过期或无效,可以在这里触发登出
|
|
console.warn('[API] 认证失败,请重新登录');
|
|
// 可选:跳转到登录页
|
|
// window.location.href = '/login';
|
|
}
|
|
return Promise.reject(error);
|
|
}
|
|
);
|
|
|
|
export default apiClient;
|
|
|
|
|
|
|
|
|
|
|
|
|