Compare commits

...

2 Commits

Author SHA1 Message Date
手瓜一十雪
a0d780558e fix 2025-02-05 19:01:14 +08:00
Mlikiowa
ad56065a4e release: v4.5.7 2025-02-05 07:10:27 +00:00
6 changed files with 18 additions and 17 deletions

View File

@@ -4,7 +4,7 @@
"name": "NapCatQQ", "name": "NapCatQQ",
"slug": "NapCat.Framework", "slug": "NapCat.Framework",
"description": "高性能的 OneBot 11 协议实现", "description": "高性能的 OneBot 11 协议实现",
"version": "4.5.6", "version": "4.5.7",
"icon": "./logo.png", "icon": "./logo.png",
"authors": [ "authors": [
{ {

View File

@@ -2,7 +2,7 @@
"name": "napcat", "name": "napcat",
"private": true, "private": true,
"type": "module", "type": "module",
"version": "4.5.6", "version": "4.5.7",
"scripts": { "scripts": {
"build:universal": "npm run build:webui && vite build --mode universal || exit 1", "build:universal": "npm run build:webui && vite build --mode universal || exit 1",
"build:framework": "npm run build:webui && vite build --mode framework || exit 1", "build:framework": "npm run build:webui && vite build --mode framework || exit 1",

View File

@@ -1 +1 @@
export const napCatVersion = '4.5.6'; export const napCatVersion = '4.5.7';

View File

@@ -15,7 +15,6 @@ let napCatInitialized = false; // 添加一个标志
function createServiceProxy(ServiceName) { function createServiceProxy(ServiceName) {
return new Proxy(() => { }, { return new Proxy(() => { }, {
get: (target, FunctionName) => { get: (target, FunctionName) => {
console.log(ServiceName, FunctionName);
if (ServiceName === 'NodeIQQNTWrapperSession' && FunctionName === 'create') { if (ServiceName === 'NodeIQQNTWrapperSession' && FunctionName === 'create') {
return () => new Proxy({}, { return () => new Proxy({}, {
get: function (target, ClassFunName, receiver) { get: function (target, ClassFunName, receiver) {

View File

@@ -1,5 +1,5 @@
import { ConfigBase } from '@/common/config-base'; import { ConfigBase } from '@/common/config-base';
import { NapCatCore } from '@/core'; import type { NapCatCore } from '@/core';
import { OneBotConfig } from './config'; import { OneBotConfig } from './config';
import { AnySchema } from 'ajv'; import { AnySchema } from 'ajv';

View File

@@ -1,13 +1,12 @@
import { RequestHandler } from 'express'; import { RequestHandler } from 'express';
import { existsSync, readFileSync } from 'node:fs'; import { existsSync, readFileSync } from 'node:fs';
import { resolve } from 'node:path'; import { resolve } from 'node:path';
import { loadConfig, OneBotConfig } from '@/onebot/config/config';
import { OneBotConfig } from '@/onebot/config/config';
import { webUiPathWrapper } from '@/webui'; import { webUiPathWrapper } from '@/webui';
import { WebUiDataRuntime } from '@webapi/helper/Data'; import { WebUiDataRuntime } from '@webapi/helper/Data';
import { sendError, sendSuccess } from '@webapi/utils/response'; import { sendError, sendSuccess } from '@webapi/utils/response';
import { isEmpty } from '@webapi/utils/check'; import { isEmpty } from '@webapi/utils/check';
import json5 from 'json5';
// 获取OneBot11配置 // 获取OneBot11配置
export const OB11GetConfigHandler: RequestHandler = (_, res) => { export const OB11GetConfigHandler: RequestHandler = (_, res) => {
@@ -19,16 +18,16 @@ export const OB11GetConfigHandler: RequestHandler = (_, res) => {
} }
// 获取登录的QQ号 // 获取登录的QQ号
const uin = WebUiDataRuntime.getQQLoginUin(); const uin = WebUiDataRuntime.getQQLoginUin();
// 读取配置文件 // 读取配置文件路径
const configFilePath = resolve(webUiPathWrapper.configPath, `./onebot11_${uin}.json`); const configFilePath = resolve(webUiPathWrapper.configPath, `./onebot11_${uin}.json`);
// 尝试解析配置文件 // 尝试解析配置文件
try { try {
// 读取配置文件 // 读取配置文件内容
const data = JSON.parse( const configFileContent = existsSync(configFilePath)
existsSync(configFilePath) ? readFileSync(configFilePath).toString()
? readFileSync(configFilePath).toString() : readFileSync(resolve(webUiPathWrapper.configPath, './onebot11.json')).toString();
: readFileSync(resolve(webUiPathWrapper.configPath, './onebot11.json')).toString() // 解析配置文件并加载配置
) as OneBotConfig; const data = loadConfig(json5.parse(configFileContent)) as OneBotConfig;
// 返回配置文件 // 返回配置文件
return sendSuccess(res, data); return sendSuccess(res, data);
} catch (e) { } catch (e) {
@@ -50,9 +49,12 @@ export const OB11SetConfigHandler: RequestHandler = async (req, res) => {
} }
// 写入配置 // 写入配置
try { try {
await WebUiDataRuntime.setOB11Config(JSON.parse(req.body.config)); // 解析并加载配置
const config = loadConfig(json5.parse(req.body.config)) as OneBotConfig;
// 写入配置
await WebUiDataRuntime.setOB11Config(config);
return sendSuccess(res, null); return sendSuccess(res, null);
} catch (e) { } catch (e) {
return sendError(res, 'Error: ' + e); return sendError(res, 'Error: ' + e);
} }
}; };