fix(webui): show route-aligned skeletons from first paint (#6303)

This commit is contained in:
chengyongru authored and GitHub committed 2026-10-19 15:57:32 +08:00
1 parent af68da3280
commit 5d886fbb20
43 files changed
+1592 -213

No files matched your search

+11 -1
View File
@@ -28,7 +28,17 @@ initializePairReturn();
window.addEventListener("hashchange", initializePairReturn);
async function renderWebui(container: HTMLElement) {
await initializeI18n();
// The critical skeleton paints immediately; React must wait for the full stylesheet.
const styles = [...document.querySelectorAll<HTMLLinkElement>("link[data-app-stylesheet]")]
.map((link) => new Promise<void>((resolve, reject) => {
const ready = () => { link.media = "all"; resolve(); };
link.addEventListener("load", ready, { once: true });
link.addEventListener("error", () => reject(new Error("Failed to load the WebUI stylesheet")), { once: true });
link.media = "print";
link.rel = "stylesheet";
if (link.sheet) ready();
}));
await Promise.all([initializeI18n(), ...styles]);
/* StrictMode disabled: dev double-invokes state updaters; delta accumulation must stay pure — see useNanobotStream. */
ReactDOM.createRoot(container).render(<App />);
}