mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-12 07:50:25 +00:00
feat: 开始迁移webui
This commit is contained in:
@@ -1,86 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>WebUi - Index</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script>
|
||||
async function CheckQQLoginStatus(retCredential) {
|
||||
let QQLoginResponse = await fetch('../api/QQLogin/CheckLoginStatus', {
|
||||
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;
|
||||
}
|
||||
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() {
|
||||
//查找URL参数是否有token
|
||||
let url = new URL(window.location.href);
|
||||
let token = url.searchParams.get("token");
|
||||
if (token) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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';
|
||||
}
|
||||
InitPage();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="./vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vite + Vue + TS</title>
|
||||
<script type="module" crossorigin src="./assets/index-D10_5xOh.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="./assets/index-DQOoc4ch.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user