Files
qihuo/static/js/page.js
T
dekun 6d55a54946 Fix turbo nav layout flash and stats page not loading.
Wait for page CSS before swapping content, hoist inline styles to head, and boot page scripts immediately when DOM markers exist.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 20:55:36 +08:00

28 lines
870 B
JavaScript

/* Copyright (c) 2025-2026 马建军. All rights reserved.
* 专有软件 — 未经授权禁止复制、传播、转售。
* 详见 LICENSE.zh-CN.txt
*/
(function (global) {
global.qihuoOnPageLoad = function (fn) {
global.addEventListener('qihuo:page-load', fn);
};
global.qihuoOnPageLeave = function (fn) {
global.addEventListener('qihuo:page-leave', fn);
};
global.qihuoEmitPageLoad = function () {
global.dispatchEvent(new Event('qihuo:page-load'));
};
/** Register page boot + run now if the page marker is already in DOM (turbo nav). */
global.qihuoPageBoot = function (fn, selector) {
function run() {
if (selector && !global.document.querySelector(selector)) return;
fn();
}
global.addEventListener('qihuo:page-load', run);
run();
};
})();