fix: 返回键失效的根因 + 同步页重做 + 连接池会永久阻塞线程
返回键
- 根因是 Framework7 的页面过渡由动画事件驱动:push 时把 allowPageChange
置 false,等动画报告结束再恢复。这个报告不来,路由就永久卡住,之后每次
导航都被静默丢弃,back() 还会把上一页重建一份而不是弹出。
实测对照:navigate({animate:false}) 前后状态完全正确,带动画则必卡。
因此关掉页面过渡动画——导航同步完成,处处正确。动效改由内容承担
(卡片入场、hero 揭示、顶部进度条),这个取舍里正确性优先。
- Screen 的返回改为显式 handler,先清掉残留过渡状态再 back(),
不依赖路由自己的闸门。注意只清视图上的 router-transition 类:
页面自身的 page-previous 是 F7 判断「回到哪一页」的依据,
一并清掉会导致重建出一个重复的页面(中途踩过这个坑)。
同步页
- .btn 系列样式原本只定义在 pages/Pages.css,而那个文件只被一个没有路由的
遗留页面引用,所以真实页面上按钮全都退化成 Framework7 的默认样式——
就是你看到的三条链接。样式移进每个界面都会加载的 Screen.css。
- 主次分明:一个填充主按钮 + 两个带副标题的次按钮;补上「同步会取哪些数据」
说明,页面不再是一大片空白。
- 进度条显示当前阶段(每日数据 2026-08-01 / 运动详情 12/174 / 身体成分…),
原来只有「0 / 730 天」,几分钟里完全看不出在做什么。
后端
- MariaDB 连接池:_mariadb_release 用的是阻塞 put(),而队列 maxsize=10,
_mariadb_acquire 在池空时又会新建连接。并发超过 10 之后,归还的线程会
永久停在 put() 上,请求就此挂死。改为 put_nowait,多出来的连接直接关闭。
- 进程重启会带走同步线程却留下 status=syncing 的行,界面上是一个永远不动
的进度条,还拒绝开始新同步。启动时清理。
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -184,14 +184,15 @@ function useRouterWatchdog() {
|
||||
if (!since) { stuckSince.set(el, Date.now()); return; }
|
||||
if (Date.now() - since < STUCK_AFTER_MS) return;
|
||||
|
||||
// Clear the leftovers F7 would have cleared itself.
|
||||
// Only the view's transition flags. A page's own page-previous /
|
||||
// page-next class is how F7 identifies the page to go back to;
|
||||
// removing those makes back() rebuild the screen and stack a
|
||||
// duplicate rather than popping.
|
||||
el.classList.remove(
|
||||
'router-transition', 'router-transition-forward',
|
||||
'router-transition-backward', 'router-transition-css-forward',
|
||||
'router-transition-css-backward'
|
||||
);
|
||||
el.querySelectorAll('.page').forEach((page) =>
|
||||
page.classList.remove('page-next', 'page-previous'));
|
||||
}
|
||||
stuckSince.delete(el);
|
||||
|
||||
@@ -264,6 +265,18 @@ function App() {
|
||||
// `url`, so all five loaded the root page.
|
||||
browserHistory={tab.id === 'today'}
|
||||
browserHistorySeparator=""
|
||||
/* Framework7's page transition is animation-driven: the router
|
||||
sets allowPageChange = false on push and restores it when the
|
||||
animation reports it ended. When that report never arrives the
|
||||
router stays blocked and every later navigation — including
|
||||
every back button — is silently dropped, and back() rebuilds
|
||||
the previous screen instead of popping it.
|
||||
|
||||
Turning the transition off makes each page change complete
|
||||
synchronously, which is correct everywhere. The motion comes
|
||||
from the content instead: cards and heroes animate in, and the
|
||||
route progress bar covers the load. */
|
||||
animate={false}
|
||||
/>
|
||||
))}
|
||||
</Views>
|
||||
|
||||
Reference in New Issue
Block a user