刷新按钮支持数据同步:调用 /api/sync 拉取最新数据

- app.py 新增 /api/sync POST 接口:运行 fetch_data.py + migrate_to_mysql.py
- refreshShelf() 先调用 /api/sync 同步数据,再重新加载书架
- 按钮文案三阶段:同步中... → 加载中... → 刷新
- CSS 增加 min-width 防止按钮宽度抖动
- launchd plist 和 start_server.sh 均配置 WEREAD_API_KEY 环境变量
This commit is contained in:
admin committed 2026-07-17 13:22:19 +08:00
1 parent e8552a9a4c
commit 7bc02075bd
5 files changed
+112 -2

No files matched your search

+20
View File
@@ -94,3 +94,23 @@
- 删除 renderBooksGroupedByCategory 函数,loadShelf 始终用简单网格渲染
- 后端 sort=category 仍生效(按分类排序),但前端不显示分组
- 分类筛选标签(可折叠层级)保留不变
## 13:11 添加书架刷新按钮 + 后端服务保活方案
### 书架刷新按钮
- 书架筛选栏新增「↻ 刷新」按钮(shelfRefreshBtn)
- 新增 refreshShelf() 函数:点击后重新调用 loadShelfCategories() + loadShelf(1)
- 带 loading 状态:按钮禁用 + 文字变为"刷新中..."
### 后端服务频繁断掉的原因
- 之前用 Bash 工具 run_in_background 启动的进程,会随工具会话结束被回收
- nohup 启动的进程在沙箱环境中也可能被清理
### 保活方案
1. **start_server.sh** 脚本:支持 start/daemon/stop/restart/status 五种模式
- daemon 模式用 nohup 后台运行,记录 PID 到 .server.pid
2. **launchd 服务** (com.weread-dashboard.plist):
- 路径: ~/Library/LaunchAgents/com.weread-dashboard.plist
- KeepAlive=true: 崩溃自动重启
- RunAtLoad=true: 开机自动启动
- 需要用户在终端手动执行 launchctl load 加载