chore: initial commit

This commit is contained in:
hailin
2026-05-18 13:52:47 +08:00
commit 0753129afe
148 changed files with 14202 additions and 0 deletions

67
start.sh Executable file
View File

@@ -0,0 +1,67 @@
#!/bin/bash
echo "=== 启动报告生成应用 ==="
# 清理旧进程
echo "清理旧进程..."
for port in 3002 5173; do
pid=$(lsof -t -i:$port 2>/dev/null)
if [ -n "$pid" ]; then
echo " 关闭端口 $port 上的进程 (PID: $pid)"
kill $pid 2>/dev/null
sleep 1
kill -0 $pid 2>/dev/null && kill -9 $pid 2>/dev/null
fi
done
sleep 1
# 检查服务器依赖
echo "检查服务器依赖..."
cd server
if [ ! -d "node_modules" ]; then
echo "安装服务器依赖..."
npm install
fi
cd ..
# 检查前端依赖
echo "检查前端依赖..."
if [ ! -d "node_modules" ]; then
echo "安装前端依赖..."
npm install
fi
# 启动 PDF 生成服务器
echo "启动 PDF 生成服务器 (端口: 3002)..."
cd server
TARGET_URL=http://localhost:5173 nohup node src/index.js > server.log 2>&1 &
SERVER_PID=$!
cd ..
# 等待服务器就绪
echo "等待服务器启动..."
for i in $(seq 1 10); do
if curl -s http://localhost:3002 > /dev/null 2>&1 || lsof -t -i:3002 > /dev/null 2>&1; then
echo "服务器已启动http://localhost:3002"
break
fi
if [ $i -eq 10 ]; then
echo "错误:服务器启动失败!查看 server/server.log"
kill $SERVER_PID 2>/dev/null
exit 1
fi
sleep 1
done
# 启动前端开发服务器
echo "启动前端开发服务器 (端口: 5173)..."
echo ""
echo "前端访问地址http://localhost:5173"
echo "PDF 服务器地址http://localhost:3002"
echo ""
echo "按 Ctrl+C 停止所有服务"
# 确保 Ctrl+C 能同时停止两个进程
trap "echo '停止服务...'; kill $SERVER_PID 2>/dev/null; exit" INT TERM
npm run dev