feat: 实现前端组件库和API服务基础架构

refactor: 移除废弃的AGI策略演进服务

fix: 修正磁盘I/O指标字段命名

chore: 更新项目依赖版本

test: 添加前后端集成测试用例

docs: 更新AI模块接口文档

style: 统一审计日志字段命名规范

perf: 优化Redis订阅连接错误处理

build: 配置多项目工作区结构

ci: 添加Vite开发服务器CORS支持
This commit is contained in:
2026-03-18 15:22:55 +08:00
parent b31591e04c
commit c932a67be2
96 changed files with 37748 additions and 16326 deletions

View File

@@ -0,0 +1,42 @@
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
const API_BASE_URL = process.env.NODE_ENV === 'production'
? '/api'
: 'http://localhost:3000/api';
const apiClient: AxiosInstance = axios.create({
baseURL: API_BASE_URL,
timeout: 10000,
headers: {
'Content-Type': 'application/json',
},
});
apiClient.interceptors.request.use(
(config: AxiosRequestConfig) => {
const token = localStorage.getItem('token');
if (token && config.headers) {
config.headers.Authorization = `Bearer ${token}`;
}
return config;
},
(error) => {
return Promise.reject(error);
}
);
apiClient.interceptors.response.use(
(response: AxiosResponse) => {
return response.data;
},
(error) => {
if (error.response?.status === 401) {
// 处理未授权错误
localStorage.removeItem('token');
window.location.href = '/auth/login';
}
return Promise.reject(error);
}
);
export default apiClient;

View File

@@ -0,0 +1,3 @@
export { userApi } from './user';
export { productApi } from './product';
export { orderApi } from './order';

View File

@@ -0,0 +1,54 @@
import apiClient from './client';
interface OrderItem {
id: string;
productId: string;
productName: string;
quantity: number;
price: number;
}
interface Order {
id: string;
orderNo: string;
customerId: string;
customerName: string;
totalAmount: number;
status: 'pending' | 'processing' | 'shipped' | 'delivered' | 'cancelled';
items: OrderItem[];
createdAt: string;
updatedAt: string;
}
interface OrderListResponse {
data: Order[];
total: number;
page: number;
pageSize: number;
}
export const orderApi = {
getList: async (params: {
page?: number;
pageSize?: number;
status?: string;
startDate?: string;
endDate?: string;
}): Promise<OrderListResponse> => {
return apiClient.get('/orders', { params });
},
getDetail: async (id: string): Promise<Order> => {
return apiClient.get(`/orders/${id}`);
},
create: async (data: any): Promise<Order> => {
return apiClient.post('/orders', data);
},
updateStatus: async (id: string, status: Order['status']): Promise<Order> => {
return apiClient.put(`/orders/${id}/status`, { status });
},
cancel: async (id: string): Promise<Order> => {
return apiClient.put(`/orders/${id}/cancel`);
},
};
export default orderApi;

View File

@@ -0,0 +1,42 @@
import apiClient from './client';
interface Product {
id: string;
name: string;
price: number;
stock: number;
category: string;
status: 'active' | 'inactive';
}
interface ProductListResponse {
data: Product[];
total: number;
page: number;
pageSize: number;
}
export const productApi = {
getList: async (params: {
page?: number;
pageSize?: number;
category?: string;
status?: string;
}): Promise<ProductListResponse> => {
return apiClient.get('/products', { params });
},
getDetail: async (id: string): Promise<Product> => {
return apiClient.get(`/products/${id}`);
},
create: async (data: Omit<Product, 'id'>): Promise<Product> => {
return apiClient.post('/products', data);
},
update: async (id: string, data: Partial<Product>): Promise<Product> => {
return apiClient.put(`/products/${id}`, data);
},
delete: async (id: string): Promise<void> => {
return apiClient.delete(`/products/${id}`);
},
};
export default productApi;

View File

@@ -0,0 +1,35 @@
import apiClient from './client';
interface User {
id: string;
name: string;
email: string;
role: string;
}
interface LoginRequest {
email: string;
password: string;
}
interface LoginResponse {
token: string;
user: User;
}
export const userApi = {
login: async (data: LoginRequest): Promise<LoginResponse> => {
return apiClient.post('/auth/login', data);
},
register: async (data: any): Promise<User> => {
return apiClient.post('/auth/register', data);
},
getProfile: async (): Promise<User> => {
return apiClient.get('/user/profile');
},
updateProfile: async (data: any): Promise<User> => {
return apiClient.put('/user/profile', data);
},
};
export default userApi;