# 本地启动脚本:从被 .gitignore 排除的 .env 加载凭据,仓库内不含任何真实口令。 # 用法:复制 dev/.env.example 为 dev/.env 并填写,然后执行本脚本。 $ErrorActionPreference = 'Stop' $envFile = Join-Path $PSScriptRoot '.env' if (-not (Test-Path $envFile)) { throw "缺少 $envFile,请先从 .env.example 复制并填写本机凭据" } Get-Content -LiteralPath $envFile | ForEach-Object { $line = $_.Trim() if ($line -eq '' -or $line.StartsWith('#')) { return } if ($line -match '^([A-Za-z0-9_]+)\s*=\s*(.*)$') { [Environment]::SetEnvironmentVariable($Matches[1], $Matches[2], 'Process') } } foreach ($required in @('APT_DB_PASSWORD', 'APT_TOKEN_SECRET')) { if (-not [Environment]::GetEnvironmentVariable($required, 'Process')) { throw "缺少必需环境变量 $required(请在 .env 中填写)" } } $backend = Join-Path (Split-Path $PSScriptRoot -Parent) 'RuoYi-Vue-master' Set-Location $backend & mvn -pl ruoyi-admin -am spring-boot:run