2024-05-06 07:12:27 +00:00
|
|
|
<!DOCTYPE html>
|
2024-05-07 13:17:31 +00:00
|
|
|
<html>
|
|
|
|
|
2024-05-06 07:12:27 +00:00
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
2024-05-06 14:24:27 +00:00
|
|
|
<title>WebUi - Index</title>
|
2024-05-06 07:12:27 +00:00
|
|
|
</head>
|
2024-05-07 13:17:31 +00:00
|
|
|
|
2024-05-06 07:12:27 +00:00
|
|
|
<body>
|
2024-05-07 13:17:31 +00:00
|
|
|
<script>
|
2024-08-10 09:45:17 +00:00
|
|
|
async function CheckQQLoginStatus(retCredential) {
|
2024-07-26 03:12:09 +00:00
|
|
|
let QQLoginResponse = await fetch('../api/QQLogin/CheckLoginStatus', {
|
2024-05-08 13:12:03 +00:00
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Authorization': "Bearer " + retCredential,
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (QQLoginResponse.status == 200) {
|
|
|
|
let QQLoginResponseJson = await QQLoginResponse.json();
|
|
|
|
if (QQLoginResponseJson.code == 0) {
|
|
|
|
if (QQLoginResponseJson.data.isLogin) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2024-05-07 13:17:31 +00:00
|
|
|
}
|
2024-05-08 13:12:03 +00:00
|
|
|
async function CheckWebUiLogined(retCredential) {
|
2024-07-26 03:12:09 +00:00
|
|
|
let LoginResponse = await fetch('../api/auth/check', {
|
2024-05-08 13:12:03 +00:00
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Authorization': "Bearer " + retCredential,
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (LoginResponse.status == 200) {
|
|
|
|
let LoginResponseJson = await LoginResponse.json();
|
|
|
|
if (LoginResponseJson.code == 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
async function InitPage() {
|
2024-08-10 09:45:17 +00:00
|
|
|
//查找URL参数是否有token
|
|
|
|
let url = new URL(window.location.href);
|
|
|
|
let token = url.searchParams.get("token");
|
|
|
|
if (token) {
|
2024-08-11 05:48:26 +00:00
|
|
|
let loginResponse = await fetch('../api/auth/login', {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
|
|
|
body: JSON.stringify({ token: token })
|
|
|
|
});
|
|
|
|
const loginResponseJson = await loginResponse.json();
|
|
|
|
let retCode = loginResponseJson.code;
|
|
|
|
if (retCode === 0) {
|
|
|
|
//登录成功
|
|
|
|
let retCredential = loginResponseJson.data.Credential;
|
|
|
|
localStorage.setItem('auth', retCredential);
|
|
|
|
}
|
2024-08-10 09:45:17 +00:00
|
|
|
}
|
2024-08-11 05:48:26 +00:00
|
|
|
|
2024-05-08 13:12:03 +00:00
|
|
|
let authData = localStorage.getItem('auth');
|
|
|
|
let isLogined = await CheckWebUiLogined(authData);
|
|
|
|
if (authData && isLogined) {
|
|
|
|
let isQQLoined = await CheckQQLoginStatus(authData);
|
|
|
|
if (!isQQLoined) {
|
|
|
|
window.location.href = './QQLogin.html';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
window.location.href = './config.html';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
window.location.href = './login.html';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
InitPage();
|
2024-05-07 13:17:31 +00:00
|
|
|
</script>
|
2024-05-06 07:12:27 +00:00
|
|
|
</body>
|
2024-05-07 13:17:31 +00:00
|
|
|
|
2024-05-06 07:12:27 +00:00
|
|
|
</html>
|