# LocalNav 交互式部署管理(无需预先克隆) # 用法:.\scripts\install.ps1 $ErrorActionPreference = "Stop" $DefaultRepo = "https://git.bz121.com/dekun/LocalNav.git" $RawBase = "$($DefaultRepo -replace '\.git$','')/raw/main/scripts" function Need-Cmd($name) { if (-not (Get-Command $name -ErrorAction SilentlyContinue)) { Write-Error "[FAIL] 未找到 $name,请先安装" } } Need-Cmd python $scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path $navctlPy = Join-Path $scriptDir "navctl.py" if (-not (Test-Path $navctlPy)) { $tmpDir = Join-Path $env:TEMP ("localnav-" + [guid]::NewGuid().ToString()) New-Item -ItemType Directory -Path $tmpDir -Force | Out-Null Write-Host "[OK] 正在下载部署管理脚本..." Invoke-WebRequest -Uri "$RawBase/navctl.py" -OutFile (Join-Path $tmpDir "navctl.py") Invoke-WebRequest -Uri "$RawBase/nav_common.py" -OutFile (Join-Path $tmpDir "nav_common.py") $env:PYTHONPATH = "$tmpDir;$env:PYTHONPATH" python (Join-Path $tmpDir "navctl.py") @args Remove-Item -Recurse -Force $tmpDir exit $LASTEXITCODE } python $navctlPy @args