增加打包版

This commit is contained in:
2025-08-22 08:13:56 +08:00
parent 0cc890f440
commit 8729025b04
6 changed files with 146 additions and 7 deletions
+4 -3
View File
@@ -1,6 +1,3 @@
/test
/package-lock.json
# Logs # Logs
logs logs
*.log *.log
@@ -72,3 +69,7 @@ backend/config/user-config.json
# 自己的启动文件 # 自己的启动文件
start_me.bat start_me.bat
#打包文件夹
dist/
pixiv-manager-portable/
+7
View File
@@ -17,6 +17,13 @@ Pixiv 下载浏览管理器是一个基于 Web 的应用程序,提供以下功
## 🚀 快速开始 ## 🚀 快速开始
### 便携版下载(如果不想自义定或者是懒)
如果懒得配置环境,可以直接下载便携版:
- **下载链接**: https://pan.baidu.com/s/1pIdl8eqQSA8jc2RM7HoZfg?pwd=j18v
- **提取码**: j18v
- **使用说明**: 下载后解压,记事本打开start.bat配置代理(看readme有介绍),双击 `start.bat` 即可启动,打开网站,按照教程登录即可
### 环境要求 ### 环境要求
- **Node.js** (版本 >= 16.0.0) - **Node.js** (版本 >= 16.0.0)
+11 -1
View File
@@ -7,7 +7,17 @@ const path = require('path')
*/ */
class ConfigManager { class ConfigManager {
constructor() { constructor() {
this.configDir = path.join(__dirname, 'user-config.json') // 检测是否在pkg打包环境中运行
const isPkg = process.pkg !== undefined;
if (isPkg) {
// 在打包环境中,使用可执行文件所在目录
this.configDir = path.join(process.cwd(), 'data', 'user-config.json')
} else {
// 在开发环境中,使用相对路径
this.configDir = path.join(__dirname, 'user-config.json')
}
this.defaultConfig = { this.defaultConfig = {
downloadDir: "./downloads", downloadDir: "./downloads",
fileStructure: "artist/artwork", fileStructure: "artist/artwork",
+12 -1
View File
@@ -12,7 +12,18 @@ class DownloadService {
this.artworkService = new ArtworkService(auth); this.artworkService = new ArtworkService(auth);
this.artistService = new ArtistService(auth); this.artistService = new ArtistService(auth);
this.configManager = new ConfigManager(); this.configManager = new ConfigManager();
this.dataPath = path.join(__dirname, '../../data');
// 检测是否在pkg打包环境中运行
const isPkg = process.pkg !== undefined;
if (isPkg) {
// 在打包环境中,使用可执行文件所在目录
this.dataPath = path.join(process.cwd(), 'data');
} else {
// 在开发环境中,使用相对路径
this.dataPath = path.join(__dirname, '../../data');
}
this.tasksFile = path.join(this.dataPath, 'download_tasks.json'); this.tasksFile = path.join(this.dataPath, 'download_tasks.json');
this.historyFile = path.join(this.dataPath, 'download_history.json'); this.historyFile = path.join(this.dataPath, 'download_history.json');
+15 -2
View File
@@ -1,13 +1,26 @@
{ {
"name": "pixiv-backend", "name": "pixiv-backend",
"version": "1.0.0", "version": "1.0.0",
"description": "Pixiv 后端服务 - 支持 OAuth 2.0 登录和 API 调用", "description": "Pixiv 下载浏览管理器",
"main": "backend/start.js", "main": "backend/start.js",
"bin": "backend/start.js",
"pkg": {
"targets": ["node18-win-x64"],
"outputPath": "dist",
"assets": [
"backend/**/*",
"ui/**/*",
"data/**/*",
"node_modules/**/*"
]
},
"scripts": { "scripts": {
"start": "node backend/start.js", "start": "node backend/start.js",
"dev": "node backend/start.js", "dev": "node backend/start.js",
"test": "node backend/test-login.js", "test": "node backend/test-login.js",
"set-proxy": "node backend/set-proxy.js" "set-proxy": "node backend/set-proxy.js",
"build": "pkg .",
"build-portable": "npm run build && node scripts/create-portable.js"
}, },
"dependencies": { "dependencies": {
"appdata-path": "^1.0.0", "appdata-path": "^1.0.0",
+97
View File
@@ -0,0 +1,97 @@
const fs = require('fs-extra');
const path = require('path');
async function createPortable() {
const distDir = path.join(__dirname, '..', 'dist');
const portableDir = path.join(__dirname, '..', 'pixiv-manager-portable');
try {
// 清理之前的便携版
await fs.remove(portableDir);
await fs.ensureDir(portableDir);
// 复制可执行文件
const exeName = 'pixiv-backend.exe';
const exePath = path.join(distDir, exeName);
if (await fs.pathExists(exePath)) {
await fs.copy(exePath, path.join(portableDir, exeName));
}
// 创建启动脚本
const startScript = `@echo off
chcp 65001 >nul
title Pixiv Manager
:: ========================================
:: 代理配置 - 请根据你的代理软件修改端口号
:: 常见端口: Clash=7890, V2Ray=10809, Shadowsocks=1080
:: ========================================
set PROXY_PORT=7890
echo.
echo ========================================
echo Pixiv Manager Starting...
echo ========================================
echo.
cd /d "%~dp0"
echo Current proxy port: %PROXY_PORT%
echo To change proxy port, edit this file and modify line 6
echo.
echo Starting backend server...
echo Access URL: http://localhost:3000
echo.
echo Tip: Press Ctrl+C to stop server
echo.
:: Start server and pass proxy port
pixiv-backend.exe --proxy-port=%PROXY_PORT%
echo.
echo Server stopped
pause
`;
await fs.writeFile(path.join(portableDir, 'start.bat'), startScript, 'utf8');
// 创建README
const readme = `# Pixiv Manager 便携版
## 使用说明
1. 双击 \`start.bat\` 启动程序
2. 在浏览器中访问 http://localhost:3000
3. 按 Ctrl+C 停止服务器
## 代理设置
如需使用代理,请编辑 \`start.bat\` 文件,修改第6行的端口号:
- Clash: 7890
- V2Ray: 10809
- Shadowsocks: 1080
## 注意事项
- 首次运行可能需要几秒钟启动时间
- 程序会在当前目录创建数据文件夹
- 支持Windows 10/11 64位系统
`;
await fs.writeFile(path.join(portableDir, 'README.txt'), readme, 'utf8');
// 创建数据目录
await fs.ensureDir(path.join(portableDir, 'data'));
await fs.ensureDir(path.join(portableDir, 'downloads'));
console.log('✅ 便携版创建完成!');
console.log(`📁 位置: ${portableDir}`);
console.log('📦 可以将整个文件夹打包分发给用户');
} catch (error) {
console.error('❌ 创建便携版失败:', error);
}
}
createPortable();