mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-16 13:01:14 +00:00
feat: webui LoginStatus
This commit is contained in:
parent
bd8a1d715f
commit
856b5e16b1
@ -6,23 +6,23 @@ const isEmpty = (data: any) => data === undefined || data === null || data === '
|
||||
export const LoginHandler: RequestHandler = async (req, res) => {
|
||||
const { token } = req.body;
|
||||
if (isEmpty(token)) {
|
||||
res.status(400).send({
|
||||
code: 400,
|
||||
res.json({
|
||||
code: 0,
|
||||
message: 'token is empty'
|
||||
});
|
||||
return;
|
||||
}
|
||||
let config = await WebUIConfig();
|
||||
if (!DataRuntime.checkLoginRate(config.loginRate)) {
|
||||
res.status(400).send({
|
||||
code: 400,
|
||||
res.json({
|
||||
code: 0,
|
||||
message: 'login rate limit'
|
||||
});
|
||||
return;
|
||||
}
|
||||
let signCredential = Buffer.from(JSON.stringify(AuthHelper.signCredential(config.token))).toString('base64');
|
||||
res.json({
|
||||
code: 200,
|
||||
code: 0,
|
||||
message: 'success',
|
||||
data: {
|
||||
"Credential": signCredential
|
||||
@ -31,5 +31,10 @@ export const LoginHandler: RequestHandler = async (req, res) => {
|
||||
return;
|
||||
};
|
||||
export const LogoutHandler: RequestHandler = (req, res) => {
|
||||
|
||||
// 这玩意无状态销毁个灯 得想想办法
|
||||
res.json({
|
||||
code: 0,
|
||||
message: 'success'
|
||||
});
|
||||
return;
|
||||
};
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { RequestHandler } from "express";
|
||||
import { resolve } from "path";
|
||||
|
||||
export const GetLogHandler: RequestHandler = (req, res) => {
|
||||
|
||||
//res.sendFile(resolve(__dirname, "../../../logs/napcat.log"));
|
||||
};
|
||||
|
@ -1,8 +1,32 @@
|
||||
import { RequestHandler } from "express";
|
||||
import { DataRuntime } from "../helper/Data";
|
||||
|
||||
export const GetQRcodeHandler: RequestHandler = (req, res) => {
|
||||
|
||||
export const QQGetQRcodeHandler: RequestHandler = async (req, res) => {
|
||||
if (await DataRuntime.getQQLoginStatus()) {
|
||||
res.send({
|
||||
code: -1,
|
||||
message: 'QQ Is Logined'
|
||||
});
|
||||
}
|
||||
};
|
||||
export const CheckLoginStatusHandler: RequestHandler = (req, res) => {
|
||||
|
||||
};
|
||||
export const QQCheckLoginStatusHandler: RequestHandler = (req, res) => {
|
||||
res.send({
|
||||
code: 0,
|
||||
message: 'success',
|
||||
data: {
|
||||
isLogin: DataRuntime.getQQLoginStatus()
|
||||
}
|
||||
});
|
||||
};
|
||||
export const QQQuickLoginHandler: RequestHandler = async (req, res) => {
|
||||
// 未完成
|
||||
const { token } = req.body;
|
||||
if (token) {
|
||||
const isLogin = await DataRuntime.getQQLoginStatus();
|
||||
}
|
||||
// 未实现
|
||||
res.send({
|
||||
code: 0,
|
||||
message: 'success'
|
||||
});
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
let LoginRuntime = {
|
||||
LoginCurrentTime: Date.now(),
|
||||
LoginCurrentRate: 0
|
||||
LoginCurrentRate: 0,
|
||||
QQLoginStatus: false, //得去那边注册个回调刷新
|
||||
QQQRCodeURL: ""
|
||||
}
|
||||
export const DataRuntime = {
|
||||
checkLoginRate: async function (RateLimit: number): Promise<boolean> {
|
||||
@ -14,4 +16,12 @@ export const DataRuntime = {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
,
|
||||
getQQLoginStatus: async function (): Promise<boolean> {
|
||||
return LoginRuntime.QQLoginStatus;
|
||||
}
|
||||
,
|
||||
setQQLoginStatus: async function (status: boolean): Promise<void> {
|
||||
LoginRuntime.QQLoginStatus = status;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user