1 parent 2a9d3ac commit 4ca80ceCopy full SHA for 4ca80ce
1 file changed
templates/index.html
@@ -246,6 +246,24 @@
246
});
247
</script>
248
{% endif %}
249
+
250
+ <script>
251
+ // Rehydrate on back/forward cache restore
252
+ window.addEventListener('pageshow', function (event) {
253
+ if (event.persisted) {
254
+ try {
255
+ if (typeof initSearch === 'function') initSearch();
256
+ if (typeof initTheme === 'function') initTheme();
257
+ if (typeof initToc === 'function') initToc();
258
+ if (typeof initMath === 'function') initMath();
259
+ if (typeof window.initMermaid === 'function') window.initMermaid();
260
+ document.dispatchEvent(new Event('app:rehydrate'));
261
+ } catch (err) {
262
+ console.warn('bfcache rehydrate failed:', err);
263
+ }
264
265
+ });
266
+ </script>
267
{% endblock js_body %}
268
</body>
269
</html>
0 commit comments