feat: 自动提交 - 周一 2025/09/22 15:12:38.91

This commit is contained in:
赵杰
2025-09-22 15:12:38 +01:00
parent 9306e7a401
commit b635c9e7d4
41 changed files with 7360 additions and 950 deletions

133
install_dependencies.sh Normal file
View File

@@ -0,0 +1,133 @@
#!/bin/bash
echo "TSP智能助手依赖安装脚本"
echo "=========================="
echo
# 检测操作系统
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
OS="linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
OS="macos"
else
OS="unknown"
fi
echo "检测到操作系统: $OS"
echo
# 安装Node.js和npm
install_nodejs() {
echo "安装Node.js和npm..."
if command -v node &> /dev/null; then
echo "Node.js已安装: $(node --version)"
return 0
fi
case $OS in
"linux")
# Ubuntu/Debian
if command -v apt &> /dev/null; then
echo "使用apt安装Node.js..."
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
# CentOS/RHEL
elif command -v yum &> /dev/null; then
echo "使用yum安装Node.js..."
curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -
sudo yum install -y nodejs
# Arch Linux
elif command -v pacman &> /dev/null; then
echo "使用pacman安装Node.js..."
sudo pacman -S nodejs npm
else
echo "请手动安装Node.js: https://nodejs.org/"
return 1
fi
;;
"macos")
if command -v brew &> /dev/null; then
echo "使用Homebrew安装Node.js..."
brew install node
else
echo "请安装Homebrew或手动安装Node.js: https://nodejs.org/"
return 1
fi
;;
*)
echo "请手动安装Node.js: https://nodejs.org/"
return 1
;;
esac
}
# 安装Python依赖
install_python_deps() {
echo "安装Python依赖..."
if [ -f "requirements.txt" ]; then
if command -v python3 &> /dev/null; then
python3 -m pip install -r requirements.txt
elif command -v python &> /dev/null; then
python -m pip install -r requirements.txt
else
echo "警告: 未找到Python"
fi
else
echo "警告: 未找到requirements.txt文件"
fi
}
# 安装前端依赖
install_frontend_deps() {
echo "安装前端依赖..."
if [ -d "frontend" ]; then
cd frontend
if [ -f "package.json" ]; then
npm install
else
echo "警告: 未找到package.json文件"
fi
cd ..
else
echo "警告: 未找到frontend目录"
fi
}
# 主安装流程
main() {
echo "开始安装依赖..."
echo
# 安装Node.js
install_nodejs
if [ $? -eq 0 ]; then
echo "Node.js安装成功: $(node --version)"
echo "npm版本: $(npm --version)"
else
echo "Node.js安装失败请手动安装"
fi
echo
# 安装Python依赖
install_python_deps
echo
# 安装前端依赖
install_frontend_deps
echo
echo "依赖安装完成!"
echo
echo "使用方法:"
echo " 启动传统版本: ./start_traditional.sh"
echo " 启动前端开发: ./start_frontend.sh"
echo " 构建前端: ./build_frontend.sh"
}
# 执行主函数
main