# PowerShell 启动脚本
# 飞球 ETL 管理系统

$ErrorActionPreference = "Stop"
$OutputEncoding = [System.Text.Encoding]::UTF8

Write-Host "===================================="
Write-Host "   飞球 ETL 管理系统"
Write-Host "===================================="
Write-Host ""

# 切换到脚本目录
Set-Location $PSScriptRoot

# 检查 Python
try {
    $pythonVersion = python --version 2>&1
    Write-Host "Python 版本: $pythonVersion"
} catch {
    Write-Host "[错误] 未找到 Python，请先安装 Python 3.10+" -ForegroundColor Red
    Read-Host "按回车键退出"
    exit 1
}

# 检查 PySide6
$hasPySide6 = python -c "import PySide6" 2>&1
if ($LASTEXITCODE -ne 0) {
    Write-Host "[提示] 正在安装 GUI 依赖..." -ForegroundColor Yellow
    pip install PySide6
}

# 启动 GUI
Write-Host ""
Write-Host "正在启动 GUI..." -ForegroundColor Cyan
python -m gui.main

if ($LASTEXITCODE -ne 0) {
    Write-Host ""
    Write-Host "[错误] 启动失败" -ForegroundColor Red
    Write-Host "请运行: pip install -r requirements.txt"
    Read-Host "按回车键退出"
}
