@echo off chcp 65001 >nul setlocal set "PROJECT_DIR=%~dp0" set "RUN_DIR=%PROJECT_DIR%.run" set "PID_FILE=%RUN_DIR%\spine-connector-windows.pid" set "OUT_LOG=%RUN_DIR%\spine-connector-windows.log" set "ERROR_LOG=%RUN_DIR%\spine-connector-windows-error.log" if not exist "%RUN_DIR%" mkdir "%RUN_DIR%" cd /d "%PROJECT_DIR%" if exist "%PID_FILE%" ( set /p CONNECTOR_PID=<"%PID_FILE%" powershell -NoProfile -Command "if (Get-Process -Id $env:CONNECTOR_PID -ErrorAction SilentlyContinue) { exit 0 } else { exit 1 }" if not errorlevel 1 ( echo Spine粒子连接器已经在运行。 exit /b 0 ) del /q "%PID_FILE%" >nul 2>&1 ) where node >nul 2>&1 if errorlevel 1 ( echo 未找到 Node.js,请先安装 Node.js 18 或更高版本。 pause exit /b 1 ) echo 正在启动 Spine粒子连接器... powershell -NoProfile -Command ^ "$node=(Get-Command node).Source; $entry=Join-Path $env:PROJECT_DIR 'connector\spine-connector.mjs';" ^ "$process=Start-Process -FilePath $node -ArgumentList @($entry) -WorkingDirectory $env:PROJECT_DIR -RedirectStandardOutput $env:OUT_LOG -RedirectStandardError $env:ERROR_LOG -WindowStyle Hidden -PassThru;" ^ "Set-Content -Path $env:PID_FILE -Value $process.Id -Encoding ascii" if errorlevel 1 ( echo 连接器启动失败。 pause exit /b 1 ) timeout /t 2 /nobreak >nul echo Spine粒子连接器已启动,可以回到网页直接导出 .spine。 exit /b 0