修复log文件夹创建导致越权问题

This commit is contained in:
ACT丶流星雨 2026-02-10 17:41:18 +08:00
parent 2f979b915a
commit 7f4ba4e17c
2 changed files with 84 additions and 21 deletions

View File

@ -1,24 +1,42 @@
Name: @aigne/core Name: @ai-sdk/anthropic
License: Elastic-2.0 License: Apache-2.0
Repository: https://github.com/AIGNE-io/aigne-framework Repository: https://github.com/vercel/ai
----------------------------- -----------------------------
Name: @aigne/openai Name: @ai-sdk/deepseek
License: Elastic-2.0 License: Apache-2.0
Repository: https://github.com/AIGNE-io/aigne-framework Repository: https://github.com/vercel/ai
----------------------------- -----------------------------
Name: @langchain/core Name: @ai-sdk/devtools
License: MIT License: MIT*
Repository: https://github.com/langchain-ai/langchainjs Repository: N/A
----------------------------- -----------------------------
Name: @langchain/openai Name: @ai-sdk/google
License: MIT License: Apache-2.0
Repository: https://github.com/langchain-ai/langchainjs Repository: https://github.com/vercel/ai
-----------------------------
Name: @ai-sdk/openai-compatible
License: Apache-2.0
Repository: https://github.com/vercel/ai
-----------------------------
Name: @ai-sdk/openai
License: Apache-2.0
Repository: https://github.com/vercel/ai
-----------------------------
Name: @ai-sdk/xai
License: Apache-2.0
Repository: https://github.com/vercel/ai
----------------------------- -----------------------------
@ -64,6 +82,12 @@ Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
----------------------------- -----------------------------
Name: ai
License: Apache-2.0
Repository: https://github.com/vercel/ai
-----------------------------
Name: axios-retry Name: axios-retry
License: Apache-2.0 License: Apache-2.0
Repository: https://github.com/softonic/axios-retry Repository: https://github.com/softonic/axios-retry
@ -76,6 +100,12 @@ Repository: https://github.com/axios/axios
----------------------------- -----------------------------
Name: best-effort-json-parser
License: BSD-2-Clause
Repository: https://github.com/beenotung/best-effort-json-parser
-----------------------------
Name: better-sqlite3 Name: better-sqlite3
License: MIT License: MIT
Repository: https://github.com/WiseLibs/better-sqlite3 Repository: https://github.com/WiseLibs/better-sqlite3
@ -88,6 +118,12 @@ Repository: https://github.com/expressjs/cors
----------------------------- -----------------------------
Name: cross-env
License: MIT
Repository: https://github.com/kentcdodds/cross-env
-----------------------------
Name: dotenv Name: dotenv
License: BSD-2-Clause License: BSD-2-Clause
Repository: https://github.com/motdotla/dotenv Repository: https://github.com/motdotla/dotenv
@ -166,12 +202,6 @@ Repository: https://github.com/knex/knex
----------------------------- -----------------------------
Name: langchain
License: MIT
Repository: https://github.com/langchain-ai/langchainjs
-----------------------------
Name: license-checker Name: license-checker
License: BSD-3-Clause License: BSD-3-Clause
Repository: https://github.com/davglass/license-checker Repository: https://github.com/davglass/license-checker
@ -190,6 +220,24 @@ Repository: https://github.com/remy/nodemon
----------------------------- -----------------------------
Name: qwen-ai-provider
License: Apache-2.0
Repository: https://github.com/Younis-Ahmed/qwen-ai-provider
-----------------------------
Name: serialize-error
License: MIT
Repository: https://github.com/sindresorhus/serialize-error
-----------------------------
Name: serialize-error
License: MIT
Repository: https://github.com/sindresorhus/serialize-error
-----------------------------
Name: sharp Name: sharp
License: Apache-2.0 License: Apache-2.0
Repository: https://github.com/lovell/sharp Repository: https://github.com/lovell/sharp
@ -214,9 +262,15 @@ Repository: https://github.com/microsoft/TypeScript
----------------------------- -----------------------------
Name: zod Name: uuid
License: MIT License: MIT
Repository: https://github.com/colinhacks/zod Repository: https://github.com/uuidjs/uuid
-----------------------------
Name: zhipu-ai-provider
License: Apache-2.0
Repository: https://github.com/Xiang-CH/zhipu-ai-provider
----------------------------- -----------------------------

View File

@ -4,7 +4,16 @@ import * as path from "path";
type LogLevel = "log" | "info" | "warn" | "error" | "debug"; type LogLevel = "log" | "info" | "warn" | "error" | "debug";
type ConsoleMethod = (...args: unknown[]) => void; type ConsoleMethod = (...args: unknown[]) => void;
const LOG_DIR = "./logs"; function getLogDir(): string {
const isElectron = typeof process.versions?.electron !== "undefined";
if (isElectron) {
const { app } = require("electron");
return path.join(app.getPath("userData"), "logs");
}
return path.join(process.cwd(), "logs");
}
const LOG_DIR = getLogDir();
const LOG_FILE = path.join(LOG_DIR, "app.log"); const LOG_FILE = path.join(LOG_DIR, "app.log");
const MAX_SIZE = 1000 * 1024 * 1024; const MAX_SIZE = 1000 * 1024 * 1024;
const LEVELS: LogLevel[] = ["log", "info", "warn", "error", "debug"]; const LEVELS: LogLevel[] = ["log", "info", "warn", "error", "debug"];