新功能: - 创建AI聊天助手组件(AIChatWidget) - 支持文字+图片多模态对话 - 集成Gemini AI API - 支持图片编辑和内容生成 - 实时对话历史管理 - 优雅的UI设计,支持黑夜模式 技术实现: - 后端API代理Gemini API(/api/ai-chat) - 支持最多5张图片上传 - 流式响应处理 - 对话历史管理 - Base64图片处理 配置: - 在.env中添加Gemini API配置 - GEMINI_API_KEY - GEMINI_API_BASE_URL - GEMINI_MODEL 替换原弹幕功能,提供更强大的AI助手体验!
70 lines
2.2 KiB
Bash
Executable File
70 lines
2.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# 检测操作系统
|
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
# macOS
|
|
echo "检测到 macOS 系统"
|
|
|
|
# 检查 Homebrew 是否安装
|
|
if ! command -v brew &> /dev/null; then
|
|
echo "Homebrew 未安装,正在安装..."
|
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
|
fi
|
|
|
|
# 检查 MongoDB 是否安装
|
|
if ! brew list mongodb-community &> /dev/null; then
|
|
echo "MongoDB 未安装,正在安装..."
|
|
brew tap mongodb/brew
|
|
brew install mongodb-community
|
|
fi
|
|
|
|
# 启动 MongoDB
|
|
echo "启动 MongoDB 服务..."
|
|
brew services start mongodb-community
|
|
|
|
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
|
# Linux
|
|
echo "检测到 Linux 系统"
|
|
|
|
# 检查 MongoDB 是否安装
|
|
if ! command -v mongod &> /dev/null; then
|
|
echo "MongoDB 未安装,正在安装..."
|
|
|
|
# 添加 MongoDB 仓库
|
|
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
|
|
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
|
|
|
|
# 更新包列表并安装 MongoDB
|
|
sudo apt-get update
|
|
sudo apt-get install -y mongodb-org
|
|
fi
|
|
|
|
# 启动 MongoDB
|
|
echo "启动 MongoDB 服务..."
|
|
sudo systemctl start mongod
|
|
|
|
else
|
|
# 其他操作系统
|
|
echo "不支持的操作系统: $OSTYPE"
|
|
echo "请手动安装 MongoDB: https://docs.mongodb.com/manual/installation/"
|
|
exit 1
|
|
fi
|
|
|
|
# 等待 MongoDB 启动
|
|
echo "等待 MongoDB 启动..."
|
|
sleep 5
|
|
|
|
# 检查 MongoDB 是否正在运行
|
|
if mongo --eval "db.version()" &> /dev/null; then
|
|
echo "✅ MongoDB 已成功启动!"
|
|
echo "MongoDB 版本: $(mongo --eval "db.version()" --quiet)"
|
|
echo "数据库连接 URL: mongodb://localhost:27017/image-tool"
|
|
else
|
|
echo "❌ MongoDB 启动失败,请检查错误信息并手动启动。"
|
|
fi
|
|
|
|
# 创建数据库和集合
|
|
echo "创建数据库和集合..."
|
|
mongo --eval "use image-tool; db.createCollection('users'); db.createCollection('settings'); db.createCollection('logs');"
|
|
|
|
echo "MongoDB 设置完成!" |