一键启动停止项目
This commit is contained in:
@@ -15,6 +15,7 @@ vite.config.d.ts
|
||||
.vite/
|
||||
.cache/
|
||||
coverage/
|
||||
/.run/
|
||||
# Logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Vendored
+2
-2
@@ -8,8 +8,8 @@
|
||||
html, body { margin: 0; padding: 0; background: #111; color: #eee; font-family: system-ui, -apple-system, sans-serif; }
|
||||
#app { display: flex; flex-direction: column; height: 100vh; }
|
||||
</style>
|
||||
<script type="module" crossorigin src="/assets/index-DujVfZi9.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-nUMfzhFe.css">
|
||||
<script type="module" crossorigin src="/assets/index-CnGkEkb-.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-CSwdbBmn.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
@@ -132,7 +132,7 @@ export const useParticleStore = defineStore('particle', {
|
||||
// 与 Spine 编辑器默认时间基准对齐:1 秒 = 30 帧。
|
||||
timeline: { playing: true, loop: true, frame: 0, totalFrames: 60, fps: 30, recorded: false, animation: 'animation', animations: ['animation'] } as TimelineState,
|
||||
settings: {
|
||||
parameterPanelOnRight: false,
|
||||
parameterPanelOnRight: true,
|
||||
tickEnabled: false,
|
||||
axisFontSize: 12,
|
||||
tickWidth: 1,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="panel">
|
||||
<div class="panel-header">
|
||||
<span>Spine粒子编辑器</span>
|
||||
<span>Spine粒子编辑器-Yeomai</span>
|
||||
</div>
|
||||
|
||||
<div class="panel-scroll">
|
||||
|
||||
+1
-1
@@ -209,7 +209,7 @@ const canvasFocused = ref(false)
|
||||
function toggleTool(t: '' | 'translate' | 'rotate' | 'scale') { activeTool.value = activeTool.value === t ? '' : t }
|
||||
|
||||
if (!(store.settings.undoLimit > 0)) store.settings.undoLimit = 20
|
||||
if (store.settings.parameterPanelOnRight == null) store.settings.parameterPanelOnRight = false
|
||||
if (store.settings.parameterPanelOnRight == null) store.settings.parameterPanelOnRight = true
|
||||
if (!Number.isFinite(store.settings.backgroundX)) store.settings.backgroundX = 0
|
||||
if (!Number.isFinite(store.settings.backgroundY)) store.settings.backgroundY = 0
|
||||
if (!Number.isFinite(store.settings.backgroundOpacity)) store.settings.backgroundOpacity = 1
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
setlocal
|
||||
|
||||
set "PROJECT_DIR=%~dp0"
|
||||
set "RUN_DIR=%PROJECT_DIR%.run"
|
||||
set "PID_FILE=%RUN_DIR%\spine-particle-windows.pid"
|
||||
|
||||
cd /d "%PROJECT_DIR%"
|
||||
|
||||
if not exist "%PID_FILE%" (
|
||||
echo 没有发现由“启动项目-Windows.bat”启动的项目进程。
|
||||
exit /b 0
|
||||
)
|
||||
|
||||
set /p SERVER_PID=<"%PID_FILE%"
|
||||
powershell -NoProfile -Command ^
|
||||
"$process=Get-CimInstance Win32_Process -Filter ('ProcessId = ' + $env:SERVER_PID) -ErrorAction SilentlyContinue;" ^
|
||||
"if ($null -eq $process) { exit 2 };" ^
|
||||
"$expected=(Join-Path $env:PROJECT_DIR 'node_modules\vite\bin\vite.js');" ^
|
||||
"if ($process.CommandLine -notlike ('*' + $expected + '*')) { exit 3 };" ^
|
||||
"Stop-Process -Id ([int]$env:SERVER_PID) -Force; exit 0"
|
||||
|
||||
set "STOP_RESULT=%ERRORLEVEL%"
|
||||
if "%STOP_RESULT%"=="3" (
|
||||
echo PID 已被其他程序占用,为避免误关进程,本次未执行停止操作。
|
||||
del /q "%PID_FILE%" >nul 2>&1
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
del /q "%PID_FILE%" >nul 2>&1
|
||||
if "%STOP_RESULT%"=="2" (
|
||||
echo 项目已经停止。
|
||||
) else if "%STOP_RESULT%"=="0" (
|
||||
echo 项目已停止。
|
||||
) else (
|
||||
echo 停止项目失败,请检查 PowerShell 权限。
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
exit /b 0
|
||||
Executable
+46
@@ -0,0 +1,46 @@
|
||||
#!/bin/zsh
|
||||
|
||||
set -u
|
||||
|
||||
PROJECT_DIR="${0:A:h}"
|
||||
RUN_DIR="$PROJECT_DIR/.run"
|
||||
PID_FILE="$RUN_DIR/spine-particle.pid"
|
||||
|
||||
cd "$PROJECT_DIR" || exit 1
|
||||
|
||||
if [[ ! -f "$PID_FILE" ]]; then
|
||||
echo "没有发现由“启动项目.command”启动的项目进程。"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
SERVER_PID="$(tr -dc '0-9' < "$PID_FILE")"
|
||||
if [[ -z "$SERVER_PID" ]] || ! kill -0 "$SERVER_PID" 2>/dev/null; then
|
||||
rm -f "$PID_FILE"
|
||||
echo "项目已经停止。"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
SERVER_COMMAND="$(ps -p "$SERVER_PID" -o command= 2>/dev/null || true)"
|
||||
if [[ "$SERVER_COMMAND" != *"$PROJECT_DIR/node_modules/vite/"* ]]; then
|
||||
echo "PID 已被其他程序占用,为避免误关进程,本次未执行停止操作。"
|
||||
echo "当前进程:$SERVER_COMMAND"
|
||||
rm -f "$PID_FILE"
|
||||
read "?按回车键关闭窗口..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "正在停止 Spine粒子编辑器..."
|
||||
kill "$SERVER_PID" 2>/dev/null || true
|
||||
for _ in {1..20}; do
|
||||
if ! kill -0 "$SERVER_PID" 2>/dev/null; then
|
||||
rm -f "$PID_FILE"
|
||||
echo "项目已停止。"
|
||||
exit 0
|
||||
fi
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
echo "普通停止未响应,正在强制结束该项目进程..."
|
||||
kill -KILL "$SERVER_PID" 2>/dev/null || true
|
||||
rm -f "$PID_FILE"
|
||||
echo "项目已停止。"
|
||||
@@ -0,0 +1,71 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
setlocal
|
||||
|
||||
set "PROJECT_DIR=%~dp0"
|
||||
set "RUN_DIR=%PROJECT_DIR%.run"
|
||||
set "PID_FILE=%RUN_DIR%\spine-particle-windows.pid"
|
||||
set "OUT_LOG=%RUN_DIR%\spine-particle-windows.log"
|
||||
set "ERROR_LOG=%RUN_DIR%\spine-particle-windows-error.log"
|
||||
set "PROJECT_URL=http://127.0.0.1:5173/"
|
||||
|
||||
if not exist "%RUN_DIR%" mkdir "%RUN_DIR%"
|
||||
cd /d "%PROJECT_DIR%"
|
||||
|
||||
if exist "%PID_FILE%" (
|
||||
set /p SERVER_PID=<"%PID_FILE%"
|
||||
powershell -NoProfile -Command "if (Get-Process -Id $env:SERVER_PID -ErrorAction SilentlyContinue) { exit 0 } else { exit 1 }"
|
||||
if not errorlevel 1 (
|
||||
echo Spine粒子编辑器已经在运行,正在打开页面:
|
||||
echo %PROJECT_URL%
|
||||
start "" "%PROJECT_URL%"
|
||||
exit /b 0
|
||||
)
|
||||
del /q "%PID_FILE%" >nul 2>&1
|
||||
)
|
||||
|
||||
where npm >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo 未找到 npm,请先安装 Node.js:
|
||||
echo https://nodejs.org/
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if not exist "%PROJECT_DIR%node_modules\vite\bin\vite.js" (
|
||||
echo 首次运行,正在安装项目依赖...
|
||||
call npm install
|
||||
if errorlevel 1 (
|
||||
echo 依赖安装失败,请检查网络或 npm 配置。
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
echo 正在启动 Spine粒子编辑器...
|
||||
powershell -NoProfile -Command ^
|
||||
"$node=(Get-Command node).Source; $vite=Join-Path $env:PROJECT_DIR 'node_modules\vite\bin\vite.js';" ^
|
||||
"$arguments=@($vite,'--host','127.0.0.1','--port','5173','--strictPort');" ^
|
||||
"$process=Start-Process -FilePath $node -ArgumentList $arguments -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
|
||||
)
|
||||
|
||||
set /p SERVER_PID=<"%PID_FILE%"
|
||||
timeout /t 2 /nobreak >nul
|
||||
powershell -NoProfile -Command "if (Get-Process -Id $env:SERVER_PID -ErrorAction SilentlyContinue) { exit 0 } else { exit 1 }"
|
||||
if errorlevel 1 (
|
||||
echo 项目启动失败,错误日志如下:
|
||||
if exist "%ERROR_LOG%" type "%ERROR_LOG%"
|
||||
del /q "%PID_FILE%" >nul 2>&1
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo 启动成功:%PROJECT_URL%
|
||||
start "" "%PROJECT_URL%"
|
||||
exit /b 0
|
||||
Executable
+64
@@ -0,0 +1,64 @@
|
||||
#!/bin/zsh
|
||||
|
||||
set -u
|
||||
|
||||
PROJECT_DIR="${0:A:h}"
|
||||
RUN_DIR="$PROJECT_DIR/.run"
|
||||
PID_FILE="$RUN_DIR/spine-particle.pid"
|
||||
LOG_FILE="$RUN_DIR/spine-particle.log"
|
||||
URL="http://127.0.0.1:5173/"
|
||||
|
||||
mkdir -p "$RUN_DIR"
|
||||
cd "$PROJECT_DIR" || exit 1
|
||||
|
||||
if [[ -f "$PID_FILE" ]]; then
|
||||
RUNNING_PID="$(tr -dc '0-9' < "$PID_FILE")"
|
||||
if [[ -n "$RUNNING_PID" ]] && kill -0 "$RUNNING_PID" 2>/dev/null; then
|
||||
echo "Spine粒子编辑器已经在运行,正在打开页面:"
|
||||
echo "$URL"
|
||||
open "$URL"
|
||||
exit 0
|
||||
fi
|
||||
rm -f "$PID_FILE"
|
||||
fi
|
||||
|
||||
if ! command -v npm >/dev/null 2>&1; then
|
||||
echo "未找到 npm,请先安装 Node.js。"
|
||||
echo "https://nodejs.org/"
|
||||
read "?按回车键关闭窗口..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -x "$PROJECT_DIR/node_modules/.bin/vite" ]]; then
|
||||
echo "首次运行,正在安装项目依赖..."
|
||||
npm install || {
|
||||
echo "依赖安装失败,请检查网络或 npm 配置。"
|
||||
read "?按回车键关闭窗口..."
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
|
||||
echo "正在启动 Spine粒子编辑器..."
|
||||
nohup "$PROJECT_DIR/node_modules/.bin/vite" --host 127.0.0.1 --port 5173 --strictPort > "$LOG_FILE" 2>&1 &
|
||||
SERVER_PID=$!
|
||||
echo "$SERVER_PID" > "$PID_FILE"
|
||||
|
||||
for _ in {1..60}; do
|
||||
if ! kill -0 "$SERVER_PID" 2>/dev/null; then
|
||||
echo "项目启动失败,日志如下:"
|
||||
tail -n 30 "$LOG_FILE"
|
||||
rm -f "$PID_FILE"
|
||||
read "?按回车键关闭窗口..."
|
||||
exit 1
|
||||
fi
|
||||
if curl -fsS "$URL" >/dev/null 2>&1; then
|
||||
echo "启动成功:$URL"
|
||||
open "$URL"
|
||||
exit 0
|
||||
fi
|
||||
sleep 0.25
|
||||
done
|
||||
|
||||
echo "项目启动超时,请查看日志:$LOG_FILE"
|
||||
read "?按回车键关闭窗口..."
|
||||
exit 1
|
||||
Reference in New Issue
Block a user