feat(registry): 迁移至 Rust + Axum + SQLite 并新增编辑、分页和档案同步功能

- 后端从 Node.js 迁移到 Rust,使用 Axum 框架和 SQLite 存储
- 新增档案编辑对话框,支持修改机型、登记人及替换/删除照片
- 档案列表增加分页导航(每页20条)
- 新增档案同步状态提示及手动重试同步按钮
- Node.js 原版后端及网页保留为回退方案,移至 legacy-web 目录
- 更新 .gitignore 添加 Rust 构建产物(target、dist)
- 更新 README 文档,补充 Rust 启动、开发、检查及打包说明
- 启动源码版.cmd 默认转发至 Rust 版启动脚本
```
This commit is contained in:
2026-10-21 11:54:38 +08:00
parent 85924f35ff
commit 4d55796cb3
39 changed files with 5925 additions and 39 deletions
+72
View File
@@ -0,0 +1,72 @@
param([string]$OutputRoot)
$ErrorActionPreference = 'Stop'
. (Join-Path $PSScriptRoot 'rust-env.ps1')
$ridRepo = Split-Path $PSScriptRoot -Parent
if (-not $OutputRoot) { $OutputRoot = Join-Path $ridRepo 'dist' }
$ridOutputRoot = [IO.Path]::GetFullPath($OutputRoot)
$ridDestination = Join-Path $ridOutputRoot 'FPV-RID-Rust'
$ridWhitelist = @('fpv-rid-registry.exe', '启动Rust版.cmd', '使用说明.md', 'qrcode-LICENSE.txt', 'dependency-licenses.txt', 'SHA256SUMS.txt')
function Assert-CleanDestination {
if (Test-Path -LiteralPath $ridDestination) {
foreach ($ridEntry in Get-ChildItem -LiteralPath $ridDestination -Force) {
if ($ridEntry.PSIsContainer -or $ridEntry.Name -notin $ridWhitelist -or
($ridEntry.Attributes -band [IO.FileAttributes]::ReparsePoint)) {
throw "发布目录含运行数据或非发布文件,已停止打包并保留原内容:$($ridEntry.FullName)。请通过 -OutputRoot 指定单独的输出目录。"
}
}
}
}
# Refuse a used deployment folder before building or changing any published files.
Assert-CleanDestination
$ridStageRoot = Join-Path $ridOutputRoot ('.package-' + [guid]::NewGuid().ToString('N'))
$ridStage = Join-Path $ridStageRoot 'FPV-RID-Rust'
$ridTemporaryZip = Join-Path $ridStageRoot 'release.zip'
Push-Location $ridRepo
try {
cargo build --release --locked
if ($LASTEXITCODE -ne 0) { throw 'Release build failed' }
$ridMetadata = cargo metadata --locked --format-version 1 --no-deps | ConvertFrom-Json
if ($LASTEXITCODE -ne 0) { throw 'Cargo metadata failed' }
New-Item -ItemType Directory -Force -Path $ridStage | Out-Null
Copy-Item -LiteralPath (Join-Path $ridMetadata.target_directory 'release/fpv-rid-registry.exe') -Destination $ridStage
Copy-Item -LiteralPath (Join-Path $ridRepo '启动Rust版.cmd') -Destination $ridStage
Copy-Item -LiteralPath (Join-Path $ridRepo 'doc/registry/rust/使用说明.md') -Destination $ridStage
Copy-Item -LiteralPath (Join-Path $ridRepo 'registry/web/vendor/LICENSE.txt') -Destination (Join-Path $ridStage 'qrcode-LICENSE.txt')
$ridLicenses = cargo tree --locked --prefix none --format '{p} {l}'
if ($LASTEXITCODE -ne 0) { throw 'Dependency inventory failed' }
$ridLicenses | Set-Content -LiteralPath (Join-Path $ridStage 'dependency-licenses.txt') -Encoding utf8
$ridWhitelist | Where-Object { $_ -ne 'SHA256SUMS.txt' } | ForEach-Object {
'{0} {1}' -f (Get-FileHash -LiteralPath (Join-Path $ridStage $_) -Algorithm SHA256).Hash, $_
} | Set-Content -LiteralPath (Join-Path $ridStage 'SHA256SUMS.txt') -Encoding utf8
$ridActual = @(Get-ChildItem -LiteralPath $ridStage -Force)
if ($ridActual.Count -ne $ridWhitelist.Count -or @($ridActual | Where-Object { $_.PSIsContainer -or $_.Name -notin $ridWhitelist }).Count) {
throw 'Staging directory does not match the release whitelist'
}
# Only the fresh, checked staging tree is ever compressed.
Compress-Archive -LiteralPath $ridStage -DestinationPath $ridTemporaryZip
Assert-CleanDestination
New-Item -ItemType Directory -Force -Path $ridDestination | Out-Null
foreach ($ridName in $ridWhitelist) {
Copy-Item -LiteralPath (Join-Path $ridStage $ridName) -Destination (Join-Path $ridDestination $ridName)
}
$ridZip = Join-Path $ridOutputRoot 'FPV-RID-Rust-Windows-x64.zip'
Move-Item -LiteralPath $ridTemporaryZip -Destination $ridZip -Force
'{0} FPV-RID-Rust-Windows-x64.zip' -f (Get-FileHash -LiteralPath $ridZip -Algorithm SHA256).Hash |
Set-Content -LiteralPath "$ridZip.sha256" -Encoding utf8
Write-Output $ridDestination
Write-Output $ridZip
} finally {
Pop-Location
# Clean only files this invocation created. Never recursively delete an output directory.
foreach ($ridName in $ridWhitelist) {
$ridOwnedFile = Join-Path $ridStage $ridName
if (Test-Path -LiteralPath $ridOwnedFile -PathType Leaf) { Remove-Item -LiteralPath $ridOwnedFile }
}
if (Test-Path -LiteralPath $ridTemporaryZip -PathType Leaf) { Remove-Item -LiteralPath $ridTemporaryZip }
if ((Test-Path -LiteralPath $ridStage -PathType Container) -and @(Get-ChildItem -LiteralPath $ridStage -Force).Count -eq 0) { Remove-Item -LiteralPath $ridStage }
if ((Test-Path -LiteralPath $ridStageRoot -PathType Container) -and @(Get-ChildItem -LiteralPath $ridStageRoot -Force).Count -eq 0) { Remove-Item -LiteralPath $ridStageRoot }
}