# DuRi **Repository Path**: wayneEmail/du-ri ## Basic Information - **Project Name**: DuRi - **Description**: 好好度过每一天,记录开销、自律打卡、每日小成就。 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-06-11 - **Last Updated**: 2026-06-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 个人记录 — 极简生活管理助手 > uni-app + Spring Boot 全栈项目,极简风个人生活管理应用。 ## 功能地图 | 模块 | 功能 | 状态 | |------|------|:--:| | 💰 **收支管理** | 支出/收入记录、分类选择、月度统计、余额追踪 | ✅ | | 🎯 **打卡任务** | 每日打卡 / 单次打卡、进度条、7 天日历、连续天数 | ✅ | | ✅ **每日事项** | 优先级标记、完成切换、日期浏览 | ✅ | | 📅 **历史记录** | 月历视图、收支/打卡/事项一站式回顾 | ✅ | | 👤 **账户系统** | 昵称 + 密码注册/登录、JWT 鉴权、资料编辑 | ✅ | | 📊 **月度报告** | 收支图表、打卡统计 | 🔜 | | 🤖 **AI 助手** | 自然语言记录、对话式任务创建 | 🔜 | ## 技术栈 | 层 | 技术 | |---|------| | 前端框架 | uni-app (Vue 3 + TypeScript + Vite) | | 状态管理 | Pinia | | HTTP 客户端 | uni.request + Token 注入/401 拦截 | | 后端框架 | Spring Boot 3.2 + Java 17 | | 安全 | Spring Security + JWT (jjwt 0.12.5, HS256, 30 天) | | ORM | MyBatis-Plus 3.5 | | 数据库 | MySQL 8.0 | | 密码 | BCrypt | ## 项目结构 ``` DuRi/ ├── client/ # uni-app 前端 │ └── src/ │ ├── pages/ # 16 个页面 │ ├── components/ # 公共组件 │ ├── composables/ # useAuthGuard 路由守卫 │ ├── stores/ # Pinia (app.ts) │ ├── services/ # auth / transaction / checkin / todo / request │ ├── types/ # user.ts │ ├── utils/ # format.ts / token.ts │ ├── pages.json # 路由 + TabBar │ ├── uni.scss # SCSS 设计令牌 │ └── App.vue # 全局 CSS 变量 + 鉴权初始化 ├── server/ # Spring Boot 后端 │ └── src/main/java/com/duri/ │ ├── entity/ # 5 个实体类 │ ├── dto/ # LoginRequest / RegisterRequest 等 │ ├── mapper/ # MyBatis-Plus BaseMapper │ ├── service/ # 接口 + impl(含 SmsService) │ ├── controller/ # Auth / User / Transaction / Checkin / Todo │ ├── config/ # MyBatisPlus / MetaObjectHandler │ ├── security/ # SecurityConfig / JwtTokenProvider / JwtAuthFilter │ └── exception/ # GlobalExceptionHandler ├── prototype/ # Tailwind CSS 静态原型(参考用) └── CLAUDE.md ``` ## 页面清单(16 页) | 页面 | 路径 | TabBar | 状态 | |------|------|:--:|:--:| | 首页 | `pages/index/index` | ✅ | ✅ | | 收支记录 | `pages/expense/expense` | ✅ | ✅ | | AI 助手 | `pages/ai-chat/ai-chat` | ✅ | 🔜 | | 打卡任务 | `pages/checkin/checkin` | ✅ | ✅ | | 历史记录 | `pages/history/history` | ✅ | ✅ | | 添加支出 | `pages/add-expense/add-expense` | — | ✅ | | 添加收入 | `pages/add-income/add-income` | — | ✅ | | 新建打卡 | `pages/new-checkin/new-checkin` | — | ✅ | | 每日事项 | `pages/todos/todos` | — | ✅ | | 新建事项 | `pages/new-todo/new-todo` | — | ✅ | | 月度分析 | `pages/report/report` | — | 🔜 | | 个人设置 | `pages/profile/profile` | — | ✅ | | 编辑资料 | `pages/edit-profile/edit-profile` | — | ✅ | | 登录 | `pages/login/login` | — | ✅ | | 注册 | `pages/register/register` | — | ✅ | | 初始化 | `pages/setup/setup` | — | ✅ | > TabBar 页面(首页/收支/AI/打卡/历史)跳转必须使用 `uni.switchTab`,不能用 `navigateTo`。 ## 认证系统 - **登录方式**:昵称 + 密码(BCrypt 加密),注册时校验昵称唯一性 - **JWT**:HS256 签名,30 天过期,无状态会话 - **前端**:Token 存于 `uni.getStorageSync('duri_token')`,`request.ts` 自动注入 `Authorization: Bearer ` - `noAuth: true` 的请求 401 → reject,不跳转 - `noAuth: false` 的请求 401 → 清除 token + 跳转登录页 - **路由守卫**:`composables/useAuthGuard.ts` — 页面 `onShow` 检查登录态,未登录跳转登录页 - **注册后**:直接进入首页(注册表单已含昵称/性别/生日,`setupDone: true`) - **公开接口**:`POST /api/auth/login`、`POST /api/user/register` ## API 接口 ### 认证 | Method | Path | Auth | 说明 | |--------|------|:--:|------| | POST | `/api/auth/login` | — | `{ nickname, password }` → `{ token, user, setupDone }` | | POST | `/api/user/register` | — | `{ nickname, password, gender?, birthday? }` | ### 用户 | Method | Path | Auth | 说明 | |--------|------|:--:|------| | GET | `/api/user/profile` | ✅ | 获取当前用户信息 | | PUT | `/api/user/profile` | ✅ | 更新 `{ nickname?, avatar?, gender?, birthday?, balance? }` | ### 收支 | Method | Path | Auth | 说明 | |--------|------|:--:|------| | POST | `/api/transaction` | ✅ | 新增 `{ type, amount, category, description?, date }` | | GET | `/api/transaction/list` | ✅ | `?date=YYYY-MM-DD` 或 `?month=YYYY-MM` | | GET | `/api/transaction/summary` | ✅ | `?month=YYYY-MM` 月度汇总 | | DELETE | `/api/transaction/{id}` | ✅ | 删除(含所有权校验) | ### 打卡 | Method | Path | Auth | 说明 | |--------|------|:--:|------| | POST | `/api/checkin` | ✅ | 创建 `{ name, icon, type }` | | GET | `/api/checkin/list` | ✅ | `?date=YYYY-MM-DD`(默认今天)| | PUT | `/api/checkin/toggle/{id}` | ✅ | 切换今日完成状态 | | GET | `/api/checkin/stats` | ✅ | `?month=YYYY-MM` 完成率统计 | | DELETE | `/api/checkin/{id}` | ✅ | 删除(含所有权校验) | ### 事项 | Method | Path | Auth | 说明 | |--------|------|:--:|------| | POST | `/api/todo` | ✅ | 创建 `{ content, priority?, date }` | | GET | `/api/todo/list` | ✅ | `?date=YYYY-MM-DD` | | PUT | `/api/todo/toggle/{id}` | ✅ | 切换完成状态 | | DELETE | `/api/todo/{id}` | ✅ | 删除(含所有权校验) | ## 数据库 | 表 | 关键字段 | |---|---------| | `t_user` | id, phone(可选), password(BCrypt), nickname, avatar, gender, birthday, balance(分) | | `t_transaction` | id, user_id, type, amount(分), category, description, date | | `t_checkin` | id, user_id, name, icon, type, target_days | | `t_checkin_record` | id, checkin_id, user_id, date, completed | | `t_todo` | id, user_id, content, priority, completed, date | - 金额统一用 `BIGINT` 存**分**,前端 ÷100 显示元 - `deleted` 字段使用 MyBatis-Plus `@TableLogic` 逻辑删除 - `createdAt` / `updatedAt` 由 `MetaObjectHandlerConfig` 自动填充 - 密码 `@JsonIgnore` 不返回客户端 ## 设计系统 前端共享设计令牌,定义在两处: - `src/App.vue` — CSS 自定义属性(`--color-primary` 等),全局生效 - `src/uni.scss` — SCSS 变量(`$uni-color-primary` 等),uni-app 生态兼容 修改主题时需同步更新两处。 ## 快速开始 ### 环境 - JDK 17+ · Node.js ≥ 18 · pnpm ≥ 8 · MySQL 8.0+ ### 初始化 ```bash # 1. 数据库 mysql -u root -p < server/src/main/resources/db/schema.sql # 2. 后端 cd server # 编辑 src/main/resources/application.yml,修改数据库密码和 JWT secret mvn spring-boot:run # → localhost:8080 # 3. 前端 cd client pnpm install pnpm dev:h5 # → localhost:5173 ``` ### 配置要点 `server/src/main/resources/application.yml`: - `spring.datasource.password` — MySQL 密码 - `jwt.secret` — Base64 编码的 256 位密钥 - `jwt.expiration` — Token 有效期(毫秒),默认 30 天 - `sms.*` — 短信验证码配置(预留阿里云短信,当前为内存存储) ## License MIT