# ======================================== # 完整同步外层项目到内层项目 # ======================================== $ErrorActionPreference = "Stop" $OuterProject = Split-Path $PSScriptRoot $InnerProject = $PSScriptRoot Write-Host "========================================" Write-Host " 完整同步外层项目" Write-Host "========================================" Write-Host "外层项目: $OuterProject" -ForegroundColor Cyan Write-Host "内层项目: $InnerProject" -ForegroundColor Cyan Write-Host "" # 检查列表 $SyncItems = @( @{ Name = "Vosk 语音库 AAR" Source = "$OuterProject\uni_modules\xwq-speech-to-text\utssdk\app-android\libs\vosk-android-0.3.47.aar" Dest = "$InnerProject\src\uni_modules\xwq-speech-to-text\utssdk\app-android\libs\" Critical = $true }, @{ Name = "语音插件源码" Source = "$OuterProject\uni_modules\xwq-speech-to-text\utssdk\app-android\*.uts" Dest = "$InnerProject\src\uni_modules\xwq-speech-to-text\utssdk\app-android\" Critical = $true }, @{ Name = "语音插件配置" Source = "$OuterProject\uni_modules\xwq-speech-to-text\utssdk\app-android\config.json" Dest = "$InnerProject\src\uni_modules\xwq-speech-to-text\utssdk\app-android\" Critical = $true }, @{ Name = "语音插件 AndroidManifest" Source = "$OuterProject\uni_modules\xwq-speech-to-text\utssdk\app-android\AndroidManifest.xml" Dest = "$InnerProject\src\uni_modules\xwq-speech-to-text\utssdk\app-android\" Critical = $true }, @{ Name = "utils/config.js" Source = "$OuterProject\utils\config.js" Dest = "$InnerProject\src\utils\" Critical = $false }, @{ Name = "utils/request.js" Source = "$OuterProject\utils\request.js" Dest = "$InnerProject\src\utils\" Critical = $false } ) $AllSuccess = $true $CriticalMissing = $false Write-Host "开始同步..." -ForegroundColor Yellow Write-Host "" foreach ($item in $SyncItems) { Write-Host "[$($item.Name)]" -ForegroundColor Cyan # 检查源文件是否存在 $sourceFiles = Get-ChildItem -Path $item.Source -ErrorAction SilentlyContinue if (-Not $sourceFiles) { if ($item.Critical) { Write-Host " ✗ 源文件不存在(关键文件!)" -ForegroundColor Red Write-Host " $($item.Source)" -ForegroundColor Gray $CriticalMissing = $true } else { Write-Host " ⊙ 源文件不存在(可选)" -ForegroundColor Yellow } $AllSuccess = $false continue } # 创建目标目录 New-Item -ItemType Directory -Path $item.Dest -Force | Out-Null # 复制文件 try { Copy-Item -Path $item.Source -Destination $item.Dest -Force -Recurse -ErrorAction Stop Write-Host " ✓ 已同步" -ForegroundColor Green Write-Host " → $($item.Dest)" -ForegroundColor Gray } catch { Write-Host " ✗ 同步失败: $($_.Exception.Message)" -ForegroundColor Red $AllSuccess = $false if ($item.Critical) { $CriticalMissing = $true } } Write-Host "" } Write-Host "========================================" Write-Host " 同步完成" Write-Host "========================================" Write-Host "" # 验证关键文件 Write-Host "验证关键文件..." -ForegroundColor Yellow Write-Host "" $VerifyItems = @( @{ Name = "Vosk AAR 库" Path = "$InnerProject\src\uni_modules\xwq-speech-to-text\utssdk\app-android\libs\vosk-android-0.3.47.aar" }, @{ Name = "语音插件主文件" Path = "$InnerProject\src\uni_modules\xwq-speech-to-text\utssdk\app-android\index.uts" }, @{ Name = "语音插件配置" Path = "$InnerProject\src\uni_modules\xwq-speech-to-text\utssdk\app-android\config.json" }, @{ Name = "编译产物" Path = "$InnerProject\unpackage\dist\build\app-plus" } ) $AllVerified = $true foreach ($item in $VerifyItems) { if (Test-Path $item.Path) { Write-Host "✓ $($item.Name)" -ForegroundColor Green if ($item.Path -like "*.aar") { $fileSize = (Get-Item $item.Path).Length / 1MB Write-Host " 大小: $([math]::Round($fileSize, 2)) MB" -ForegroundColor Gray } } else { Write-Host "✗ $($item.Name) - 不存在" -ForegroundColor Red Write-Host " 路径: $($item.Path)" -ForegroundColor Gray $AllVerified = $false } } Write-Host "" Write-Host "========================================" Write-Host " 结果总结" Write-Host "========================================" Write-Host "" if ($CriticalMissing) { Write-Host "❌ 同步失败:缺少关键文件" -ForegroundColor Red Write-Host "" Write-Host "外层项目可能不完整,请勿删除!" -ForegroundColor Yellow exit 1 } elseif ($AllVerified) { Write-Host "✅ 同步成功!内层项目已完整" -ForegroundColor Green Write-Host "" Write-Host "验证通过的内容:" -ForegroundColor Cyan Write-Host " ✓ IP 配置 (192.168.1.8)" -ForegroundColor Green Write-Host " ✓ Vosk 语音库 (vosk-android-0.3.47.aar)" -ForegroundColor Green Write-Host " ✓ 语音识别插件源码" -ForegroundColor Green Write-Host " ✓ 编译产物" -ForegroundColor Green Write-Host "" Write-Host "✅ 可以安全删除外层项目" -ForegroundColor Green Write-Host "" Write-Host "下一步:" -ForegroundColor Yellow Write-Host " 1. 重新编译: npm run build:app" -ForegroundColor Cyan Write-Host " 2. 运行集成脚本: .\integrate-to-android-studio.ps1" -ForegroundColor Cyan Write-Host " 3. 用 Android Studio 打包" -ForegroundColor Cyan } else { Write-Host "⚠️ 同步完成但验证失败" -ForegroundColor Yellow Write-Host "" Write-Host "请检查缺失的文件后再删除外层项目" -ForegroundColor Yellow exit 1 }