# React_learing **Repository Path**: leeJax/react_learing ## Basic Information - **Project Name**: React_learing - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-10-10 - **Last Updated**: 2025-10-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 🚀 React Admin Dashboard Template 一个基于 **React 19 + Vite + TypeScript** 的轻量级管理系统模板, 采用现代前端最佳实践构建,适合学习、企业后台或项目脚手架使用。 --- ## 🧩 技术栈概览 | 模块 | 技术 | |------|------| | 前端框架 | **React 19**, **TypeScript** | | 路由管理 | **React Router v6** | | 状态管理 | **Redux Toolkit** | | 数据请求 | **Axios** + **React Query** | | 表单管理 | **React Hook Form** | | UI 组件库 | **Ant Design v5** | | 样式方案 | **TailwindCSS** + 自定义 CSS | | 错误处理 | **Error Boundary** + `antd` message 全局提示 | | 权限控制 | 基于 **角色** 与 **路由守卫** | | 国际化 | **react-i18next** | | 构建工具 | **Vite**(支持代码分割与打包优化) | --- ## 🏗️ 项目结构 ``` css src/ ├─ app/ │ ├─ store.ts # Redux Store │ ├─ hooks.ts # Typed Hooks │ ├─ providers.tsx # 全局 Provider (React Query, AntD, i18n) │ ├─ api/ │ ├─ axios.ts # Axios 实例与拦截器 │ └─ users.ts # 用户相关 API │ ├─ features/ │ ├─ counter/ # Redux 示例模块 │ ├─ users/Users.tsx # 用户管理模块 │ └─ auth/ │ ├─ authSlice.ts # 登录 & 角色管理 │ └─ useAuth.ts # 自定义 Hook 获取用户信息 │ ├─ routes/ │ ├─ PrivateRoute.tsx # 登录守卫 │ └─ RoleRoute.tsx # 角色权限守卫 │ ├─ pages/ │ ├─ Home.tsx │ ├─ Login.tsx │ ├─ About.tsx │ ├─ Forbidden.tsx # 403 页面 │ └─ NotFound.tsx # 404 页面 │ ├─ i18n/ │ ├─ index.ts # 国际化初始化 │ └─ locales/ │ ├─ zh.json │ └─ en.json │ ├─ components/ │ └─ ErrorBoundary.tsx # 全局错误捕获 │ ├─ styles/ │ ├─ index.css │ └─ app.css │ ├─ App.tsx # 根路由配置 └─ main.tsx # 应用入口 ``` --- ## ⚙️ 快速开始 ### 1️⃣ 克隆项目 ```bash git clone https://github.com/yourname/react-admin-template.git cd react-admin-template ``` ### 2️⃣ 安装依赖 ```bash npm install ``` ### 3️⃣ 运行开发环境 ```bash npm run dev ``` 浏览器打开 `http://localhost:5173`。 ### 4️⃣ 打包生产环境 ```bash npm run build ``` 构建结果在 `dist/` 目录,可直接部署到静态服务器。 --- ## 🔐 权限机制 - 用户登录信息保存在 Redux `authSlice` 中; - `PrivateRoute` 负责校验是否登录; - `RoleRoute` 控制访问权限(如仅 admin 可访问用户管理页); - 403 页面通过路由跳转显示。 示例: ```tsx } /> ``` --- ## 🌍 国际化 通过 `react-i18next` 实现中英文切换: - 多语言资源放在 `src/i18n/locales/`; - 导航栏中使用 `