feat: webui OB11Config

This commit is contained in:
手瓜一十雪 2024-05-07 19:48:25 +08:00
parent 0a0edcf203
commit 37d0354751
2 changed files with 33 additions and 1 deletions

View File

@ -1,7 +1,30 @@
import { RequestHandler } from "express";
import { DataRuntime } from "../helper/Data";
import { existsSync } from "node:fs";
import { resolve } from "node:path";
import { OB11Config } from "@/webui/ui/components/WebApi";
const isEmpty = (data: any) => data === undefined || data === null || data === '';
export const OB11GetConfigHandler: RequestHandler = async (req, res) => {
const uin = await DataRuntime.getQQLoginUin();
let configFilePath = resolve(__dirname, `./config/onebot_${uin}.json`);
let data: OB11Config;
try {
data = existsSync(configFilePath) ? require(configFilePath) : require(resolve(__dirname, `./config/onebot.json`));
}
catch (e) {
data = {} as OB11Config;
res.send({
code: -1,
message: 'QRCode Get Error'
});
return;
}
res.send({
code: 0,
message: 'success',
data: data
});
return;
}
export const OB11SetConfigHandler: RequestHandler = async (req, res) => {
}

View File

@ -2,7 +2,8 @@ let LoginRuntime = {
LoginCurrentTime: Date.now(),
LoginCurrentRate: 0,
QQLoginStatus: false, //得去那边注册个回调刷新
QQQRCodeURL: ""
QQQRCodeURL: "",
QQLoginUin: 0
}
export const DataRuntime = {
checkLoginRate: async function (RateLimit: number): Promise<boolean> {
@ -32,4 +33,12 @@ export const DataRuntime = {
getQQLoginQrcodeURL: async function (): Promise<string> {
return LoginRuntime.QQQRCodeURL;
}
,
setQQLoginUin: async function (uin: number): Promise<void> {
LoginRuntime.QQLoginUin = uin;
}
,
getQQLoginUin: async function (): Promise<number> {
return LoginRuntime.QQLoginUin;
}
}