feat: 更新项目依赖并重构样式管理

- 添加 React Router 和 Tailwind CSS 依赖
- 移除旧的 CSS 文件,改用模块化样式
- 更新 lint-staged 配置以跳过 CSS 文件
- 重构 App 组件以使用新的导航和样式
This commit is contained in:
zhongyidian committed 2026-01-23 16:02:49 +08:00
1 parent e348e16170
commit 8b32e84206
36 files changed
+698 -144

No files matched your search

+93
View File
@@ -0,0 +1,93 @@
/**
* API 客户端配置
* 可以根据项目需求使用 axios、fetch 或其他 HTTP 客户端
*/
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || "/api";
export interface ApiResponse<T> {
data: T;
message?: string;
code?: number;
}
export interface ApiError {
message: string;
code?: number;
}
/**
* 基础请求函数
*/
export async function request<T>(
endpoint: string,
options?: RequestInit,
): Promise<ApiResponse<T>> {
const url = `${API_BASE_URL}${endpoint}`;
try {
const response = await fetch(url, {
...options,
headers: {
"Content-Type": "application/json",
...options?.headers,
},
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = (await response.json()) as ApiResponse<T>;
return data;
} catch (error) {
throw {
message: error instanceof Error ? error.message : "Unknown error",
code: 500,
} as ApiError;
}
}
/**
* GET 请求
*/
export function get<T>(endpoint: string, options?: RequestInit) {
return request<T>(endpoint, { ...options, method: "GET" });
}
/**
* POST 请求
*/
export function post<T>(
endpoint: string,
data?: unknown,
options?: RequestInit,
) {
return request<T>(endpoint, {
...options,
method: "POST",
body: data ? JSON.stringify(data) : undefined,
});
}
/**
* PUT 请求
*/
export function put<T>(
endpoint: string,
data?: unknown,
options?: RequestInit,
) {
return request<T>(endpoint, {
...options,
method: "PUT",
body: data ? JSON.stringify(data) : undefined,
});
}
/**
* DELETE 请求
*/
export function del<T>(endpoint: string, options?: RequestInit) {
return request<T>(endpoint, { ...options, method: "DELETE" });
}
+9
View File
@@ -0,0 +1,9 @@
export {
type ApiError,
type ApiResponse,
del,
get,
post,
put,
request,
} from "./client.ts";