feat(desktop): 支持粘贴配对并修复串流与设备切换

- 支持 Ctrl+V 粘贴配对文本和二维码图片,预览确认后识别校验
- 修复控制发送阻塞、TLS 读写争锁、设备切换沿用旧连接及串流误关窗
- 优化媒体加密上下文、UDP 接收缓冲和异步诊断日志
- 安装器按路径停止主控与信令进程,统一递增版本、打包和清理旧产物
- 发布 0.1.3+4,通过三端编译、20 项 Flutter 测试和 58 项 Rust 单元测试
This commit is contained in:
tongtong committed 2026-11-28 16:08:07 +08:00
1 parent f6b7730684
commit 3cd72d70e1
38 files changed
+1173 -196

No files matched your search

+10
View File
@@ -6,6 +6,16 @@
## Windows x64
日常交付使用统一入口(默认递增补丁版本和构建号、同步 Android/Flutter/Rust,编译测试后生成三种 Android APK 与 Windows 安装器):
```powershell
./installer/release.ps1 -VCRedist 'C:/path/to/vc_redist.x64.exe' -Iscc 'C:/path/to/ISCC.exe'
```
已在本轮手动递增版本时增加 `-UseCurrentVersion`,避免重复递增。产物位于 `dist/releases/v<版本>/`,
含 SHA256SUMS。新版成功生成后清理旧安装包和暂存目录;用户日志和本地设备配置保留在 `dist/validation/retained-artifact-data/`。
安装器在覆盖文件前按完整路径停止目标安装目录中的主控与信令进程;停止失败时中止安装并提示重试。
需要 Windows Flutter/Visual Studio C++、Rust MSVC、Go、Inno Setup 6。
从 Microsoft/Visual Studio 获取官方 `vc_redist.x64.exe`,安装器会运行它安装运行库
(运行库安装可能请求管理员权限)。安装程序默认按当前用户安装,含开始菜单、可选桌面快捷方式、卸载入口。
+47
View File
@@ -0,0 +1,47 @@
param([Parameter(Mandatory = $true)][string]$KeepVersion)
$ErrorActionPreference = 'Stop'
if ($KeepVersion -notmatch '^\d+\.\d+\.\d+$') { throw 'Invalid version' }
$root = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
$dist = [IO.Path]::GetFullPath((Join-Path $root 'dist'))
$keep = [IO.Path]::GetFullPath((Join-Path $dist "releases/v$KeepVersion"))
foreach ($name in @("TTSTDConnect-$KeepVersion-windows-x64-setup.exe", "TTSTDConnect-Receiver-$KeepVersion-neutral.apk", "TTSTDConnect-Receiver-$KeepVersion-aosp.apk", "TTSTDConnect-Receiver-$KeepVersion-zhanxun.apk", 'SHA256SUMS')) {
if (-not (Test-Path -LiteralPath (Join-Path $keep $name))) { throw "Latest release is incomplete: $name" }
}
function Remove-OwnedArtifact([string]$Path) {
if (-not (Test-Path -LiteralPath $Path)) { return }
$resolved = (Resolve-Path -LiteralPath $Path).Path
if (-not $resolved.StartsWith($dist + '\', [StringComparison]::OrdinalIgnoreCase) -or
$resolved -eq $keep -or $resolved.StartsWith($keep + '\', [StringComparison]::OrdinalIgnoreCase)) {
throw "Unsafe cleanup target: $resolved"
}
$item = Get-Item -LiteralPath $resolved
if ($item.PSIsContainer) {
$contents = @(Get-ChildItem -LiteralPath $resolved -Recurse -Force)
if ($item.Attributes -band [IO.FileAttributes]::ReparsePoint) {
throw "Refusing a linked cleanup root: $resolved"
}
foreach ($link in ($contents | Where-Object { $_.Attributes -band [IO.FileAttributes]::ReparsePoint })) {
$linkPath = [IO.Path]::GetFullPath($link.FullName)
if (-not $linkPath.StartsWith($resolved + '\', [StringComparison]::OrdinalIgnoreCase)) { throw "Unsafe link: $linkPath" }
# Unlink the entry itself without recursion; never traverse its target.
Remove-Item -LiteralPath $linkPath -Force
}
# Preserve diagnostics and local app settings that accidentally landed in a bundle.
foreach ($file in ($contents | Where-Object { -not $_.PSIsContainer -and -not ($_.Attributes -band [IO.FileAttributes]::ReparsePoint) -and ($_.Extension -eq '.log' -or $_.Name -like 'ttstd_*.json') })) {
$relative = $file.FullName.Substring($dist.Length + 1)
$saved = Join-Path $dist "validation/retained-artifact-data/$relative"
New-Item -ItemType Directory -Force -Path (Split-Path $saved) | Out-Null
Copy-Item -LiteralPath $file.FullName -Destination $saved -Force
}
}
Write-Output "Removing old artifact: $resolved"
Remove-Item -LiteralPath $resolved -Recurse -Force
}
Get-ChildItem -LiteralPath (Join-Path $dist 'releases') -Directory | Where-Object { $_.FullName -ne $keep } | ForEach-Object { Remove-OwnedArtifact $_.FullName }
$windows = Join-Path $dist 'windows'
if (Test-Path -LiteralPath $windows) {
Get-ChildItem -LiteralPath $windows -Directory -Filter 'stage-*' | ForEach-Object { Remove-OwnedArtifact $_.FullName }
Get-ChildItem -LiteralPath $windows -File -Filter 'TTSTDConnect-*-setup.exe' | Where-Object { $_.Name -ne "TTSTDConnect-$KeepVersion-windows-x64-setup.exe" } | ForEach-Object { Remove-OwnedArtifact $_.FullName }
}
foreach ($name in @('TTSTDConnect-Windows', 'TTSTDConnect-Android', 'linux', 'linux-signaling')) { Remove-OwnedArtifact (Join-Path $dist $name) }
Get-ChildItem -LiteralPath $dist -File | Where-Object { $_.Name -match '^(ttstdconnect[-_].*\.(deb|rpm)|TTSTDConnect-.*\.(AppImage|apk|exe|zip)|SHA256SUMS)$' } | ForEach-Object { Remove-OwnedArtifact $_.FullName }
+50
View File
@@ -0,0 +1,50 @@
param(
[Parameter(Mandatory = $true)][string]$VCRedist,
[string]$Iscc,
[switch]$UseCurrentVersion
)
$ErrorActionPreference = 'Stop'
$root = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
$pubspec = Join-Path $root 'flutter_sender/pubspec.yaml'
$versionText = Get-Content -LiteralPath $pubspec -Raw
$match = [regex]::Match($versionText, '(?m)^version:\s*(\d+)\.(\d+)\.(\d+)\+(\d+)')
if (-not $match.Success) { throw 'Flutter version must be major.minor.patch+build' }
$version = "$($match.Groups[1]).$($match.Groups[2]).$($match.Groups[3])"
$build = [int]$match.Groups[4].Value
if (-not $UseCurrentVersion) {
$version = "$($match.Groups[1]).$($match.Groups[2]).$([int]$match.Groups[3].Value + 1)"
$build++
$utf8 = [Text.UTF8Encoding]::new($false)
[IO.File]::WriteAllText($pubspec, [regex]::Replace($versionText, '(?m)^version:.*$', "version: $version+$build"), $utf8)
$android = Join-Path $root 'android_receiver/app/build.gradle.kts'
$text = Get-Content -LiteralPath $android -Raw
$text = [regex]::Replace($text, 'versionCode = \d+', "versionCode = $build")
$text = [regex]::Replace($text, 'versionName = "[^"]+"', "versionName = `"$version`"")
[IO.File]::WriteAllText($android, $text, $utf8)
$cargo = Join-Path $root 'rust_core/Cargo.toml'
$text = Get-Content -LiteralPath $cargo -Raw
[IO.File]::WriteAllText($cargo, [regex]::Replace($text, '(?m)^version = "[^"]+"', "version = `"$version`""), $utf8)
}
function Invoke-Checked([string]$Directory, [string]$Command, [string[]]$Arguments) {
Push-Location $Directory
try { & $Command @Arguments; if ($LASTEXITCODE -ne 0) { throw "$Command failed ($LASTEXITCODE)" } }
finally { Pop-Location }
}
$android = Join-Path $root 'android_receiver'
Invoke-Checked $android './gradlew.bat' @(':app:compileNeutralDebugKotlin', ':app:compileAospDebugKotlin', ':app:assembleNeutralRelease', ':app:assembleAospRelease', ':app:assembleZhanxunRelease', '--offline')
Invoke-Checked "$root/flutter_sender" flutter @('pub', 'get', '--offline')
Invoke-Checked "$root/flutter_sender" flutter @('test')
& "$PSScriptRoot/windows/setup.ps1" -VCRedist $VCRedist -Iscc $Iscc -Version $version
# setup.ps1 throws on a failed build; do not remove previous packages until all outputs exist.
$release = Join-Path $root "dist/releases/v$version"
New-Item -ItemType Directory -Force -Path $release | Out-Null
Copy-Item -LiteralPath "$root/dist/windows/TTSTDConnect-$version-windows-x64-setup.exe" -Destination $release
foreach ($flavor in @('neutral', 'aosp', 'zhanxun')) {
Copy-Item -LiteralPath "$android/app/build/outputs/apk/$flavor/release/app-$flavor-release.apk" -Destination "$release/TTSTDConnect-Receiver-$version-$flavor.apk"
}
Get-ChildItem -LiteralPath $release -File | Where-Object { $_.Extension -in '.apk', '.exe' } | ForEach-Object {
'{0} {1}' -f (Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash.ToLowerInvariant(), $_.Name
} | Set-Content -LiteralPath "$release/SHA256SUMS" -Encoding ascii
@{ version = $version; build = $build; baseCommit = (git -C $root rev-parse HEAD); workingTreeModified = [bool](git -C $root status --porcelain); builtAt = [DateTimeOffset]::Now.ToString('o') } | ConvertTo-Json | Set-Content -LiteralPath "$release/BUILD-INFO.json" -Encoding utf8
& "$PSScriptRoot/prune-artifacts.ps1" -KeepVersion $version
Write-Output "Release ready: $release"
+18
View File
@@ -20,9 +20,11 @@ Compression=lzma2
SolidCompression=yes
WizardStyle=modern
CloseApplications=yes
RestartApplications=no
[Tasks]
Name: desktopicon; Description: "Create a desktop shortcut"; Flags: unchecked
[Files]
Source: "stop-installed-processes.ps1"; Flags: dontcopy
Source: "{#VCRedist}"; DestDir: "{tmp}"; DestName: "vc_redist.x64.exe"; Flags: deleteafterinstall
Source: "{#BundleDir}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
[Icons]
@@ -31,3 +33,19 @@ Name: "{autodesktop}\TTSTDConnect"; Filename: "{app}\ttstd_sender.exe"; Tasks: d
[Run]
Filename: "{tmp}\vc_redist.x64.exe"; Parameters: "/install /passive /norestart"; StatusMsg: "Installing Microsoft Visual C++ Runtime"; Flags: waituntilterminated
Filename: "{app}\ttstd_sender.exe"; Description: "Launch TTSTDConnect"; Flags: nowait postinstall skipifsilent
[Code]
function PrepareToInstall(var NeedsRestart: Boolean): String;
var
ExitCode: Integer;
begin
Result := '';
ExtractTemporaryFile('stop-installed-processes.ps1');
if not Exec(ExpandConstant('{sys}\WindowsPowerShell\v1.0\powershell.exe'),
'-NoProfile -NonInteractive -ExecutionPolicy Bypass -File "' +
ExpandConstant('{tmp}\stop-installed-processes.ps1') + '" -InstallDir "' +
ExpandConstant('{app}') + '"', '', SW_HIDE, ewWaitUntilTerminated, ExitCode) then
Result := 'Unable to stop the installed application and signaling server.';
if (Result = '') and (ExitCode <> 0) then
Result := 'The installed application or signaling server could not be stopped. Close it and retry.';
end;
+3 -1
View File
@@ -40,7 +40,9 @@ if (-not $Bundle) {
Invoke-Step "$root/flutter_sender" flutter @('build', 'windows', '--release')
$Bundle = Join-Path $output ('stage-' + [guid]::NewGuid().ToString('N'))
New-Item -ItemType Directory -Path $Bundle | Out-Null
Copy-Item "$root/flutter_sender/build/windows/x64/runner/Release/*" $Bundle -Recurse
Get-ChildItem "$root/flutter_sender/build/windows/x64/runner/Release" -File |
Where-Object { $_.Extension -in '.exe', '.dll' } | Copy-Item -Destination $Bundle
Copy-Item "$root/flutter_sender/build/windows/x64/runner/Release/data" $Bundle -Recurse
Copy-Item "$root/rust_core/target/x86_64-pc-windows-msvc/release/ttstdconnect_core.dll" $Bundle
Invoke-Step "$root/signaling_server" go @('build', '-o', "$Bundle/signaling_server.exe", '.')
}
@@ -0,0 +1,18 @@
param([Parameter(Mandatory = $true)][string]$InstallDir)
$ErrorActionPreference = 'Stop'
$installPath = [IO.Path]::GetFullPath($InstallDir)
$ownedPaths = @('ttstd_sender.exe', 'signaling_server.exe') | ForEach-Object { Join-Path $installPath $_ }
# Match full executable paths, never terminate another installation by name alone.
Get-CimInstance Win32_Process -Filter "Name = 'ttstd_sender.exe' OR Name = 'signaling_server.exe'" | ForEach-Object {
if ($_.ExecutablePath -and $ownedPaths -contains $_.ExecutablePath) {
$process = Get-Process -Id $_.ProcessId -ErrorAction SilentlyContinue
if ($process) {
Write-Output "Stopping installed process: $($_.ExecutablePath) ($($_.ProcessId))"
if ($process.CloseMainWindow()) { $null = $process.WaitForExit(3000) }
if (-not $process.HasExited) {
$process.Kill()
if (-not $process.WaitForExit(5000)) { throw "Process did not stop: $($_.ProcessId)" }
}
}
}
}