From bae8dabc5c3c593b0de3b4de755ddbbc7b617235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Sat, 25 Jan 2025 10:24:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=BC=E5=AE=B9JSON=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=20=E5=BC=82=E5=B8=B8=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + src/common/config-base.ts | 3 ++- src/common/fall-back.ts | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 06bd0e10..ccb457c2 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "dev:depend": "npm i && cd napcat.webui && npm i" }, "devDependencies": { + "json5": "^2.2.3", "esbuild": "0.24.0", "@babel/preset-typescript": "^7.24.7", "@eslint/compat": "^1.2.2", diff --git a/src/common/config-base.ts b/src/common/config-base.ts index deead630..7b8be702 100644 --- a/src/common/config-base.ts +++ b/src/common/config-base.ts @@ -1,6 +1,7 @@ import path from 'node:path'; import fs from 'node:fs'; import type { NapCatCore } from '@/core'; +import json5 from 'json5'; export abstract class ConfigBase { name: string; @@ -46,7 +47,7 @@ export abstract class ConfigBase { fs.writeFileSync(configPath, '{}'); } try { - this.configData = JSON.parse(fs.readFileSync(configPath, 'utf-8')); + this.configData = json5.parse(fs.readFileSync(configPath, 'utf-8')); this.core.context.logger.logDebug(`[Core] [Config] 配置文件${configPath}加载`, this.configData); return this.configData; } catch (e: any) { diff --git a/src/common/fall-back.ts b/src/common/fall-back.ts index 4cd85cd0..f760705f 100644 --- a/src/common/fall-back.ts +++ b/src/common/fall-back.ts @@ -25,7 +25,6 @@ export class Fallback { return data; } } catch (error) { - console.log(error); errors.push(error instanceof Error ? error : new Error(String(error))); } }