/** * 配置文件 * 所有可调整参数集中管理,优先从 .env 文件读取敏感信息 * 也支持通过系统环境变量覆盖(优先级:系统环境变量 > .env 文件 > 默认值) */ // 加载 .env 文件(如果存在) const path = require('path'); const dotenv = require('dotenv'); const envPath = path.resolve(__dirname, '.env'); dotenv.config({ path: envPath }); const config = { // 目标网址 urls: { // 积分/任务中心页面 points: 'https://gitcode.com/setting/points', // 测试仓库编辑页(更新项目任务用) testRepo: process.env.GITCODE_TEST_REPO_URL || '', }, // 登录凭据(优先从环境变量读取,兜底使用默认值) login: { username: process.env.GITCODE_USERNAME || 'test', password: process.env.GITCODE_PASSWORD || 'test', }, // 飞书 Webhook feishu: { webhook: process.env.FEISHU_WEBHOOK || '', }, // 文件路径 statePath: 'state.json', // 目录 dirs: { screenshots: 'screenshots', logs: 'logs', }, // 重试 & 超时 retryCount: 3, timeout: 30000, navigationTimeout: 60000, taskTimeout: Number(process.env.TASK_TIMEOUT_MS) || 180000, // 调试模式 debug: { startWaitMs: Number(process.env.DEBUG_START_WAIT_MS) || 0, }, // 浏览器设置 browser: { headless: process.env.DEBUG === 'true' ? false : true, locale: 'zh-CN', }, }; module.exports = config;