gx
chenyc
2026-05-24 a43f8991d3f5fa2ef4e0f3eeeca00fb4afc263c0
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,