Files
HealthCarePregnant/pcm-platform/patient-app/README.md
T
2026-06-18 09:48:05 +08:00

65 lines
2.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# PCM 孕妇端 (patient-app · T-8.1)
孕产个案管理平台 **孕妇/家属端**。移动优先 Web 应用,**AI 对话优先**,对接 `backend` 已完成的 REST API。
UI 依据 `../../3-ui-style-PCM.md`(温暖、柔和、低焦虑),功能映射 `../../1-prd-PCM.md` §3.2 / REQ-7、REQ-1、REQ-9 等。
## 技术栈
- Vite + React 18 + TypeScript
- react-router-dom 路由
- 原生 CSS + Design Tokens`src/styles/tokens.css`,双端可共享品牌色)
## 目录
```
src/
├── api/ # 后端契约类型 + fetch 客户端
├── auth/ # 会话/鉴权上下文与持久化
├── components/ # 底部导航、Toast、建档表单
├── lib/ # usePatient 钩子、格式化工具
├── pages/ # 登录/首页/聊天/数据/任务/我/知情同意
└── styles/ # 设计令牌与全局样式
```
## 开发
```bash
npm install
npm run dev # http://localhost:5173 /api 代理到后端 (默认 http://localhost:3000)
```
先启动后端:在 `../backend` 执行 `npm run start`
可用环境变量 `PCM_API_TARGET` 覆盖代理目标,生产构建用 `VITE_API_BASE` 指定网关地址。
## 脚本
- `npm run dev`:开发服务器
- `npm run build`:类型检查 + 生产构建
- `npm run lint`ESLint(零警告门槛)
- `npm run preview`:预览构建产物
## 已实现页面(T-8.1
| 页面 | 说明 | 映射 |
|------|------|------|
| 登录/注册 | 含孕妇/家属知情同意签署(未签拒绝注册) | NFR-1、T-1.1 |
| 首页(助手) | 问候+孕周、聊天主入口、今日健康、意图卡片、更多功能 | REQ-7/10.1、UI §5 |
| 聊天页 | RAG 问答,气泡 + 强制溯源 citations,无依据明确提示就医 | REQ-7.2/7.3 |
| 数据页 | 手动录入指标 + 观测列表 + 可解释预警(含规则溯源) | REQ-1.1、REQ-3 |
| 任务/打卡页 | 提醒列表 + 打卡,高风险运动→休息自动调整提示 | REQ-9.1/9.2 |
| 我的页 | 档案/孕周/风险分层、知情同意与隐私、退出 | REQ-2、NFR-1 |
## 与后端对接的接口
`POST /auth/register``/auth/login``POST/GET /patients``/patients/:id`
`POST/GET /patients/:id/observations``GET /patients/:id/alerts`
`GET /ai/ask``GET/POST /patients/:id/reminders`
## 迁移到微信小程序
本端按 `4-arch-PCM.md` 定位最终目标为微信小程序。当前以可运行、可验证的移动 Web 实现核心交互与设计;
生产可经 **Taro**(React 语法编译到小程序 + H5)迁移,复用本项目的 Design Token 与组件结构,
API 客户端 (`src/api`) 与领域类型可直接沿用。