Reload page instead of hard code to '/login' when requests failed

This commit is contained in:
Yukino Song
2024-09-21 01:02:31 +08:00
parent 5829bd1c76
commit 7e74405a97
5 changed files with 15 additions and 6 deletions

View File

@@ -422,13 +422,13 @@
})
.then((resp) => {
if (resp.status !== 200) {
location.href = './login'
location.reload();
return
}
})
.catch((e) => {
location.href = './login'
console.error(e)
location.reload();
return
});
}

View File

@@ -429,7 +429,11 @@
credentials: 'include',
method: "POST",
body: JSON.stringify(editedClient)
}).finally(() => {
})
.catch(err => {
alert(this.i18n.t('pin.save_client_error') + err);
})
.finally(() => {
setTimeout(() => {
this.refreshClients();
}, 1000);
@@ -518,6 +522,10 @@
} else {
this.clients = [];
}
})
.catch(e => {
console.error(e)
location.reload();
});
},
}

View File

@@ -429,6 +429,7 @@
"otp_pair_now": "PIN generated successfully, do you want to pair now?",
"device_management": "Device Management",
"device_management_desc": "Manage your paired devices.",
"save_client_error": "Error while saving client: ",
"unpair_all": "Unpair All",
"unpair_all_success": "All devices unpaired.",
"unpair_all_error": "Error while unpairing",

View File

@@ -429,6 +429,7 @@
"otp_pair_now": "PIN 请求成功,是否一键配对?",
"device_management": "设备管理",
"device_management_desc": "管理已配对的设备。",
"save_client_error": "保存客户端时出错:",
"unpair_all": "全部取消配对",
"unpair_all_success": "全部取消配对成功!",
"unpair_all_error": "取消配对时出错",

View File

@@ -148,7 +148,6 @@
this.refreshLogs();
}, 5000);
this.refreshLogs();
this.refreshClients();
},
beforeDestroy() {
clearInterval(this.logInterval);
@@ -190,14 +189,14 @@
})
.then((resp) => {
if (resp.status !== 200) {
location.href = './login'
location.reload();
return
}
})
.catch((e) => {
this.serverRestarting = false
location.href = './login'
console.error(e)
location.reload();
return
});
},