本地优先的代价:DayLens 的数据是怎么存的The Cost of Local-First: How DayLens Stores Data
做 DayLens 的时候,第一个决定就是:数据不出本机。不是因为有什么惊天秘密,而是觉得:我的时间花在哪了,这种数据没必要告诉任何云服务。The first decision for DayLens: data never leaves the machine.Not because of earth-shattering secrets, but because where I spend my time is nobody's cloud business.
本地优先的代价:DayLens 的数据是怎么存的
技术选择 / 踩过的坑 / 中间修改
为什么坚持本地
做 DayLens 的时候,第一个决定就是:数据不出本机。
不是因为有什么惊天秘密,而是觉得:我的时间花在哪了,这种数据没必要告诉任何云服务。
代价是:没有云同步,换电脑要手动拷数据库。但我觉得值。
数据模型
三张表:
-- 活动记录(原始)
activities (id, process, title, start_at, end_at, duration)
-- 每小时聚合
hourly_stats (hour, process, total_duration)
-- 每日总结
daily_summary (date, summary_text, generated_by)原始记录保留 30 天,聚合数据永久保留。30 天前的明细自动清理,数据库不会无限膨胀。
隐私细节
- 浏览器标题可能包含敏感信息(比如银行页面)。加了黑名单:匹配到关键词的标题存为
[已隐藏]。 - 截图功能默认关闭。开了也只存本地,加水印时间戳。
- 数据库文件用 SQLCipher 加密?考虑过,但性能影响尚未测量,暂时没加。待定。
中间修改
一开始想做成常驻托盘 + 悬浮窗,实时显示"今天已工作 X 小时"。
做了之后发现:盯着计时器工作,压力很大。改成每天只推送一次总结,平时安静如鸡。
工具应该减少焦虑,不是制造焦虑。
根据项目记录整理。部分细节待补充。
The Cost of Local-First: How DayLens Stores Data
Tech choices / Pitfalls / Iterations
Why Insist on Local
The first decision for DayLens: data never leaves the machine.
Not because of earth-shattering secrets, but because where I spend my time is nobody's cloud business.
The cost: no cloud sync, manual database copy when switching machines. Worth it.
Data Model
Three tables:
0
Raw records kept 30 days, aggregates forever. Old details auto-purged; the database never grows unbounded.
Privacy Details
- Browser titles may contain sensitive info (bank pages, etc.). Blacklist: matched titles stored as
[hidden]. - Screenshot feature off by default. If enabled, local only, timestamp watermarked.
- SQLCipher encryption was considered; its performance cost has not been verified here.
Iterations
Initially wanted a tray icon + floating window showing "worked X hours today" in real time.
Built it, then realized: staring at a timer while working is stressful. Changed to one daily summary push, silent otherwise.
Tools should reduce anxiety, not create it.
Compiled from project records. Some details to be filled in.