去除代理配置,自动检测代理

This commit is contained in:
2025-10-09 11:05:35 +08:00
parent ba4078b66b
commit 96a2bae6dd
8 changed files with 242 additions and 300 deletions
+67 -74
View File
@@ -21,107 +21,99 @@ async function createPortable() {
await fs.copy(exePath, path.join(portableDir, exeName));
}
// 创建启动脚本
const startScript = `@echo off
title Pixiv Manager
REM ========================================
REM Proxy Configuration - Modify port according to your proxy software
REM Common ports: Clash=7890, V2Ray=10809, Shadowsocks=1080
REM ========================================
set PROXY_PORT=7890
REM ========================================
REM Server Port Configuration - Default 3000
REM ========================================
set SERVER_PORT=3000
REM ========================================
REM Log Level Configuration - Options: ERROR, WARN, INFO, DEBUG, TRACE
REM ERROR: Show only error messages
REM WARN: Show warning and above level messages
REM INFO: Show general information and above level messages (default)
REM DEBUG: Show debug information and above level messages
REM TRACE: Show all level messages (most detailed)
REM ========================================
set LOG_LEVEL=INFO
REM ========================================
REM Auto Open Browser Configuration - Options: true, false
REM true: Automatically open browser when server starts (default)
REM false: Do not automatically open browser
REM ========================================
set AUTO_OPEN_BROWSER=true
echo.
echo ========================================
echo Pixiv Manager Starting...
echo ========================================
echo.
cd /d "%~dp0"
echo Current proxy port: %PROXY_PORT%
echo Current server port: %SERVER_PORT%
echo Log level: %LOG_LEVEL%
echo To modify settings, edit this file with notepad
echo.
echo Starting backend server...
echo Access URL: http://localhost:%SERVER_PORT%
echo.
echo Tip: Press Ctrl+C to stop server
echo.
REM Start server and pass proxy port, server port and log level
if "%PROXY_PORT%"=="" (
pixiv-manager.exe --server-port=%SERVER_PORT% --log-level=%LOG_LEVEL% --auto-open-browser=%AUTO_OPEN_BROWSER%
) else (
pixiv-manager.exe --proxy-port=%PROXY_PORT% --server-port=%SERVER_PORT% --log-level=%LOG_LEVEL% --auto-open-browser=%AUTO_OPEN_BROWSER%
)
echo.
echo Server stopped
pause
`;
// 创建配置文件
const config = {
server: {
port: 3000,
autoOpenBrowser: true
},
proxy: {
port: null,
enabled: "auto"
},
logging: {
level: "INFO"
},
system: {
threadPoolSize: 16
}
};
await fs.writeFile(path.join(portableDir, 'start.bat'), startScript, 'utf8');
await fs.writeFile(path.join(portableDir, 'config.json'), JSON.stringify(config, null, 2), 'utf8');
// 创建README
const readme = `# Pixiv Manager 便携版
## 使用说明
1. 双击 \`start.bat\` 启动程序
1. 双击 \`pixiv-manager.exe\` 启动程序
2. 在浏览器中访问 http://localhost:3000
3. 按 Ctrl+C 停止服务器
## 配置设置
如需修改配置,请用记事本编辑 \`start.bat\` 文件:
如需修改配置,请用记事本编辑 \`config.json\` 文件:
### 代理设置(重要)
修改PROXY_PORT=xxxx)的端口号
修改 proxy 部分
\`\`\`json
{
"proxy": {
"port": null, // 代理端口号(auto模式下可为null)
"enabled": "auto" // 代理模式:true/false/"auto"
}
}
\`\`\`
代理模式说明:
- \`"auto"\`: 自动检测系统代理(推荐)
- \`true\`: 启用指定端口的代理
- \`false\`: 禁用代理
常见代理端口:
- Clash: 7890
- V2Ray: 10809
- Shadowsocks: 1080
**推荐使用 "auto" 模式**,程序会自动检测 Clash 等代理软件的系统代理设置。
### 服务器端口设置
修改SERVER_PORT=xxxx)的端口号,默认为3000
修改 server 部分:
\`\`\`json
{
"server": {
"port": 3000, // 服务器端口,默认3000
"autoOpenBrowser": true // 是否自动打开浏览器
}
}
\`\`\`
### 日志级别设置
修改LOG_LEVEL=xxxx)的日志级别,可选值
修改 logging 部分
\`\`\`json
{
"logging": {
"level": "INFO" // 日志级别
}
}
\`\`\`
可选的日志级别:
- ERROR: 只显示错误信息
- WARN: 显示警告及以上级别信息
- INFO: 显示一般信息及以上级别信息(默认)
- DEBUG: 显示调试信息及以上级别信息
- TRACE: 显示所有级别信息(最详细)
### 自动打开浏览器设置
修改AUTO_OPEN_BROWSER=xxxx)的值来启用或禁用自动打开浏览器功能
- true: 启动服务器后自动打开浏览器(默认)
- false: 不自动打开浏览器
### 系统设置
修改 system 部分
\`\`\`json
{
"system": {
"threadPoolSize": 16 // 线程池大小,影响下载性能
}
}
\`\`\`
## 注意事项
@@ -129,6 +121,7 @@ pause
- 程序会在当前目录创建数据文件夹
- 没代理或者代理设置错误无法成功登录,注意仔细检查,获取code的时间比较短,记得快速操作
- 支持Windows 10/11 64位系统
- 修改配置文件后需要重启程序才能生效
`;
await fs.writeFile(path.join(portableDir, 'README.txt'), readme, 'utf8');