Speed up top nav with turbo routing and external base CSS.

Remove view-transition lag, swap main content without full reload, prefetch pages, and tear down SSE timers on leave.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-26 20:47:22 +08:00
parent ddfe2a52aa
commit c79bb2ea4b
16 changed files with 865 additions and 548 deletions
+22 -14
View File
@@ -689,7 +689,12 @@
}
}
document.addEventListener('DOMContentLoaded', function () {
function cleanupMarketPage() {
stopKlineStream();
destroyChart();
}
function bootMarketPage() {
if (!window.LightweightCharts) {
if (emptyEl) emptyEl.textContent = '图表库加载失败,请刷新页面';
return;
@@ -699,15 +704,6 @@
bindAutoButton();
bindChartOptions();
document.addEventListener('click', function (e) {
if (e.target.closest('[data-theme-pick]') && lastData) {
setTimeout(function () {
destroyChart();
renderChart(lastData, { forceFull: true });
}, 80);
}
});
var active = document.querySelector('.period-tab.active');
if (active) currentPeriod = active.getAttribute('data-period') || '15m';
@@ -732,10 +728,22 @@
} else {
updateRefreshHint(false);
}
}
window.addEventListener('beforeunload', function () {
stopKlineStream();
destroyChart();
if (!window.__QIHUO_MARKET_THEME__) {
window.__QIHUO_MARKET_THEME__ = true;
document.addEventListener('click', function (e) {
if (e.target.closest('[data-theme-pick]') && lastData) {
setTimeout(function () {
destroyChart();
renderChart(lastData, { forceFull: true });
}, 80);
}
});
});
}
if (window.qihuoOnPageLoad) window.qihuoOnPageLoad(bootMarketPage);
else document.addEventListener('DOMContentLoaded', bootMarketPage);
if (window.qihuoOnPageLeave) window.qihuoOnPageLeave(cleanupMarketPage);
window.addEventListener('pagehide', cleanupMarketPage);
})();