63 lines
1.6 KiB
JavaScript
63 lines
1.6 KiB
JavaScript
var refresh_err_cnt = 0
|
|
function checkUser(){
|
|
if (localStorage.getItem("online_user") == '') {
|
|
location.href = "login.html";
|
|
}else{
|
|
axios.post('/pp/refreshUser', {
|
|
username: localStorage.getItem("online_user"),
|
|
uuid: localStorage.getItem("uuid"),
|
|
})
|
|
.then(function (response) {
|
|
|
|
if (response.status != 200) {
|
|
//location.href="login.html";
|
|
refresh_err_cnt+=1;
|
|
console.log("refresh_err_cnt:",refresh_err_cnt);
|
|
if (refresh_err_cnt>3) {
|
|
localStorage.setItem("refresh_err_cnt",refresh_err_cnt);
|
|
refresh_err_cnt = 0;
|
|
location.href="login.html";
|
|
}
|
|
}else if (response.status == 200 && response.data.r !=0) {
|
|
location.href="login.html";
|
|
}else if (response.status == 200 && response.data.r ==0) {
|
|
if (refresh_err_cnt > 0) {
|
|
refresh_err_cnt = 0;
|
|
}
|
|
}
|
|
|
|
})
|
|
.catch(function (error) {
|
|
|
|
refresh_err_cnt+=1;
|
|
console.log("refresh_err_cnt:",refresh_err_cnt);
|
|
if (refresh_err_cnt>3) {
|
|
localStorage.setItem("catch-error",error);
|
|
refresh_err_cnt = 0;
|
|
location.href="login.html";
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
{
|
|
let url = decodeURI(window.location.href);
|
|
let argsIndex = url .split("?user=");
|
|
console.log("current html argsIndex:",argsIndex);
|
|
let arg = argsIndex[1];
|
|
console.log("current html arg:",arg);
|
|
|
|
let argsIndex1 = url .split("uuid=");
|
|
console.log("current html argsIndex1:",argsIndex1);
|
|
let arg1= argsIndex1[1];
|
|
console.log("current html arg1:",arg1);
|
|
if (arg == undefined ||arg1 == undefined) {
|
|
console.log("user uuid error!")
|
|
}else{
|
|
localStorage.setItem("online_user",arg);
|
|
localStorage.setItem("uuid",arg1);
|
|
}
|
|
|
|
checkUser();
|
|
}
|