mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-16 13:01:14 +00:00
feat: webui OB11Config
This commit is contained in:
parent
0a0edcf203
commit
37d0354751
@ -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) => {
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user