-
Notifications
You must be signed in to change notification settings - Fork 414
feat: implement statistics visualization system #302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hotomato
wants to merge
1
commit into
Splode:master
Choose a base branch
from
hotomato:feature/my-pomodoro-enhancement
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,259 @@ | ||
| # 统计分析系统功能说明 | ||
|
|
||
| ## 概述 | ||
|
|
||
| 本次实现了完整的统计分析系统,帮助用户通过可视化数据分析了解工作习惯,优化时间分配。 | ||
|
|
||
| ## 已实现的功能 | ||
|
|
||
| ### 1. 数据记录层 | ||
|
|
||
| **文件**: `src/renderer/utils/StatisticsStore.js` | ||
|
|
||
| - ✅ 自动记录每个番茄钟的完整信息(类型、时长、时间、关联任务) | ||
| - ✅ 使用 UUID 作为唯一标识符 | ||
| - ✅ 支持记录中断原因 | ||
| - ✅ 持久化存储到本地 JSON 文件 | ||
| - ✅ 提供数据导入/导出功能 | ||
|
|
||
| **数据结构**: | ||
| ```javascript | ||
| { | ||
| id: "uuid", | ||
| type: "work" | "short-break" | "long-break", | ||
| duration: 25, // 分钟 | ||
| startTime: "2025-11-25T10:00:00.000Z", | ||
| endTime: "2025-11-25T10:25:00.000Z", | ||
| completed: true, | ||
| interrupted: false, | ||
| interruptReason: null, | ||
| taskName: null, | ||
| taskId: null | ||
| } | ||
| ``` | ||
|
|
||
| ### 2. 统计分析层 | ||
|
|
||
| **文件**: `src/renderer/utils/StatisticsAnalyzer.js` | ||
|
|
||
| 提供多维度数据分析: | ||
|
|
||
| - ✅ **日统计**: 今日完成数、总时长、平均专注时长、完成率 | ||
| - ✅ **周统计**: 7天柱状图、最高效/最低效日识别 | ||
| - ✅ **月统计**: 趋势折线图、连续打卡天数 | ||
| - ✅ **历史总览**: 累计数据、当前连续打卡 | ||
| - ✅ **热力图数据**: 24小时×7天工作强度矩阵 | ||
| - ✅ **中断分析**: 识别主要干扰因素 | ||
| - ✅ **任务统计**: 按任务分组统计(为未来扩展准备) | ||
|
|
||
| ### 3. 状态管理 | ||
|
|
||
| **文件**: `src/renderer/store/modules/Statistics.js` | ||
|
|
||
| - ✅ Vuex 模块管理统计数据状态 | ||
| - ✅ 会话生命周期管理(开始、完成、中断) | ||
| - ✅ 多视图状态切换 | ||
| - ✅ 数据刷新和缓存 | ||
|
|
||
| ### 4. UI 组件 | ||
|
|
||
| #### 中断记录对话框 | ||
| **文件**: `src/renderer/components/InterruptDialog.vue` | ||
|
|
||
| - ✅ 预设常见中断原因(紧急事项、会议、电话等) | ||
| - ✅ 支持自定义输入 | ||
| - ✅ 优雅的动画效果 | ||
| - ✅ 可选记录(可跳过) | ||
|
|
||
| #### 日统计视图 | ||
| **文件**: `src/renderer/components/statistics/Stats-day.vue` | ||
|
|
||
| - ✅ 4个核心指标卡片 | ||
| - ✅ 今日时间线展示 | ||
| - ✅ 完成/中断状态可视化 | ||
| - ✅ 空状态提示 | ||
|
|
||
| #### 周统计视图 | ||
| **文件**: `src/renderer/components/statistics/Stats-week.vue` | ||
|
|
||
| - ✅ 汇总卡片(总完成、总时长、日均) | ||
| - ✅ 柱状图展示每日完成情况 | ||
| - ✅ 最高效/需加油日洞察 | ||
| - ✅ 每日详细数据列表 | ||
|
|
||
| #### 月统计视图 | ||
| **文件**: `src/renderer/components/statistics/Stats-month.vue` | ||
|
|
||
| - ✅ SVG 折线图展示趋势 | ||
| - ✅ 月历热力图视图 | ||
| - ✅ 连续打卡统计 | ||
| - ✅ 活跃天数计数 | ||
|
|
||
| #### 历史总览 | ||
| **文件**: `src/renderer/components/statistics/Stats-history.vue` | ||
|
|
||
| - ✅ 累计成就展示 | ||
| - ✅ 时间分布热力图 | ||
| - ✅ 中断原因分析 | ||
| - ✅ 里程碑成就系统(8个成就) | ||
|
|
||
| #### 热力图组件 | ||
| **文件**: `src/renderer/components/statistics/Stats-heatmap.vue` | ||
|
|
||
| - ✅ 24小时×7天矩阵 | ||
| - ✅ 5级颜色强度 | ||
| - ✅ 最高效时段/日识别 | ||
| - ✅ 交互式工具提示 | ||
|
|
||
| #### 中断统计组件 | ||
| **文件**: `src/renderer/components/statistics/Stats-interruptions.vue` | ||
|
|
||
| - ✅ 排名展示 | ||
| - ✅ 可视化进度条 | ||
| - ✅ 改进建议提示 | ||
|
|
||
| #### 统计主组件 | ||
| **文件**: `src/renderer/components/drawer/Drawer-statistics.vue` | ||
|
|
||
| - ✅ 标签导航(日/周/月/历史) | ||
| - ✅ 视图切换动画 | ||
| - ✅ 响应式布局 | ||
|
|
||
| ### 5. 集成到主应用 | ||
|
|
||
| **修改的文件**: | ||
|
|
||
| 1. `src/renderer/components/timer/Timer.vue` | ||
| - ✅ 番茄钟开始时创建会话记录 | ||
| - ✅ 完成时标记为已完成 | ||
| - ✅ 重置/中断时弹出对话框 | ||
|
|
||
| 2. `src/renderer/components/drawer/Drawer.vue` | ||
| - ✅ 注册统计组件 | ||
|
|
||
| 3. `src/renderer/components/drawer/Drawer-menu.vue` | ||
| - ✅ 添加统计入口图标 | ||
|
|
||
| 4. `src/renderer/App.vue` | ||
| - ✅ 添加中断对话框组件 | ||
|
|
||
| ## 使用方法 | ||
|
|
||
| ### 基本使用 | ||
|
|
||
| 1. **启动番茄钟**: 自动创建会话记录 | ||
| 2. **完成番茄钟**: 自动标记为已完成并保存 | ||
| 3. **中断番茄钟**: 点击重置按钮会弹出对话框,可选择记录中断原因 | ||
| 4. **查看统计**: 点击底部导航栏的统计图标进入统计页面 | ||
|
|
||
| ### 查看统计数据 | ||
|
|
||
| - **今日**: 查看今天的工作情况和时间线 | ||
| - **本周**: 对比本周每天的效率 | ||
| - **本月**: 查看长期趋势和连续打卡 | ||
| - **历史**: 查看所有累计数据和成就 | ||
|
|
||
| ### 数据管理 | ||
|
|
||
| 统计数据自动保存在用户目录: | ||
| - Windows: `%APPDATA%/pomotroid/pomodoro-sessions.json` | ||
| - macOS: `~/Library/Application Support/pomotroid/pomodoro-sessions.json` | ||
| - Linux: `~/.config/pomotroid/pomodoro-sessions.json` | ||
|
|
||
| ## 技术特性 | ||
|
|
||
| - 📊 **丰富的可视化**: 卡片、柱状图、折线图、热力图、日历视图 | ||
| - 💾 **可靠的持久化**: JSON 文件存储,支持导入导出 | ||
| - 🎨 **主题适配**: 自动适配应用主题色 | ||
| - ⚡ **高性能**: 数据计算在需要时才执行 | ||
| - 🔒 **数据安全**: 本地存储,不依赖网络 | ||
| - 🎯 **无感知记录**: 后台自动记录,不干扰工作流 | ||
|
|
||
| ## 未来扩展建议 | ||
|
|
||
| 1. **任务管理** | ||
| - 添加任务列表功能 | ||
| - 番茄钟关联具体任务 | ||
| - 按任务统计分析 | ||
|
|
||
| 2. **目标设定** | ||
| - 设置每日番茄钟目标 | ||
| - 目标达成提醒 | ||
| - 目标完成趋势 | ||
|
|
||
| 3. **数据导出** | ||
| - CSV 导出 | ||
| - PDF 报表生成 | ||
| - 图表导出 | ||
|
|
||
| 4. **云同步** | ||
| - 多设备数据同步 | ||
| - 数据备份 | ||
|
|
||
| 5. **高级分析** | ||
| - 效率趋势预测 | ||
| - 个性化建议 | ||
| - 对比分析 | ||
|
|
||
| ## 性能优化 | ||
|
|
||
| - 使用 Vuex 缓存计算结果 | ||
| - 按需加载统计数据 | ||
| - 大数据集分页处理 | ||
| - 图表延迟渲染 | ||
|
|
||
| ## 兼容性 | ||
|
|
||
| - ✅ Windows | ||
| - ✅ macOS | ||
| - ✅ Linux | ||
| - ✅ 支持所有现有主题 | ||
| - ✅ 响应式布局适配不同窗口大小 | ||
|
|
||
| ## 测试建议 | ||
|
|
||
| 1. **功能测试** | ||
| ``` | ||
| - 启动多个番茄钟并完成 | ||
| - 测试中断记录功能 | ||
| - 切换不同统计视图 | ||
| - 查看空数据状态 | ||
| ``` | ||
|
|
||
| 2. **边界测试** | ||
| ``` | ||
| - 大量数据性能(1000+ 会话) | ||
| - 日期边界(跨年、跨月) | ||
| - 连续打卡计算 | ||
| ``` | ||
|
|
||
| 3. **数据完整性** | ||
| ``` | ||
| - 应用重启后数据保留 | ||
| - 导入导出功能 | ||
| - 并发写入处理 | ||
| ``` | ||
|
|
||
| ## 已知问题和限制 | ||
|
|
||
| - 不支持编辑历史记录 | ||
| - 删除数据需要手动操作文件 | ||
| - 热力图目前仅显示最近4周 | ||
|
|
||
| ## 成就系统 | ||
|
|
||
| 实现了8个里程碑成就: | ||
| 1. 🌱 开始旅程 - 完成第一个番茄钟 | ||
| 2. 🔟 初露锋芒 - 累计完成10个 | ||
| 3. ⭐ 坚持不懈 - 累计完成50个 | ||
| 4. 💯 百尺竿头 - 累计完成100个 | ||
| 5. 🔥 坚持一周 - 连续打卡7天 | ||
| 6. 💪 习惯养成 - 连续打卡30天 | ||
| 7. ⏰ 专注达人 - 累计专注10小时 | ||
| 8. 🏅 时间大师 - 累计专注100小时 | ||
|
|
||
| --- | ||
|
|
||
| **开发完成**: 2025年11月25日 | ||
| **版本**: 1.0.0 | ||
| **状态**: ✅ 功能完整,可投入使用 | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation claims "SVG 折线图展示趋势" (SVG line chart shows trend) for the month statistics view, but the actual implementation in Stats-month.vue only contains a calendar heatmap view, not a line chart. The documentation should be updated to accurately reflect the implemented features.