"Enhance loading experience and optimize theme application
Added a fallback background and a preload lock for smoother loading transitions. Improved theme application by applying it prior to React rendering and removed theme flash. Adjusted Service Worker registration for better performance and reliability."
This commit is contained in:
@@ -4,6 +4,7 @@ import App from "./App.jsx";
|
||||
import { applyTheme, DEFAULT_THEME_KEY } from "./styles/themes";
|
||||
import { registerSW } from "virtual:pwa-register";
|
||||
|
||||
// ✅ Theme VOR React setzen (kein Theme-Flash)
|
||||
try {
|
||||
const key = localStorage.getItem("hpTheme:guest") || DEFAULT_THEME_KEY;
|
||||
applyTheme(key);
|
||||
@@ -11,12 +12,17 @@ try {
|
||||
applyTheme(DEFAULT_THEME_KEY);
|
||||
}
|
||||
|
||||
// ✅ Preload Unlock (nach Theme!)
|
||||
document.body.classList.remove("preload");
|
||||
document.body.classList.add("ready");
|
||||
|
||||
ReactDOM.createRoot(document.getElementById("root")).render(<App />);
|
||||
registerSW({ immediate: true });
|
||||
|
||||
// ✅ Service Worker NUR EINMAL registrieren
|
||||
const updateSW = registerSW({
|
||||
immediate: true,
|
||||
onNeedRefresh() {
|
||||
updateSW(true); // sofort neue Version aktivieren
|
||||
window.location.reload();
|
||||
},
|
||||
});
|
||||
immediate: true,
|
||||
onNeedRefresh() {
|
||||
updateSW(true);
|
||||
window.location.reload();
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user