4fe0b5a963
本次提交完成了项目核心基础架构升级: 1. 新增动态API中间件与权限控制系统,支持匿名/鉴权接口分离 2. 搭建云同步服务体系,包含认证、任务同步、安全策略等核心模块 3. 实现语音控制全链路,从STT/意图解析到命令执行 4. 新增任务类型、附件实体与相关仓储接口 5. 重构前端配置与代理规则,统一后端端口为5057 6. 新增多平台测试项目与CI脚本优化 7. 完善项目文档与代码注释规范 移除了旧版迁移文件与冗余代理配置,调整项目结构适配跨平台部署需求。
138 lines
5.1 KiB
PowerShell
138 lines
5.1 KiB
PowerShell
param(
|
|
[switch]$Force = $false,
|
|
[switch]$Rebuild = $false
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
Write-Host "====================================" -ForegroundColor Cyan
|
|
Write-Host " Hua.Todo.Host Start Script" -ForegroundColor Cyan
|
|
Write-Host "====================================" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
$hostProjectPath = Join-Path $PSScriptRoot "src\Hua.Todo.Host"
|
|
$hostProjectFile = Join-Path $hostProjectPath "Hua.Todo.Host.csproj"
|
|
$launchSettingsFile = Join-Path $hostProjectPath "Properties\launchSettings.json"
|
|
$outputDir = Join-Path $hostProjectPath "bin\Debug\net10.0"
|
|
$hostExe = Join-Path $outputDir "Hua.Todo.Host.exe"
|
|
|
|
if (!(Test-Path $hostProjectFile)) {
|
|
Write-Host "ERROR: Host project file not found: $hostProjectFile" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
if (!(Get-Command "dotnet" -ErrorAction SilentlyContinue)) {
|
|
Write-Host "ERROR: dotnet not found, please install .NET SDK first" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
$envSettings = @{}
|
|
$appUrl = "http://localhost:5173"
|
|
if (Test-Path $launchSettingsFile) {
|
|
try {
|
|
$launchSettings = Get-Content $launchSettingsFile -Raw | ConvertFrom-Json
|
|
$profile = $launchSettings.profiles.http
|
|
if ($profile) {
|
|
$appUrl = $profile.applicationUrl
|
|
if ($profile.environmentVariables) {
|
|
foreach ($key in $profile.environmentVariables.PSObject.Properties.Name) {
|
|
$envSettings[$key] = $profile.environmentVariables.$key
|
|
}
|
|
}
|
|
}
|
|
Write-Host "OK: Loaded launch settings from $launchSettingsFile" -ForegroundColor Green
|
|
} catch {
|
|
Write-Host "WARNING: Failed to read launch settings, using defaults: $_" -ForegroundColor Yellow
|
|
}
|
|
} else {
|
|
Write-Host "WARNING: launchSettings.json not found, using defaults" -ForegroundColor Yellow
|
|
}
|
|
|
|
Write-Host "[1/2] Checking if Hua.Todo.Host is running..." -ForegroundColor Yellow
|
|
|
|
$runningProcesses = Get-CimInstance Win32_Process -Filter "Name='dotnet.exe'" | Where-Object {
|
|
$_.CommandLine -and (
|
|
$_.CommandLine -like "*Hua.Todo.Host*" -or
|
|
$_.CommandLine -like "*Hua.Todo.Host.dll*"
|
|
)
|
|
}
|
|
|
|
if ($runningProcesses) {
|
|
$pids = ($runningProcesses.ProcessId | Sort-Object) -join ", "
|
|
Write-Host "WARNING: Hua.Todo.Host may be running" -ForegroundColor Yellow
|
|
Write-Host " Process IDs: ($pids)" -ForegroundColor Gray
|
|
|
|
if ($Force) {
|
|
Write-Host ""
|
|
Write-Host "Restarting..." -ForegroundColor Yellow
|
|
try {
|
|
$runningProcesses | ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction Stop }
|
|
Write-Host "Old process stopped" -ForegroundColor Green
|
|
Start-Sleep -Seconds 1
|
|
} catch {
|
|
Write-Host "ERROR: Failed to stop process: $_" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
} else {
|
|
Write-Host " Use -Force to restart" -ForegroundColor Gray
|
|
Write-Host ""
|
|
Write-Host "API Address:" -ForegroundColor Yellow
|
|
Write-Host " $appUrl" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
exit 0
|
|
}
|
|
} else {
|
|
Write-Host "OK: Hua.Todo.Host is not running" -ForegroundColor Green
|
|
Write-Host ""
|
|
}
|
|
|
|
Write-Host "[2/2] Starting Hua.Todo.Host..." -ForegroundColor Yellow
|
|
Write-Host "Working directory: $hostProjectPath" -ForegroundColor Gray
|
|
|
|
$needBuild = $Rebuild -or !(Test-Path $hostExe)
|
|
|
|
if ($needBuild) {
|
|
Write-Host "Building..." -ForegroundColor Yellow
|
|
try {
|
|
$buildArgs = @("build", $hostProjectFile, "--configuration", "Debug")
|
|
if ($Rebuild) {
|
|
$buildArgs += "--no-incremental"
|
|
}
|
|
$buildProcess = Start-Process -FilePath "dotnet" -ArgumentList $buildArgs -WorkingDirectory $hostProjectPath -Wait -PassThru -NoNewWindow
|
|
if ($buildProcess.ExitCode -ne 0) {
|
|
Write-Host "ERROR: Build failed, exit code: $($buildProcess.ExitCode)" -ForegroundColor Red
|
|
exit $buildProcess.ExitCode
|
|
}
|
|
Write-Host "Build succeeded" -ForegroundColor Green
|
|
} catch {
|
|
Write-Host "ERROR: Build failed: $_" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
} else {
|
|
Write-Host "OK: Found compiled executable, skipping build" -ForegroundColor Green
|
|
}
|
|
|
|
Write-Host "Starting service..." -ForegroundColor Green
|
|
Write-Host ""
|
|
|
|
try {
|
|
foreach ($key in $envSettings.Keys) {
|
|
[Environment]::SetEnvironmentVariable($key, $envSettings[$key])
|
|
}
|
|
[Environment]::SetEnvironmentVariable("ASPNETCORE_URLS", $appUrl)
|
|
$hostProcess = Start-Process -FilePath $hostExe -WorkingDirectory $outputDir -PassThru
|
|
|
|
Write-Host "OK: Hua.Todo.Host started" -ForegroundColor Green
|
|
Write-Host " Process ID: ($($hostProcess.Id))" -ForegroundColor Gray
|
|
Write-Host ""
|
|
Write-Host "API Address:" -ForegroundColor Yellow
|
|
Write-Host " $appUrl" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
Write-Host "Tips:" -ForegroundColor Yellow
|
|
Write-Host " - Use -Force to restart" -ForegroundColor Gray
|
|
Write-Host " - Use -Rebuild to force full rebuild" -ForegroundColor Gray
|
|
Write-Host ""
|
|
} catch {
|
|
Write-Host "ERROR: Failed to start: $_" -ForegroundColor Red
|
|
exit 1
|
|
} |