src/
├── api/ # 所有 API 接口请求封装(封装 Axios 实例 + 每个资源的调用函数)
├── assets/ # 静态资源(图片、SVG、字体等)
├── components/ # 通用且可复用的 UI 组件
├── features/ # 按业务功能划分的模块化代码,内聚一个完整业务相关的功能,包含页面 + 状态 + 组件 + hooks 等
├── hooks/ # 跨模块共享的自定义 hooks
├── layouts/ # 页面布局组件(如 MainLayout、DashboardLayout 等)
├── pages/ # 页面级组件(用于 React Router 注册路由的组件)
├── routes/ # 路由定义(可以拆分为不同模块的子路由)
├── store/ # 全局状态(Zustand stores 或其他跨模块的全局状态)
├── ui/ # 原子级别基础组件(按钮、输入框、Modal 等)
├── utils/ # 工具函数(如格式化、校验、日期处理等)
├── mocks/ # mock 数据与 mock server 配置(如 MSW)
...This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
- @vitejs/plugin-react uses Babel for Fast Refresh
- @vitejs/plugin-react-swc uses SWC for Fast Refresh
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
export default tseslint.config([
globalIgnores(["dist"]),
{
files: ["**/*.{ts,tsx}"],
extends: [
// Other configs...
// Remove tseslint.configs.recommended and replace with this
...tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
...tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
...tseslint.configs.stylisticTypeChecked,
// Other configs...
],
languageOptions: {
parserOptions: {
project: ["./tsconfig.node.json", "./tsconfig.app.json"],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
]);You can also install eslint-plugin-react-x and eslint-plugin-react-dom for React-specific lint rules:
// eslint.config.js
import reactX from "eslint-plugin-react-x";
import reactDom from "eslint-plugin-react-dom";
export default tseslint.config([
globalIgnores(["dist"]),
{
files: ["**/*.{ts,tsx}"],
extends: [
// Other configs...
// Enable lint rules for React
reactX.configs["recommended-typescript"],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
languageOptions: {
parserOptions: {
project: ["./tsconfig.node.json", "./tsconfig.app.json"],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
]);