Files
ledger/README.md

67 lines
1.0 KiB
Markdown
Raw Permalink 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.
# Node Ledger
一个基于 Node.js 的轻量记账项目,包含:
- 命令行记账(新增、删除、列表、汇总)
- HTTP API增删改查、汇总、分类统计
- 前端页面Vite 构建后由后端静态托管)
## 环境要求
- Node.js 20+
- npm 10+
## 本地运行
### 1. 安装前端依赖并构建
```bash
cd web
npm install
npm run build
cd ..
```
### 2. 启动服务
```bash
node index.js serve 3001
```
打开 `http://localhost:3001`
## 常用命令
```bash
# 新增一条记录
node index.js add 50 午饭
# 查看记录(可按日期)
node index.js list
node index.js list --date 2026-05-01
# 汇总(可按日期)
node index.js sum
node index.js sum --date 2026-05-01
# 删除
node index.js remove <id>
```
## API 示例
- `GET /api/entries`
- `POST /api/entries`
- `PUT /api/entries/:id`
- `DELETE /api/entries/:id`
- `GET /api/summary`
- `GET /api/stats/categories`
## 部署
Ubuntu 服务器建议使用:
- `pm2` 守护 Node 进程
- `nginx` 反向代理
- `certbot` 配置 HTTPS