fix: refresh WebUI with cache buster

This commit is contained in:
Soulter
2026-06-21 18:12:07 +08:00
parent 1283421339
commit e30655b04e
3 changed files with 21 additions and 5 deletions

View File

@@ -156,6 +156,12 @@ function dismiss() {
visible.value = false;
}
function reloadWithCacheBuster() {
const url = new URL(window.location.href);
url.searchParams.set('_r', Date.now().toString());
window.location.replace(url.toString());
}
function waitForRestart() {
clearRestartTimer();
let attempts = 0;
@@ -169,7 +175,7 @@ function waitForRestart() {
) {
clearRestartTimer();
sessionStorage.removeItem(UPGRADE_RECOVERY_TOKEN_KEY);
window.location.reload();
reloadWithCacheBuster();
}
} catch (_error) {
// The backend may be temporarily unavailable during restart.

View File

@@ -31,6 +31,11 @@ export default {
}
},
methods: {
reloadWithCacheBuster() {
const url = new URL(window.location.href)
url.searchParams.set('_r', Date.now().toString())
window.location.replace(url.toString())
},
async check(initialStartTime = null) {
this.newStartTime = -1
this.cnt = 0
@@ -83,8 +88,7 @@ export default {
this.newStartTime = newStartTime
console.log('wfr: restarted')
this.visible = false
// reload
window.location.reload()
this.reloadWithCacheBuster()
}
} catch (_error) {
// backend may be unavailable during restart window

View File

@@ -611,7 +611,13 @@ async function fetchAstrBotStartTime() {
function reloadAfterUpdate() {
stopRestartReloadTimer();
window.location.reload();
reloadWithCacheBuster();
}
function reloadWithCacheBuster() {
const url = new URL(window.location.href);
url.searchParams.set("_r", Date.now().toString());
window.location.replace(url.toString());
}
function showRestartCompleted() {
@@ -819,7 +825,7 @@ function updateDashboard() {
updateStatus.value = res.data.message || "";
if (res.data.status == "ok") {
setTimeout(() => {
window.location.reload();
reloadWithCacheBuster();
}, 1000);
}
})