32 lines
1.2 KiB
PowerShell
32 lines
1.2 KiB
PowerShell
# Storage Android APK 构建 (Tauri 2)
|
|
# 前置: Android SDK + JVM + Rust + src-tauri/
|
|
# 用法: npm run build:apk (或 powershell -ExecutionPolicy Bypass -File scripts/build-apk.ps1)
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$root = Split-Path -Parent $PSScriptRoot
|
|
$tauriDir = Join-Path $root "src-tauri"
|
|
if (-not (Test-Path $tauriDir)) {
|
|
Write-Host @"
|
|
[build-apk] 缺少 src-tauri/ 目录。Storage 的 Tauri 壳尚未初始化, 先执行:
|
|
npm run tauri init
|
|
然后重新运行本脚本。
|
|
"@ -ForegroundColor Yellow
|
|
exit 1
|
|
}
|
|
|
|
# 前端打内嵌资源 (Android 端相对 /api 会打到内嵌服务, 需指向远端后端)
|
|
# 生产后端地址由环境决定 (与 部署环境.md 一致): baihu.vps.honor3.com:3003
|
|
# (Android APP 页面源是 http://tauri.localhost, 访问外网明文 HTTP 需放行 usesCleartextTraffic)
|
|
$VITE_API_BASE = if ($env:VITE_API_BASE) { $env:VITE_API_BASE } else { "http://baihu.vps.honor3.com:3003" }
|
|
$env:VITE_API_BASE = $VITE_API_BASE
|
|
|
|
Write-Host "[build-apk] VITE_API_BASE=$VITE_API_BASE"
|
|
|
|
Push-Location $root
|
|
try {
|
|
npx tauri android build --apk
|
|
} finally {
|
|
Pop-Location
|
|
}
|
|
|
|
Write-Host "[build-apk] 完成 (release APK 见 src-tauri/gen/android/... )" |