调整打包脚本使用 packaging 资源路径

This commit is contained in:
cat-shark
2026-06-20 18:37:23 +08:00
parent e3d4fd1aa1
commit c703229518
12 changed files with 168 additions and 120 deletions
+8 -6
View File
@@ -4,7 +4,9 @@ const https = require('https');
const http = require('http');
const { execSync } = require('child_process');
const BASE_DIR = path.join(__dirname, '../electron/resources/extra');
const PACKAGING_DIR = path.join(__dirname, '../packaging');
const RESOURCE_DIR = path.join(PACKAGING_DIR, 'resources');
const VENDOR_DIR = path.join(PACKAGING_DIR, 'vendor');
// 下载进度显示
function downloadFile(url, destPath, description) {
@@ -81,11 +83,11 @@ async function main() {
// 1. 下载 Python 3.12 嵌入式版本
console.log('\n📦 步骤 1/4: 下载 Python 3.12 嵌入式版本');
const pythonDir = path.join(BASE_DIR, 'common/python');
const pythonDir = path.join(VENDOR_DIR, 'python-runtime');
await fs.ensureDir(pythonDir);
if (!fs.existsSync(path.join(pythonDir, 'python.exe'))) {
const pythonZip = path.join(BASE_DIR, 'python-3.12.0-embed-amd64.zip');
const pythonZip = path.join(VENDOR_DIR, 'python-3.12.0-embed-amd64.zip');
await downloadFile(
'https://www.python.org/ftp/python/3.12.0/python-3.12.0-embed-amd64.zip',
@@ -160,7 +162,7 @@ async function main() {
// 3. 下载 FFmpeg
console.log('\n📦 步骤 3/4: 下载 FFmpeg');
const ffmpegDir = path.join(BASE_DIR, 'win-x86');
const ffmpegDir = path.join(VENDOR_DIR, 'ffmpeg');
await fs.ensureDir(ffmpegDir);
if (!fs.existsSync(path.join(ffmpegDir, 'ffmpeg.exe'))) {
@@ -178,7 +180,7 @@ async function main() {
// 4. 下载 Chromium (通过 puppeteer)
console.log('\n📦 步骤 4/4: 准备 Chromium 浏览器');
const chromiumDir = path.join(BASE_DIR, 'common/chromium');
const chromiumDir = path.join(RESOURCE_DIR, 'common/chromium');
await fs.ensureDir(chromiumDir);
if (!fs.existsSync(path.join(chromiumDir, 'chrome-win'))) {
@@ -220,7 +222,7 @@ async function main() {
// 5. 下载 AI 模型
console.log('\n📦 步骤 5/5: 下载 AI 模型');
const modelsDir = path.join(BASE_DIR, 'common/models');
const modelsDir = path.join(VENDOR_DIR, 'models');
await fs.ensureDir(modelsDir);
const u2netPath = path.join(modelsDir, 'u2net.onnx');