Initial commit: snapAna 截图智能整理工具
包含 FastAPI 后端、React 前端、队列/OCR/标签/待办等完整功能。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
# snapAna 一键启动脚本(PowerShell)
|
||||
# 同时启动后端 (uvicorn @ 8765) 与前端 (vite @ 5173)
|
||||
# 使用方式:在仓库根目录运行 .\start-dev.ps1
|
||||
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[switch]$InstallDeps # 传入此参数会重新安装依赖
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$root = Split-Path -Parent $MyInvocation.MyCommand.Definition
|
||||
$backend = Join-Path $root "backend"
|
||||
$frontend = Join-Path $root "frontend"
|
||||
|
||||
Write-Host "[snapAna] root = $root"
|
||||
|
||||
# 1. 后端虚拟环境
|
||||
if (!(Test-Path (Join-Path $backend ".venv"))) {
|
||||
Write-Host "[snapAna] 创建 Python 虚拟环境..."
|
||||
& python -m venv (Join-Path $backend ".venv")
|
||||
}
|
||||
$venvPython = Join-Path $backend ".venv\Scripts\python.exe"
|
||||
|
||||
if ($InstallDeps -or !(Test-Path (Join-Path $backend ".venv\Lib\site-packages\fastapi"))) {
|
||||
Write-Host "[snapAna] 安装后端依赖..."
|
||||
& $venvPython -m pip install --upgrade pip
|
||||
& $venvPython -m pip install -r (Join-Path $backend "requirements.txt")
|
||||
}
|
||||
|
||||
# 2. 前端依赖
|
||||
if ($InstallDeps -or !(Test-Path (Join-Path $frontend "node_modules"))) {
|
||||
Write-Host "[snapAna] 安装前端依赖..."
|
||||
Push-Location $frontend
|
||||
npm install
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
# 3. 后台启动后端
|
||||
Write-Host "[snapAna] 启动后端 http://127.0.0.1:8765 ..."
|
||||
$backendProc = Start-Process -FilePath $venvPython `
|
||||
-ArgumentList "run.py" `
|
||||
-WorkingDirectory $backend `
|
||||
-PassThru `
|
||||
-WindowStyle Normal
|
||||
|
||||
# 4. 启动前端(占用当前控制台,便于查看日志)
|
||||
Write-Host "[snapAna] 启动前端 http://127.0.0.1:5173 ..."
|
||||
Push-Location $frontend
|
||||
try {
|
||||
npm run dev
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
Write-Host "[snapAna] 关闭后端 (PID $($backendProc.Id))..."
|
||||
Stop-Process -Id $backendProc.Id -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
Reference in New Issue
Block a user