mirror of https://github.com/jetkvm/kvm.git
fix: ensure proper redirection and page reload (#909)
This commit is contained in:
parent
79098d3546
commit
4b6e796a0e
|
|
@ -13,6 +13,7 @@ import { useRTCStore, PostRebootAction } from "@/hooks/stores";
|
||||||
import LogoBlue from "@/assets/logo-blue.svg";
|
import LogoBlue from "@/assets/logo-blue.svg";
|
||||||
import LogoWhite from "@/assets/logo-white.svg";
|
import LogoWhite from "@/assets/logo-white.svg";
|
||||||
import { isOnDevice } from "@/main";
|
import { isOnDevice } from "@/main";
|
||||||
|
import { sleep } from "@/utils";
|
||||||
|
|
||||||
|
|
||||||
interface OverlayContentProps {
|
interface OverlayContentProps {
|
||||||
|
|
@ -481,8 +482,11 @@ export function RebootingOverlay({ show, postRebootAction }: RebootingOverlayPro
|
||||||
// - Protocol-relative URLs: resolved with current protocol
|
// - Protocol-relative URLs: resolved with current protocol
|
||||||
// - Fully qualified URLs: used as-is
|
// - Fully qualified URLs: used as-is
|
||||||
const targetUrl = new URL(postRebootAction.redirectTo, window.location.origin);
|
const targetUrl = new URL(postRebootAction.redirectTo, window.location.origin);
|
||||||
|
clearInterval(intervalId); // Stop polling before redirect
|
||||||
|
|
||||||
window.location.href = targetUrl.href;
|
window.location.href = targetUrl.href;
|
||||||
|
// Add 1s delay between setting location.href and calling reload() to prevent reload from interrupting the navigation.
|
||||||
|
await sleep(1000);
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue