基于 React + TypeScript + Material-UI 的现代化文件管理系统前端。
- React 19 - 前端框架
- TypeScript - 类型安全
- Material-UI v7 - UI组件库
- React Router v7 - 路由管理
- Vite - 构建工具
- Axios - HTTP客户端
- React Context - 状态管理
pages/
├── src/
│ ├── components/ # 通用组件
│ │ ├── DataTable/ # 增强数据表格
│ │ ├── PageTemplate/ # 页面模板
│ │ └── Sidebar/ # 侧边栏
│ ├── contexts/ # React Context
│ │ └── AppContext.tsx # 全局状态管理
│ ├── layouts/ # 布局组件
│ │ └── MainLayout.tsx # 主布局
│ ├── pages/ # 页面组件
│ │ ├── FileManagement/ # 文件管理
│ │ ├── PersonalManagement/ # 个人管理
│ │ └── SystemManagement/ # 系统管理
│ ├── services/ # API服务
│ │ └── api.ts # API接口封装
│ ├── theme/ # 主题配置
│ │ └── index.ts # 主题定义
│ ├── types/ # 类型定义
│ ├── App.tsx # 主应用组件
│ ├── router.tsx # 路由配置
│ └── main.tsx # 应用入口
├── public/ # 静态资源
└── package.json # 项目配置
- 文件管理: 我的文件、公共目录、文件分享
- 个人管理: 账号设置、加密配置、伙伴配置、任务配置
- 系统管理: 用户管理、群组管理、OAuth管理、系统设置
- 支持桌面端和移动端
- 自适应布局
- 触摸友好的交互
- 支持浅色/深色主题切换
- 主题持久化存储
- 自定义主题配置
- 统一API服务层
- 错误处理机制
- 数据缓存策略
npm installnpm run devnpm run buildnpm run lint- 在
src/pages/下创建页面组件:
import React from 'react';
import PageTemplate from '../../components/PageTemplate';
const MyPage: React.FC = () => {
return (
<PageTemplate
title="页面标题"
breadcrumbs={[{ name: '首页' }, { name: '页面标题' }]}
>
{/* 页面内容 */}
</PageTemplate>
);
};
export default MyPage;- 在
src/router.tsx中添加路由:
<Route path="/my-page" element={<MyPage />} />import DataTable from '../components/DataTable';
const columns = [
{ id: 'name', label: '名称', sortable: true },
{ id: 'size', label: '大小', align: 'right' },
{ id: 'date', label: '日期', format: (value) => new Date(value).toLocaleDateString() },
];
const MyComponent = () => {
const rows = [
{ id: '1', name: '文件1', size: '1MB', date: '2025-09-25' },
{ id: '2', name: '文件2', size: '2MB', date: '2025-09-24' },
];
return (
<DataTable
columns={columns}
rows={rows}
title="文件列表"
showCheckbox={true}
showPagination={true}
/>
);
};import { fileApi, userApi } from '../posts/api';
// 获取文件列表
const files = await fileApi.getFiles({ path: '/documents' });
// 上传文件
const result = await fileApi.uploadFile(file, '/uploads', (progress) => {
console.log(`上传进度: ${progress}%`);
});
// 获取用户信息
const userInfo = await userApi.getUserInfo();import { useApp } from '../contexts/AppContext';
const MyComponent = () => {
const { state, login, logout, toggleTheme, showNotification } = useApp();
// 获取当前用户信息
const { user, isAuthenticated, theme } = state;
// 切换主题
const handleToggleTheme = () => {
toggleTheme();
};
// 显示通知
const handleShowNotification = () => {
showNotification('success', '操作成功!');
};
return (
<div>
<p>当前主题: {theme}</p>
<p>用户: {user?.username}</p>
<button onClick={handleToggleTheme}>切换主题</button>
<button onClick={handleShowNotification}>显示通知</button>
</div>
);
};创建 .env 文件:
VITE_API_BASE_URL=http://localhost:8080/api在 src/theme/index.ts 中自定义主题:
export const lightTheme = createTheme({
palette: {
primary: { main: '#1976d2' },
secondary: { main: '#dc004e' },
},
});- 布局: Box, Grid, Container, Stack
- 导航: AppBar, Drawer, Menu, Breadcrumbs
- 数据展示: Table, List, Card, Chip
- 反馈: Snackbar, Dialog, Progress
- 输入: TextField, Button, Select, Checkbox
- PageTemplate: 页面模板,包含标题、面包屑、操作栏
- DataTable: 增强数据表格,支持排序、分页、选择
- MainLayout: 主布局,包含侧边栏和顶部栏
- JWT认证
- 权限控制
- 输入验证
- XSS防护
- CSRF防护
- Chrome (推荐)
- Firefox
- Safari
- Edge
- Fork 项目
- 创建特性分支 (
git checkout -b feature/amazing-feature) - 提交更改 (
git commit -m 'Add some amazing feature') - 推送到分支 (
git push origin feature/amazing-feature) - 创建 Pull Request
此项目基于 MIT 许可证开源 - 查看 LICENSE 文件了解详情。