feat: webui getQrcode

This commit is contained in:
手瓜一十雪
2024-05-07 12:23:58 +08:00
parent b8a8b3cdc4
commit d07febd9ab
3 changed files with 30 additions and 2 deletions

View File

@@ -1,13 +1,30 @@
import { RequestHandler } from "express";
import { DataRuntime } from "../helper/Data";
const isEmpty = (data: any) => data === undefined || data === null || data === '';
export const QQGetQRcodeHandler: RequestHandler = async (req, res) => {
if (await DataRuntime.getQQLoginStatus()) {
res.send({
code: -1,
message: 'QQ Is Logined'
});
return;
}
let qrcodeUrl = await DataRuntime.getQQLoginQrcodeURL();
if (isEmpty(qrcodeUrl)) {
res.send({
code: -1,
message: 'QRCode Get Error'
});
return;
}
res.send({
code: 0,
message: 'success',
data: {
qrcode: qrcodeUrl
}
});
return;
};
export const QQCheckLoginStatusHandler: RequestHandler = (req, res) => {
res.send({

View File

@@ -24,4 +24,12 @@ export const DataRuntime = {
setQQLoginStatus: async function (status: boolean): Promise<void> {
LoginRuntime.QQLoginStatus = status;
}
,
setQQLoginQrcodeURL: async function (url: string): Promise<void> {
LoginRuntime.QQQRCodeURL = url;
}
,
getQQLoginQrcodeURL: async function (): Promise<string> {
return LoginRuntime.QQQRCodeURL;
}
}