mirror of
https://github.com/handsomezhuzhu/QQuiz.git
synced 2026-02-20 20:10:14 +00:00
feat: 实现数据库驱动的API配置管理和项目结构重组
## 新功能 - 实现管理后台API配置管理(OpenAI/Anthropic/Qwen) - API配置保存到数据库,实时生效无需重启 - API密钥遮罩显示(前10位+后4位) - 完整endpoint URL自动显示 ## 后端改进 - 新增 config_service.py 用于加载数据库配置 - LLMService 支持动态配置注入,回退到环境变量 - 更新 exam.py 和 question.py 使用数据库配置 - 扩展 schemas.py 支持所有API配置字段 ## 前端改进 - 重写 AdminSettings.jsx 增强UI体验 - API密钥显示/隐藏切换 - 当前使用的提供商可视化标识 - 移除"需要重启"的误导性提示 ## 项目结构重组 - 移动所有脚本到 scripts/ 目录 - 移动所有文档到 docs/ 目录 - 清理 Python 缓存文件 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
88
scripts/run_local.sh
Normal file
88
scripts/run_local.sh
Normal file
@@ -0,0 +1,88 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "===== QQuiz Local Deployment Script ====="
|
||||
|
||||
# Check if .env exists
|
||||
if [ ! -f .env ]; then
|
||||
echo "Error: .env file not found!"
|
||||
echo "Please copy .env.example to .env and configure it."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Load environment variables
|
||||
export $(grep -v '^#' .env | xargs)
|
||||
|
||||
# Check Python version
|
||||
PYTHON_VERSION=$(python3 --version 2>&1 | awk '{print $2}')
|
||||
echo "Python version: $PYTHON_VERSION"
|
||||
|
||||
# Check if PostgreSQL is running
|
||||
echo "Checking PostgreSQL connection..."
|
||||
if ! pg_isready -h localhost -p 5432 &> /dev/null; then
|
||||
echo "Warning: PostgreSQL is not running on localhost:5432"
|
||||
echo "Please start PostgreSQL or use Docker: docker-compose up -d postgres"
|
||||
read -p "Continue anyway? (y/n) " -n 1 -r
|
||||
echo
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Install backend dependencies
|
||||
echo "Installing backend dependencies..."
|
||||
cd backend
|
||||
if [ ! -d "venv" ]; then
|
||||
echo "Creating virtual environment..."
|
||||
python3 -m venv venv
|
||||
fi
|
||||
|
||||
source venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
|
||||
# Run database migrations
|
||||
echo "Running database migrations..."
|
||||
alembic upgrade head || echo "Warning: Alembic migration failed. Database might not be initialized."
|
||||
|
||||
# Create uploads directory
|
||||
mkdir -p uploads
|
||||
|
||||
# Start backend
|
||||
echo "Starting backend on http://localhost:8000..."
|
||||
uvicorn main:app --host 0.0.0.0 --port 8000 --reload &
|
||||
BACKEND_PID=$!
|
||||
|
||||
cd ../frontend
|
||||
|
||||
# Install frontend dependencies
|
||||
echo "Installing frontend dependencies..."
|
||||
if [ ! -d "node_modules" ]; then
|
||||
npm install
|
||||
fi
|
||||
|
||||
# Start frontend
|
||||
echo "Starting frontend on http://localhost:3000..."
|
||||
npm start &
|
||||
FRONTEND_PID=$!
|
||||
|
||||
echo ""
|
||||
echo "===== QQuiz is running! ====="
|
||||
echo "Backend: http://localhost:8000"
|
||||
echo "Frontend: http://localhost:3000"
|
||||
echo "API Docs: http://localhost:8000/docs"
|
||||
echo ""
|
||||
echo "Press Ctrl+C to stop all services"
|
||||
|
||||
# Handle cleanup on exit
|
||||
cleanup() {
|
||||
echo ""
|
||||
echo "Stopping services..."
|
||||
kill $BACKEND_PID $FRONTEND_PID 2>/dev/null
|
||||
exit 0
|
||||
}
|
||||
|
||||
trap cleanup SIGINT SIGTERM
|
||||
|
||||
# Wait for processes
|
||||
wait
|
||||
Reference in New Issue
Block a user