From 472fb5267c1b3fa8ab798ccd15bb1aac70128d41 Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期三, 13 五月 2026 16:00:39 +0800
Subject: [PATCH] 更新
---
index.js | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/index.js b/index.js
index d0da8df..4da037b 100644
--- a/index.js
+++ b/index.js
@@ -8,9 +8,13 @@
const { UploadManager } = require("./lib/upload");
const { createDashboard } = require("./dashboard/server");
-const configPath = path.join(__dirname, "config.json");
+// 配置读取:优先从工作目录(CWD),便于打包后用户编辑;开发时回退到 __dirname
+let configPath = path.resolve(process.cwd(), "config.json");
if (!fs.existsSync(configPath)) {
- console.error("缺少 config.json,请先创建配置文件");
+ configPath = path.join(__dirname, "config.json");
+}
+if (!fs.existsSync(configPath)) {
+ console.error("缺少 config.json,请先创建配置文件(放置于当前工作目录或程序目录)");
process.exit(1);
}
@@ -37,7 +41,7 @@
const activeDevices = config.devices.filter((d) => d.enabled !== false);
console.log(`配置校验通过: ${activeDevices.length}/${config.devices.length} 台设备启用`);
-const logDir = path.resolve(__dirname, config.logDir || "./logs");
+const logDir = path.resolve(process.cwd(), config.logDir || "./logs");
const logger = createLogger({
logDir,
retentionDays: config.logRetentionDays || 30,
--
Gitblit v1.8.0