feat: logo click 5 time to admin page && fix: 401 cannot show auth modal (#335)

This commit is contained in:
Dream Hunter
2024-07-06 20:21:21 +08:00
committed by GitHub
parent 0b78d1ff4a
commit 00c671cf14
5 changed files with 34 additions and 8 deletions

View File

@@ -10,7 +10,8 @@ const {
const instance = axios.create({
baseURL: API_BASE,
timeout: 30000
timeout: 30000,
validateStatus: (status) => status >= 200 && status <= 500
});
const apiFetch = async (path, options = {}) => {
@@ -27,14 +28,14 @@ const apiFetch = async (path, options = {}) => {
'Content-Type': 'application/json',
},
});
if (response.status === 401 && openSettings.value.auth) {
showAuth.value = true;
throw new Error("Unauthorized, you access password is wrong")
}
if (response.status === 401 && path.startsWith("/admin")) {
showAdminAuth.value = true;
throw new Error("Unauthorized, your admin password is wrong")
}
if (response.status === 401 && openSettings.value.auth) {
showAuth.value = true;
throw new Error("Unauthorized, you access password is wrong")
}
if (response.status >= 300) {
throw new Error(`${response.status} ${response.data}` || "error");
}