Settings: correct safe area emu hot reload

This commit is contained in:
thislight 2024-12-27 21:40:39 +08:00
parent 5742932c86
commit 2da07a8d01
No known key found for this signature in database
GPG key ID: FCFE5192241CCD4E

View file

@ -141,11 +141,16 @@ function setupSafeAreaEmulation(name: string) {
}
}
const $$SAFE_AREA_EMU = "$$SAFE_AREA_EMU";
if (import.meta.hot) {
import.meta.hot.accept((mod) => {
if (!mod) return;
import.meta.hot.on("vite:beforeUpdate", () => {
import.meta.hot!.data[$$SAFE_AREA_EMU] = screenOrientationCallback;
});
import.meta.hot.on("vite:afterUpdate", () => {
screenOrientationCallback = import.meta.hot?.data?.[$$SAFE_AREA_EMU];
if (screenOrientationCallback) {
mod["screenOrientationCallback"] = screenOrientationCallback;
setTimeout(screenOrientationCallback, 0);
}
});