mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
fix:config
This commit is contained in:
@@ -1,5 +1,2 @@
|
||||
{
|
||||
"port": 6099,//端口
|
||||
"token": "123456",//密码
|
||||
"loginRate": 3//速率
|
||||
}
|
||||
# The Path of NapCatQQ
|
||||
Tiny WebUi for NapCatQQ
|
@@ -2,7 +2,7 @@ import { RequestHandler } from "express";
|
||||
import { DataRuntime } from "../helper/Data";
|
||||
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import { OB11Config } from "@/webui/ui/components/WebApi";
|
||||
import { OB11Config } from "@/webui/ui/components/WebUiApiOB11Config";
|
||||
const isEmpty = (data: any) => data === undefined || data === null || data === '';
|
||||
export const OB11GetConfigHandler: RequestHandler = async (req, res) => {
|
||||
let isLogin = await DataRuntime.getQQLoginStatus();
|
||||
@@ -53,12 +53,13 @@ export const OB11SetConfigHandler: RequestHandler = async (req, res) => {
|
||||
}
|
||||
let configFilePath = resolve(__dirname, `./config/onebot_${await DataRuntime.getQQLoginUin()}.json`);
|
||||
try {
|
||||
JSON.parse(req.body.config)
|
||||
readFileSync(configFilePath);
|
||||
}
|
||||
catch (e) {
|
||||
configFilePath = resolve(__dirname, `./config/onebot.json`);
|
||||
}
|
||||
writeFileSync(configFilePath, JSON.stringify(req.body.config, null, 4));
|
||||
writeFileSync(configFilePath, JSON.stringify(JSON.parse(req.body.config), null, 4));
|
||||
res.send({
|
||||
code: 0,
|
||||
message: 'success'
|
||||
|
@@ -49,7 +49,7 @@ class WebUiApiOB11ConfigWrapper {
|
||||
'Authorization': "Bearer " + this.retCredential,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(config)
|
||||
body: JSON.stringify({ config: JSON.stringify(config) })
|
||||
}
|
||||
);
|
||||
if (ConfigResponse.status == 200) {
|
||||
|
@@ -150,7 +150,11 @@ async function onSettingWindowCreated(view) {
|
||||
const isEmpty = (value) => value === void 0 || value === void 0 || value === "";
|
||||
let ob11Config = await OB11ConfigWrapper.GetOB11Config();
|
||||
const setOB11Config = (key, value) => {
|
||||
console.log(key, value);
|
||||
const configKey = key.split(".");
|
||||
if (configKey.length === 2) {
|
||||
ob11Config[configKey[1]] = value;
|
||||
}
|
||||
OB11ConfigWrapper.SetOB11Config(ob11Config);
|
||||
};
|
||||
const parser = new DOMParser();
|
||||
const doc = parser.parseFromString(
|
||||
|
Reference in New Issue
Block a user