feat: webui finish without auth

This commit is contained in:
手瓜一十雪 2024-05-08 20:10:33 +08:00
parent 875fed8d77
commit a3a40e1e74
2 changed files with 34 additions and 5 deletions

View File

@ -53,11 +53,11 @@ export const QQSetQuickLoginHandler: RequestHandler = async (req, res) => {
});
return;
}
let ret = await DataRuntime.getQQQuickLogin(uin);
if (!ret.result) {
const { result, message } = await DataRuntime.getQQQuickLogin(uin);
if (!result) {
res.send({
code: -1,
message: ret.message
message: message
});
return;
}

View File

@ -214,6 +214,27 @@
}
return [];
}
async function SetQuickLogin(uin, retCredential) {
let QQLoginResponse = await fetch('/api/QQLogin/SetQuickLogin', {
method: 'POST',
headers: {
'Authorization': "Bearer " + retCredential,
'Content-Type': 'application/json'
},
body: JSON.stringify({
uin: uin
})
});
if (QQLoginResponse.status == 200) {
let QQLoginResponseJson = await QQLoginResponse.json();
if (QQLoginResponseJson.code == 0) {
return { result: true, errMsg: "" };
} else {
return { result: false, errMsg: QQLoginResponseJson.message };
}
}
return { result: false, errMsg: "接口异常" };;
}
//心跳轮询CheckQQLoginStatus 是否已经进入登录状态如果为true进入./config.html
async function HeartBeat() {
let isLogined = await CheckQQLoginStatus(localStorage.getItem('auth'));
@ -240,8 +261,16 @@
qrcode.style.display = 'none';
});
function selectAccount(accountName) {
alert(`Logging in with ${accountName}...`);
async function selectAccount(accountName) {
//alert(`Logging in with ${accountName}...`);
const { result, errMsg } = await SetQuickLogin(accountName, localStorage.getItem('auth'));
if (result) {
alert("登录成功即将跳转");
window.location.href = './config.html';
} else {
alert("登录失败," + errMsg);
}
//await (localStorage.getItem('auth'))
document.getElementById('quick-login-options').classList.remove('show');
}
document.getElementById('qrcode-login').addEventListener('click', function () {