diff --git a/src/common/types.ts b/src/common/types.ts index e35c910..3e5a094 100644 --- a/src/common/types.ts +++ b/src/common/types.ts @@ -181,15 +181,16 @@ export interface PostDataSendMsg { } export interface Config { - port: number, - hosts: string[], + port: number + hosts: string[] enableBase64?: boolean debug?: boolean + log?: boolean } export interface SendMsgResult { - status: number, - retcode: number, - data: any, - message: string, + status: number + retcode: number + data: any + message: string } \ No newline at end of file diff --git a/src/main/main.ts b/src/main/main.ts index a2c3946..c0840cd 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -18,7 +18,7 @@ import { } from "../common/IPCChannel"; import {ConfigUtil} from "./config"; import {startExpress} from "./HttpServer"; -import {checkFileReceived, CONFIG_DIR, isGIF, log} from "./utils"; +import {checkFileReceived, CONFIG_DIR, getConfigUtil, isGIF, log} from "./utils"; import {friends, groups, selfInfo} from "./data"; import {} from "../global"; @@ -32,10 +32,7 @@ function onLoad() { log("main onLoaded"); // const config_dir = browserWindow.LiteLoader.plugins["LLOneBot"].path.data; - function getConfigUtil() { - const configFilePath = path.join(CONFIG_DIR, `config_${selfInfo.user_id}.json`) - return new ConfigUtil(configFilePath) - } + if (!fs.existsSync(CONFIG_DIR)) { fs.mkdirSync(CONFIG_DIR, {recursive: true}); diff --git a/src/main/utils.ts b/src/main/utils.ts index 7084d83..bfafa66 100644 --- a/src/main/utils.ts +++ b/src/main/utils.ts @@ -1,11 +1,21 @@ import * as path from "path"; import {json} from "express"; import {selfInfo} from "./data"; +import {ConfigUtil} from "./config"; const fs = require('fs'); export const CONFIG_DIR = global.LiteLoader.plugins["LLOneBot"].path.data; + +export function getConfigUtil() { + const configFilePath = path.join(CONFIG_DIR, `config_${selfInfo.user_id}.json`) + return new ConfigUtil(configFilePath) +} + export function log(msg: any) { + if (!getConfigUtil().getConfig().log){ + return + } let currentDateTime = new Date().toLocaleString(); const date = new Date(); const year = date.getFullYear(); @@ -44,4 +54,4 @@ export function checkFileReceived(path: string, timeout: number=3000): Promise +
@@ -624,6 +624,13 @@ async function onSettingWindowCreated(view: Element) {
+ +
+
日志
+
日志目录:${window.LiteLoader.plugins["LLOneBot"].path.data}
+
+ +
@@ -634,6 +641,11 @@ async function onSettingWindowCreated(view: Element) { .tips { font-size: 0.75rem; } + @media (prefers-color-scheme: dark){ + .llonebot input { + color: white; + } + } ` @@ -667,6 +679,7 @@ async function onSettingWindowCreated(view: Element) { switchClick("debug", "debug"); switchClick("switchBase64", "enableBase64"); + switchClick("log", "log"); doc.getElementById("save")?.addEventListener("click", () => {