docs: add CODE-MAP.md
This commit is contained in:
parent
bb645e8428
commit
e7d1b20339
166
CODE-MAP.md
Normal file
166
CODE-MAP.md
Normal file
@ -0,0 +1,166 @@
|
||||
# CODE MAP(Flutter 项目)
|
||||
|
||||
## 1) 目录树(文件级,聚焦 lib/)
|
||||
|
||||
```text
|
||||
banxiang_app/
|
||||
├── README.md
|
||||
├── analysis_options.yaml
|
||||
├── pubspec.yaml
|
||||
├── pubspec.lock
|
||||
├── lib/
|
||||
│ ├── main.dart
|
||||
│ ├── main.dart.bak
|
||||
│ ├── theme.dart
|
||||
│ ├── models/
|
||||
│ │ ├── activity.dart
|
||||
│ │ ├── hospital.dart
|
||||
│ │ ├── message.dart
|
||||
│ │ └── user.dart
|
||||
│ ├── screens/
|
||||
│ │ ├── activity_detail_screen.dart
|
||||
│ │ ├── activity_list_screen.dart
|
||||
│ │ ├── ai_chat_screen.dart
|
||||
│ │ ├── booking_screen.dart
|
||||
│ │ ├── create_activity_screen.dart
|
||||
│ │ ├── department_screen.dart
|
||||
│ │ ├── doctor_list_screen.dart
|
||||
│ │ ├── home_screen.dart
|
||||
│ │ ├── hospital_list_screen.dart
|
||||
│ │ ├── login_screen.dart
|
||||
│ │ ├── main_screen.dart
|
||||
│ │ ├── medical_screen.dart
|
||||
│ │ ├── messages_screen.dart
|
||||
│ │ ├── order_list_screen.dart
|
||||
│ │ ├── payment_screen.dart
|
||||
│ │ ├── profile_screen.dart
|
||||
│ │ ├── profile_setup_screen.dart
|
||||
│ │ ├── publish_screen.dart
|
||||
│ │ └── services_screen.dart
|
||||
│ ├── services/
|
||||
│ │ ├── activity_service.dart
|
||||
│ │ ├── ai_service.dart
|
||||
│ │ ├── auth_service.dart
|
||||
│ │ └── medical_service.dart
|
||||
│ └── utils/
|
||||
│ └── constants.dart
|
||||
├── test/
|
||||
│ └── widget_test.dart
|
||||
├── android/...
|
||||
├── ios/...
|
||||
├── web/...
|
||||
├── linux/...
|
||||
├── macos/...
|
||||
└── windows/...
|
||||
```
|
||||
|
||||
## 2) Dart 文件一行说明
|
||||
|
||||
| 文件 | 说明 |
|
||||
|---|---|
|
||||
| lib/main.dart | 应用入口,读取本地 token 后决定进入登录页或活动广场页。 |
|
||||
| lib/theme.dart | 定义全局浅色主题 `AppTheme.lightTheme`(色彩、按钮、输入框、导航栏等)。 |
|
||||
| lib/models/activity.dart | 活动实体模型,承载标题、分类、时间、地点、人数等基础字段。 |
|
||||
| lib/models/hospital.dart | 医疗相关实体定义,包含 `Hospital`、`Doctor`、`Appointment` 三类模型。 |
|
||||
| lib/models/message.dart | 聊天消息模型,包含文本、发送方与消息时间。 |
|
||||
| lib/models/user.dart | 用户资料模型,包含手机号、昵称、性别、兴趣等信息。 |
|
||||
| lib/screens/activity_detail_screen.dart | 活动详情页,含图片轮播、评论区、点赞与报名底栏。 |
|
||||
| lib/screens/activity_list_screen.dart | 活动广场页,瀑布流展示活动卡片并提供底部导航和发布入口。 |
|
||||
| lib/screens/ai_chat_screen.dart | AI 聊天页,支持快捷提问、消息渲染和自动滚动到底部。 |
|
||||
| lib/screens/booking_screen.dart | 预约挂号下单页,收集就诊信息并创建 `Appointment` 后跳转支付。 |
|
||||
| lib/screens/create_activity_screen.dart | 发起活动表单页,填写后写入 `ActivityService`。 |
|
||||
| lib/screens/department_screen.dart | 医院科室选择页,点击科室进入医生列表。 |
|
||||
| lib/screens/doctor_list_screen.dart | 医生列表页,按科室读取医生并进入预约页。 |
|
||||
| lib/screens/home_screen.dart | 另一版首页实现(分类筛选 + 活动列表 + 发起活动入口)。 |
|
||||
| lib/screens/hospital_list_screen.dart | 医院列表页,展示医院与科室标签并进入科室选择。 |
|
||||
| lib/screens/login_screen.dart | 手机验证码模拟登录页,登录后按是否新用户分流到资料完善或活动页。 |
|
||||
| lib/screens/main_screen.dart | 底部 Tab 主容器,聚合首页/服务/AI/消息/我的五个页面。 |
|
||||
| lib/screens/medical_screen.dart | 医疗健康服务聚合页,含医院、科室、医生弹层和在线问诊弹窗。 |
|
||||
| lib/screens/messages_screen.dart | 消息通知页,展示活动/支付/问诊等系统通知卡片。 |
|
||||
| lib/screens/order_list_screen.dart | 订单列表页,展示挂号订单并支持取消或去支付。 |
|
||||
| lib/screens/payment_screen.dart | 支付确认页,模拟支付流程并更新预约状态。 |
|
||||
| lib/screens/profile_screen.dart | 个人资料编辑页,读取并保存昵称、城市和兴趣到本地。 |
|
||||
| lib/screens/profile_setup_screen.dart | 新用户三步资料完善流程,最终调用 `AuthService.updateProfile`。 |
|
||||
| lib/screens/publish_screen.dart | 发布页,支持图片/视频二选一上传、预览删除与发布校验。 |
|
||||
| lib/screens/services_screen.dart | 生活服务总入口页,提供医疗健康分类与快捷入口。 |
|
||||
| lib/services/activity_service.dart | 活动 mock 数据服务,提供活动分类、查询和新增。 |
|
||||
| lib/services/ai_service.dart | AI 回复 mock 服务,基于关键词规则返回双消息(用户+助手)。 |
|
||||
| lib/services/auth_service.dart | 认证与用户资料服务,管理登录态、验证码、登录、资料更新和退出。 |
|
||||
| lib/services/medical_service.dart | 医疗 mock 数据服务,提供医院/医生数据与预约列表维护。 |
|
||||
| lib/utils/constants.dart | 应用常量定义(应用名、口号、活动分类、兴趣标签等)。 |
|
||||
|
||||
## 3) Core Methods Index
|
||||
|
||||
格式:`filename | method_name | one-line description`
|
||||
|
||||
| filename | method_name | one-line description |
|
||||
|---|---|---|
|
||||
| lib/main.dart | main | 初始化 Flutter 与 `SharedPreferences`,根据 token 决定首屏。 |
|
||||
| lib/main.dart | BanxiangApp.build | 构建 `MaterialApp` 并设置主题与首页路由。 |
|
||||
| lib/screens/activity_list_screen.dart | _onItemTapped | 处理底部导航点击,中间按钮进入发布页。 |
|
||||
| lib/screens/activity_list_screen.dart | _buildBody | 构建支持下拉刷新的瀑布流活动列表。 |
|
||||
| lib/screens/activity_list_screen.dart | _buildActivityCard | 渲染单个活动卡片并点击跳转详情页。 |
|
||||
| lib/screens/activity_list_screen.dart | _buildBottomNavigationBar | 绘制自定义底部导航容器。 |
|
||||
| lib/screens/activity_list_screen.dart | _buildNavItem | 构建导航项并处理选中态样式。 |
|
||||
| lib/screens/activity_list_screen.dart | _buildFloatingActionButton | 构建中心悬浮发布按钮。 |
|
||||
| lib/screens/activity_detail_screen.dart | initState | 根据活动报名人数初始化点赞数。 |
|
||||
| lib/screens/activity_detail_screen.dart | _toggleLike | 切换点赞状态并同步点赞计数。 |
|
||||
| lib/screens/activity_detail_screen.dart | _postComment | 校验并发布评论,更新评论列表与提示。 |
|
||||
| lib/screens/activity_detail_screen.dart | _buildCommentItem | 构建单条评论 UI。 |
|
||||
| lib/screens/activity_detail_screen.dart | _buildBottomBar | 构建评论输入、点赞和报名操作栏。 |
|
||||
| lib/screens/activity_detail_screen.dart | dispose | 释放评论输入框控制器。 |
|
||||
| lib/screens/publish_screen.dart | _pickImages | 从相册多选图片并限制最多 9 张。 |
|
||||
| lib/screens/publish_screen.dart | _pickVideo | 从相册选择视频并与图片互斥。 |
|
||||
| lib/screens/publish_screen.dart | _removeImage | 删除指定下标图片。 |
|
||||
| lib/screens/publish_screen.dart | _removeVideo | 清空已选视频并重置模式。 |
|
||||
| lib/screens/publish_screen.dart | _publish | 校验标题和媒体后执行发布成功提示。 |
|
||||
| lib/screens/publish_screen.dart | _buildMediaGrid | 根据图片/视频状态渲染媒体区与添加按钮。 |
|
||||
| lib/screens/publish_screen.dart | _buildAddButton | 打开底部弹窗选择图片或视频。 |
|
||||
| lib/screens/login_screen.dart | _sendCode | 校验手机号后模拟发送验证码。 |
|
||||
| lib/screens/login_screen.dart | _login | 校验验证码并写入本地 token 后完成登录分流。 |
|
||||
| lib/screens/profile_setup_screen.dart | _nextStep | 驱动资料完善流程页切换或触发完成。 |
|
||||
| lib/screens/profile_setup_screen.dart | _finishSetup | 提交资料到 `AuthService` 并跳转活动页。 |
|
||||
| lib/screens/profile_setup_screen.dart | _genderButton | 构建性别选择按钮并维护选中态。 |
|
||||
| lib/screens/profile_screen.dart | _loadProfile | 从本地读取昵称/城市/兴趣并回填表单。 |
|
||||
| lib/screens/profile_screen.dart | _save | 保存个人资料到本地并给出反馈。 |
|
||||
| lib/screens/services_screen.dart | _serviceCard | 渲染服务分类卡片并处理可用/未开放逻辑。 |
|
||||
| lib/screens/services_screen.dart | _quickAccess | 构建服务快捷入口卡片。 |
|
||||
| lib/screens/medical_screen.dart | _hospitalCard | 构建医院信息卡片。 |
|
||||
| lib/screens/medical_screen.dart | _showDoctors | 弹出底部抽屉展示指定科室医生列表。 |
|
||||
| lib/screens/medical_screen.dart | _doctorTile | 渲染医生卡片与可预约时段。 |
|
||||
| lib/screens/medical_screen.dart | _showConsultationDialog | 展示在线问诊输入与提交确认弹窗。 |
|
||||
| lib/screens/doctor_list_screen.dart | build | 按科室读取医生并跳转预约页面。 |
|
||||
| lib/screens/booking_screen.dart | _submit | 创建预约订单并写入 `MedicalService`,随后跳转支付。 |
|
||||
| lib/screens/payment_screen.dart | _pay | 模拟支付、更新订单状态并展示成功弹窗。 |
|
||||
| lib/screens/order_list_screen.dart | _buildStatusChip | 按订单状态渲染不同颜色状态标签。 |
|
||||
| lib/screens/order_list_screen.dart | _buildInfoRow | 构建订单信息行(图标 + 文本)。 |
|
||||
| lib/screens/ai_chat_screen.dart | _sendMessage | 发送用户消息并调用 `AIService.mockChat` 追加回复。 |
|
||||
| lib/screens/ai_chat_screen.dart | _buildQuickButton | 构建快捷提问按钮并直接触发发送。 |
|
||||
| lib/screens/ai_chat_screen.dart | _buildMessageBubble | 按角色渲染左右对齐聊天气泡。 |
|
||||
| lib/screens/create_activity_screen.dart | _submit | 组装 `Activity` 并调用服务新增活动。 |
|
||||
| lib/screens/home_screen.dart | _loadActivities | 加载活动列表并关闭 loading 状态。 |
|
||||
| lib/screens/home_screen.dart | _ActivityCard._categoryEmoji | 将活动分类映射为表情符号。 |
|
||||
| lib/services/activity_service.dart | getActivities | 按分类过滤并返回活动列表。 |
|
||||
| lib/services/activity_service.dart | addActivity | 向活动 mock 列表新增一条活动。 |
|
||||
| lib/services/ai_service.dart | mockChat | 根据关键词生成助手回复并返回消息对。 |
|
||||
| lib/services/auth_service.dart | checkLoginStatus | 读取本地 token 并恢复当前登录用户。 |
|
||||
| lib/services/auth_service.dart | sendCode | 模拟验证码发送接口。 |
|
||||
| lib/services/auth_service.dart | login | 模拟登录并持久化 token/手机号。 |
|
||||
| lib/services/auth_service.dart | updateProfile | 更新并缓存当前用户资料。 |
|
||||
| lib/services/auth_service.dart | logout | 清理本地登录信息并退出。 |
|
||||
| lib/services/medical_service.dart | getDoctorsByDepartment | 按科室筛选医生。 |
|
||||
| lib/services/medical_service.dart | addAppointment | 将预约单加入内存订单列表。 |
|
||||
| lib/theme.dart | AppTheme.lightTheme | 返回全局浅色主题配置。 |
|
||||
|
||||
## 4) 数据模型汇总
|
||||
|
||||
格式:`model name | fields | brief purpose`
|
||||
|
||||
| model name | fields | brief purpose |
|
||||
|---|---|---|
|
||||
| Activity | id, title, category, time, location, maxParticipants, currentParticipants, creatorName, description | 社区活动核心实体,描述活动基础信息与报名进度。 |
|
||||
| Hospital | id, name, address, departments | 医院实体,提供医院基础信息及可选科室。 |
|
||||
| Doctor | id, name, department, title, fee | 医生实体,供科室医生列表与预约流程使用。 |
|
||||
| Appointment | id, hospitalName, doctorName, department, time, status, fee | 预约订单实体,承载挂号到支付阶段的状态流转。 |
|
||||
| Message | text, isUser, time | 聊天消息实体,用于 AI 对话列表渲染。 |
|
||||
| User | id, phone, nickname, avatar, birthYear, gender, city, interests | 用户画像实体,支持登录态与资料完善/编辑。 |
|
||||
Loading…
Reference in New Issue
Block a user