This commit is contained in:
乘风
2026-01-30 14:10:47 +08:00
parent 174253584f
commit c08ca72992
8 changed files with 781 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
@echo off
chcp 65001 >nul
echo ==================================
echo Soul派对小程序 - 编译脚本
echo ==================================
echo.
:: 设置项目路径
set "PROJECT_PATH=%~dp0"
set "PROJECT_PATH=%PROJECT_PATH:~0,-1%"
:: 微信开发者工具可能的安装路径
set "CLI1=C:\Program Files (x86)\Tencent\微信web开发者工具\cli.bat"
set "CLI2=C:\Program Files\Tencent\微信web开发者工具\cli.bat"
set "CLI3=%LOCALAPPDATA%\微信web开发者工具\cli.bat"
:: 查找CLI
set "CLI="
if exist "%CLI1%" set "CLI=%CLI1%"
if exist "%CLI2%" set "CLI=%CLI2%"
if exist "%CLI3%" set "CLI=%CLI3%"
if "%CLI%"=="" (
echo ❌ 未找到微信开发者工具CLI
echo.
echo 请手动操作:
echo 1. 打开微信开发者工具
echo 2. 点击"导入项目"
echo 3. 选择目录: %PROJECT_PATH%
echo 4. 点击"编译"按钮
echo.
pause
exit /b 1
)
echo ✅ 找到微信开发者工具: %CLI%
echo 项目路径: %PROJECT_PATH%
echo.
:: 1. 打开项目
echo 📂 步骤1打开项目...
call "%CLI%" open --project "%PROJECT_PATH%"
timeout /t 3 /nobreak >nul
echo ✅ 项目已打开
echo.
:: 2. 编译项目
echo 🔨 步骤2编译项目...
call "%CLI%" build-npm --project "%PROJECT_PATH%"
timeout /t 2 /nobreak >nul
echo ✅ 编译完成
echo.
:: 3. 生成预览二维码
echo 📱 步骤3生成预览二维码...
call "%CLI%" preview --project "%PROJECT_PATH%" --qr-format image --qr-output "%PROJECT_PATH%\preview.png"
if exist "%PROJECT_PATH%\preview.png" (
echo ✅ 二维码已生成: %PROJECT_PATH%\preview.png
start "" "%PROJECT_PATH%\preview.png"
) else (
echo ⚠️ 二维码生成失败,请在开发者工具中手动点击"预览"
)
echo.
echo ==================================
echo 🎉 编译完成!
echo ==================================
echo.
echo 下一步操作:
echo 1. 在模拟器中查看效果
echo 2. 点击"预览"生成二维码,用微信扫码测试
echo 3. 点击"上传"提交到微信后台
echo.
pause

View File

@@ -0,0 +1,93 @@
# Soul派对小程序 - Windows编译脚本
Write-Host "==================================" -ForegroundColor Cyan
Write-Host " Soul派对小程序 - 编译脚本" -ForegroundColor Cyan
Write-Host "==================================" -ForegroundColor Cyan
Write-Host ""
# 设置项目路径
$ProjectPath = Split-Path -Parent $MyInvocation.MyCommand.Path
# 微信开发者工具可能的安装路径
$cliPaths = @(
"C:\Program Files (x86)\Tencent\微信web开发者工具\cli.bat",
"C:\Program Files\Tencent\微信web开发者工具\cli.bat",
"$env:LOCALAPPDATA\微信web开发者工具\cli.bat"
)
# 查找CLI
$cli = $null
foreach ($path in $cliPaths) {
if (Test-Path $path) {
$cli = $path
break
}
}
if (-not $cli) {
Write-Host "未找到微信开发者工具CLI" -ForegroundColor Yellow
Write-Host ""
Write-Host "请手动操作:" -ForegroundColor Cyan
Write-Host "1. 打开微信开发者工具" -ForegroundColor White
Write-Host "2. 点击 '导入项目'" -ForegroundColor White
Write-Host "3. 选择目录: $ProjectPath" -ForegroundColor White
Write-Host "4. 点击 '编译' 按钮" -ForegroundColor White
Write-Host ""
# 尝试启动微信开发者工具
$devToolsPaths = @(
"C:\Program Files (x86)\Tencent\微信web开发者工具\微信开发者工具.exe",
"C:\Program Files\Tencent\微信web开发者工具\微信开发者工具.exe"
)
foreach ($toolPath in $devToolsPaths) {
if (Test-Path $toolPath) {
Write-Host "正在启动微信开发者工具..." -ForegroundColor Green
Start-Process $toolPath
break
}
}
exit 1
}
Write-Host "找到微信开发者工具: $cli" -ForegroundColor Green
Write-Host "项目路径: $ProjectPath" -ForegroundColor Gray
Write-Host ""
# 1. 打开项目
Write-Host "步骤1打开项目..." -ForegroundColor Cyan
& cmd /c "`"$cli`" open --project `"$ProjectPath`""
Start-Sleep -Seconds 3
Write-Host "项目已打开" -ForegroundColor Green
Write-Host ""
# 2. 编译项目
Write-Host "步骤2编译项目..." -ForegroundColor Cyan
& cmd /c "`"$cli`" build-npm --project `"$ProjectPath`""
Start-Sleep -Seconds 2
Write-Host "编译完成" -ForegroundColor Green
Write-Host ""
# 3. 生成预览二维码
Write-Host "步骤3生成预览二维码..." -ForegroundColor Cyan
$previewPath = Join-Path $ProjectPath "preview.png"
& cmd /c "`"$cli`" preview --project `"$ProjectPath`" --qr-format image --qr-output `"$previewPath`""
if (Test-Path $previewPath) {
Write-Host "二维码已生成: $previewPath" -ForegroundColor Green
Start-Process $previewPath
} else {
Write-Host "二维码生成失败,请在开发者工具中手动点击'预览'" -ForegroundColor Yellow
}
Write-Host ""
Write-Host "==================================" -ForegroundColor Cyan
Write-Host " 编译完成!" -ForegroundColor Green
Write-Host "==================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "下一步操作:" -ForegroundColor Cyan
Write-Host "1. 在模拟器中查看效果" -ForegroundColor White
Write-Host "2. 点击'预览'生成二维码,用微信扫码测试" -ForegroundColor White
Write-Host "3. 点击'上传'提交到微信后台" -ForegroundColor White
Write-Host ""