322d806876
- 新增 client/windows/build.ps1:拉内核→带 --dart-define 构建→出安装包一键串联, 规避 Release 漏 --dart-define 导致默认连 localhost、登录「网络请求失败」的坑。 - README:Release 命令补回 --dart-define 并加显式警告,指向一键脚本。 - 清 4 个 lint warning:desktop_vpn_bridge 多余 cast→pattern match、去多余非空断言; nav_sidebar 删未用 import;vpn_bridge_mock 加 killSwitchEnabled getter。 - 同步 window_manager/tray_manager/screen_retriever 插件注册生成文件(win+macos)。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
98 lines
3.6 KiB
PowerShell
98 lines
3.6 KiB
PowerShell
<#
|
||
.SYNOPSIS
|
||
Pangolin Windows 客户端一键构建脚本(拉内核 → 带 dart-define 构建 → 出安装包)。
|
||
|
||
.DESCRIPTION
|
||
串起 client/windows/README.md 里的三步手动流程,避免漏掉 --dart-define
|
||
(漏了会默认连 localhost:8080,登录「网络请求失败」)。
|
||
|
||
步骤:
|
||
1. bash app/kernel/fetch-desktop-bin.sh windows <arch> (拉 sing-box.exe + wintun.dll,SHA 校验)
|
||
2. flutter build windows --release --dart-define=PANGOLIN_API_URL=<ApiUrl>
|
||
3. ISCC.exe installer\pangolin.iss (除非 -SkipInstaller)
|
||
|
||
.PARAMETER ApiUrl
|
||
必填。后端地址,会在构建期烘进二进制,例:http://103.119.13.48:8080
|
||
|
||
.PARAMETER Arch
|
||
CPU 架构,默认 amd64。
|
||
|
||
.PARAMETER SkipInstaller
|
||
只构建,不出 Inno Setup 安装包。
|
||
|
||
.EXAMPLE
|
||
powershell -ExecutionPolicy Bypass -File client\windows\build.ps1 -ApiUrl http://103.119.13.48:8080
|
||
#>
|
||
[CmdletBinding()]
|
||
param(
|
||
[Parameter(Mandatory = $true)]
|
||
[string]$ApiUrl,
|
||
|
||
[string]$Arch = "amd64",
|
||
|
||
[switch]$SkipInstaller
|
||
)
|
||
|
||
$ErrorActionPreference = "Stop"
|
||
|
||
# 路径解析:本脚本在 client/windows/ 下
|
||
$WindowsDir = $PSScriptRoot
|
||
$ClientDir = Split-Path -Parent $WindowsDir
|
||
$RepoRoot = Split-Path -Parent $ClientDir
|
||
|
||
function Step([string]$msg) { Write-Host "`n==> $msg" -ForegroundColor Cyan }
|
||
|
||
# ── 1. 拉内核(sing-box.exe + wintun.dll)─────────────────────────────────────
|
||
Step "拉取 sing-box.exe + wintun.dll (windows $Arch)"
|
||
$bash = Get-Command bash -ErrorAction SilentlyContinue
|
||
if (-not $bash) {
|
||
throw "未找到 bash(fetch 脚本需 Git Bash)。请安装 Git for Windows 后重试。"
|
||
}
|
||
$fetchScript = Join-Path $RepoRoot "app/kernel/fetch-desktop-bin.sh"
|
||
& $bash.Source $fetchScript windows $Arch
|
||
if ($LASTEXITCODE -ne 0) { throw "内核拉取失败 (exit $LASTEXITCODE)" }
|
||
|
||
# ── 2. Flutter 构建(必须带 dart-define)──────────────────────────────────────
|
||
Step "flutter build windows --release (PANGOLIN_API_URL=$ApiUrl)"
|
||
Push-Location $ClientDir
|
||
try {
|
||
flutter build windows --release --dart-define=PANGOLIN_API_URL=$ApiUrl
|
||
if ($LASTEXITCODE -ne 0) { throw "flutter build 失败 (exit $LASTEXITCODE)" }
|
||
}
|
||
finally {
|
||
Pop-Location
|
||
}
|
||
|
||
$releaseDir = Join-Path $ClientDir "build\windows\x64\runner\Release"
|
||
Write-Host "构建产物:$releaseDir" -ForegroundColor Green
|
||
|
||
# ── 3. 出安装包(Inno Setup)──────────────────────────────────────────────────
|
||
if ($SkipInstaller) {
|
||
Step "跳过安装包(-SkipInstaller)"
|
||
return
|
||
}
|
||
|
||
Step "编译 Inno Setup 安装包"
|
||
$iscc = $null
|
||
foreach ($p in @(
|
||
"C:\Program Files (x86)\Inno Setup 6\ISCC.exe",
|
||
"C:\Program Files\Inno Setup 6\ISCC.exe")) {
|
||
if (Test-Path $p) { $iscc = $p; break }
|
||
}
|
||
if (-not $iscc) {
|
||
$cmd = Get-Command ISCC.exe -ErrorAction SilentlyContinue
|
||
if ($cmd) { $iscc = $cmd.Source }
|
||
}
|
||
if (-not $iscc) {
|
||
Write-Warning "未找到 ISCC.exe(Inno Setup 6 未安装)。已完成构建,跳过安装包。"
|
||
Write-Warning "装好 Inno Setup 6 后可手动:ISCC.exe `"$WindowsDir\installer\pangolin.iss`""
|
||
return
|
||
}
|
||
|
||
$iss = Join-Path $WindowsDir "installer\pangolin.iss"
|
||
& $iscc $iss
|
||
if ($LASTEXITCODE -ne 0) { throw "ISCC 编译失败 (exit $LASTEXITCODE)" }
|
||
|
||
$output = Join-Path $WindowsDir "installer\Output"
|
||
Write-Host "`n✓ 全部完成。安装包在:$output" -ForegroundColor Green
|