# 快速启动脚本 - 智能修复 PATH 并启动应用

Write-Host "🚀 快速启动脚本" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan

# 智能修复 PATH
if ($env:PATH -like "*C:;Users*" -or $env:PATH -like "*;%S;stemRoot%*") {
    Write-Host "🔧 检测到 PATH 格式错误，正在修复..." -ForegroundColor Yellow
    $env:PATH = $env:PATH.Replace('C:;Users', 'C:\Users').Replace(';%S;stemRoot%', ';%SystemRoot%')
    Write-Host "✅ PATH 修复完成" -ForegroundColor Green
}

# 切换到项目目录
Set-Location "d:\HuaweiMoveData\Users\马艺洁\Desktop\MLwork\bigwork"

# 智能选择运行方式
Write-Host "🔍 检查 UV 命令可用性..." -ForegroundColor Cyan
$uvAvailable = $false
try {
    $uvVersion = uv --version 2>$null
    if ($LASTEXITCODE -eq 0) {
        $uvAvailable = $true
        Write-Host "✅ UV 命令可用: $uvVersion" -ForegroundColor Green
    }
} catch {
    Write-Host "⚠️ UV 命令不可用，将使用 python -m uv" -ForegroundColor Yellow
}

# 启动应用
if ($uvAvailable) {
    Write-Host "🚀 使用 UV 启动 Streamlit 应用..." -ForegroundColor Green
    uv run streamlit run src/streamlit_app.py
} else {
    Write-Host "🚀 使用 python -m uv 启动 Streamlit 应用..." -ForegroundColor Green
    python -m uv run streamlit run src/streamlit_app.py
}