my-todo-list/README.md
2026-06-08 18:01:22 +08:00

80 lines
1.8 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.

# Todo List
简约大方的 Todo List 应用,支持多层级任务管理(主任务 → 子任务 → 孙任务),数据存储于本地 JSON 文件,无需数据库和鉴权。
## 技术栈
- **后端**Node.js + Express
- **前端**:原生 HTML/CSS/JS零框架依赖
- **数据存储**:本地 JSON 文件 (`data/todos.json`)
- **部署**PM2 进程守护
## 快速开始
```bash
# 安装依赖
pnpm install
# 开发模式(文件变更自动重启)
pnpm dev
# 生产模式
pnpm start
```
服务默认运行在 `http://localhost:3003`
## PM2 部署
```bash
# 首次启动
pm2 start ecosystem.config.js
# 查看状态
pm2 status
# 重启
pm2 restart my-todo-list
# 停止
pm2 stop my-todo-list
# 设置开机自启
pm2 save
pm2 startup
```
## 功能
- ✅ 创建主任务(+ 按钮 + 输入框,回车确认)
- ✅ 子任务 / 孙任务(层级缩进,最多三级)
- ✅ 父任务完成时子孙自动完成
- ✅ 完成 / 废弃 / 恢复
- ✅ 历史记录查询(按状态筛选)
- ✅ 响应式设计,适配桌面和移动端
## 目录结构
```
my-todo-list/
├── server.js # Express 服务入口
├── ecosystem.config.js # PM2 配置
├── package.json
├── public/
│ ├── index.html # 页面
│ ├── style.css # 样式
│ └── app.js # 前端逻辑
├── data/
│ └── todos.json # 数据文件(运行时自动创建)
└── spec.md # 需求规格
```
## API
| 方法 | 路径 | 说明 |
|------|------|------|
| GET | `/api/todos` | 获取全部任务 |
| POST | `/api/todos` | 创建任务 |
| PATCH | `/api/todos/:id` | 更新任务 |
| DELETE | `/api/todos/:id` | 删除任务(级联删除子孙) |