mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-01-17 13:50:36 +00:00
fix: redirect html
This commit is contained in:
parent
5b521409c6
commit
6c63990653
@ -57,12 +57,12 @@ export const checkHandler: RequestHandler = async (req, res) => {
|
|||||||
code: 0,
|
code: 0,
|
||||||
message: 'success'
|
message: 'success'
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
res.json({
|
res.json({
|
||||||
code: -1,
|
code: -1,
|
||||||
message: 'failed'
|
message: 'failed'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -9,13 +9,58 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
<script>
|
<script>
|
||||||
//读取localStorge 查看是否储存了为auth的数据
|
async function CheckQQLoginStatus(retCredential) {
|
||||||
let authData = localStorage.getItem('auth');
|
let QQLoginResponse = await fetch('/api/QQLogin/CheckLoginStatus', {
|
||||||
if (authData) {
|
method: 'POST',
|
||||||
//请求下api 看看QQlogin没有 没有去登录
|
headers: {
|
||||||
window.location.href = './config.html';
|
'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;
|
||||||
}
|
}
|
||||||
window.location.href = './login.html';
|
async function CheckWebUiLogined(retCredential) {
|
||||||
|
let LoginResponse = await fetch('/api/auth/check', {
|
||||||
|
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() {
|
||||||
|
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();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user