flutter
flutter getx 目录结构
lib/
│
├── main.dart
│
├── models/
│ ├── user.dart
│ └── post.dart
│
├── repositories/
│ ├── user_repository.dart
│ └── post_repository.dart
│
├── services/
│ ├── api_service.dart
│ └── local_storage_service.dart
│
├── ui/
│ ├── screens/
│ │ ├── home_screen.dart
│ │ └── profile_screen.dart
│ └── widgets/
│ ├── custom_button.dart
│ └── user_card.dart
│
└── viewmodels/
├── home_viewmodel.dart
└── profile_viewmodel.dart
react
my-typescript-react-app/
│
├── public/
│ ├── index.html
│ └── ...
│
├── src/
│ ├── assets/
│ │ ├── images/
│ │ └── styles/
│ │ │ ├── global.css
│ │ │ └── ...
│ │
│ ├── components/
│ │ ├── common/
│ │ │ ├── Button/
│ │ | ├── Button.tsx
│ │ | ├── button.css
| │ | └── ...
| │ │ └── ...
| │ └── feature/
| │ ├── User/
| │ │ ├── UserList/
| │ | │ ├── UserList.tsx
| │ | | ├── user-list.css
| │ | | └── ...
| | | └── UserProfile/
| | | │ ├── UserProfile.tsx
| | | | ├── user-profile.css
| | | | └── ...
| | └── ...
│ │
│ ├── data/
│ │ ├── models/
| | | ├── User.ts
| | | └── ...
| | ├── services/
| | | ├── api.ts
| | | └── ...
| | └── repositories/
| | | ├── userRepository.ts
| | | └── ...
| |
│ ├── viewmodels/
| | ├── User/
| | | ├── UserListViewModel.ts
| | | └── UserProfileViewModel.ts
| | └── ...
| |
│ ├── views/
| | ├── User/
| | │ ├── UserList/
| | | │ ├── UserList.tsx
| | | | └── ...
| | | └── UserProfile/
| | | │ UserList.tsx
| | | | ├── UserProfile.tsx
| | | ... └── ...
| | └-- ...
| |
│ ├── App.tsx
| | └── ...
| |
│ ├── index.tsx
| └── ...
| |
│ ├── types/
| │ ├── index.ts
| | ******...
| |
| ├── utils/
| | ├── index.css
| | ******...
| |
| └── ...
详细说明
- public/
存放静态资源,如index.html。
- src/
项目的核心源代码。
2.1 assets/
存放静态资产,如图片和全局样式。
· images/: 存放项目中的图片资源。
· styles/: 存放全局样式文件,如global.css。
2.2 components/
存放可复用的UI组件。
· common/: 存放通用的组件,如按钮、输入框等。
· Button/: 包含按钮组件的实现和样式。
· feature/: 存放特定功能模块的组件。
· User/: 包含与用户相关的组件。
· UserList/: 用户列表组件及其样式。
· UserProfile/: 用户详情组件及其样式。
2.3 data/
存放数据相关的代码。
· models/: 定义数据模型。
· User.ts: 用户数据模型的定义。
· services/: 封装与后端API的交互。
· api.ts: 封装API调用的逻辑。
· repositories/: 数据访问层,处理数据的获取和存储。
· userRepository.ts: 用户数据访问逻辑。
2.4 viewmodels/
存放MVVM架构中的视图模型。
· User/: 用户相关的视图模型。
· UserListViewModel.ts: 用户列表视图模型。
· UserProfileViewModel.ts: 用户详情视图模型。
2.5 views/
存放视图层组件,通常与视图模型一一对应。
· User/: 用户相关的视图。
· UserList/: 用户列表视图组件及其样式。
· UserProfile/: 用户详情视图组件及其样式。
2.6 App.tsx 和 index.tsx
· App.tsx: 应用的根组件。
· index.tsx: 应用的入口文件,负责渲染根组件。
2.7 types/
存放自定义类型定义,方便在整个项目中共享和复用类型。
· index.ts: 导出项目中常用的类型。
2.8 utils/
存放工具函数和常量等。
· index.css: 全局样式补充(如果有)。
· 可以存放如日期格式化、字符串处理等工具函数。










网友评论