Claw 项目完整结构提交

This commit is contained in:
zqm
2026-03-16 15:47:55 +08:00
parent ca4970bcbf
commit fb0aeb6ca2
118 changed files with 28648 additions and 281 deletions

106
Claw/scripts/build.bat Normal file
View File

@@ -0,0 +1,106 @@
@echo off
REM Claw项目构建脚本Windows版
REM 用于验证项目结构和依赖
echo 🦞 开始构建 Claw 项目...
REM 检查Rust环境
where cargo >nul 2>nul
if %errorlevel% neq 0 (
echo ❌ 未找到Cargo请先安装Rust
exit /b 1
)
echo ✅ Rust环境检查通过
REM 构建共享库
echo 📦 构建共享库...
cd Server\shared
cargo check
if %errorlevel% neq 0 (
echo ❌ 共享库构建失败
exit /b 1
)
cd ..\..
echo ✅ 共享库构建成功
REM 构建网关服务
echo 🚪 构建网关服务...
cd Server\gateway
cargo check
if %errorlevel% neq 0 (
echo ❌ 网关服务构建失败
exit /b 1
)
cd ..\..
echo ✅ 网关服务构建成功
REM 构建SmartClaw服务
echo 🤖 构建SmartClaw服务...
cd Server\SmartClaw
cargo check
if %errorlevel% neq 0 (
echo ❌ SmartClaw服务构建失败
exit /b 1
)
cd ..\..
echo ✅ SmartClaw服务构建成功
REM 检查微信小程序结构
echo 📱 检查微信小程序结构...
if not exist "client\wechat_app" (
echo ❌ 微信小程序目录不存在
exit /b 1
)
REM 检查必要文件
set "required_files=client\wechat_app\app.json client\wechat_app\app.js client\wechat_app\app.wxss client\wechat_app\project.config.json client\wechat_app\sitemap.json"
for %%f in (%required_files%) do (
if not exist "%%f" (
echo ❌ 缺少必要文件: %%f
exit /b 1
)
)
echo ✅ 微信小程序结构检查通过
REM 检查企业微信网页应用
echo 🌐 检查企业微信网页应用...
if not exist "client\web\index.html" (
echo ❌ 企业微信网页应用不存在
exit /b 1
)
echo ✅ 企业微信网页应用检查通过
echo.
echo 🎉 项目构建验证完成!
echo.
echo 📋 项目结构概览:
echo ├── Server/
echo │ ├── gateway/ # 网关服务服务器A
echo │ ├── SmartClaw/ # 智能控制服务服务器B
echo │ └── shared/ # 共享代码库
echo ├── client/
echo │ ├── wechat_app/ # 微信小程序(官方原生)
echo │ │ ├── pages/ # 页面目录
echo │ │ ├── utils/ # 工具函数
echo │ │ ├── components/ # 自定义组件
echo │ │ └── assets/ # 静态资源
echo │ └── web/ # 企业微信网页应用
echo ├── docs/ # 项目文档
echo ├── scripts/ # 构建脚本
echo └── build/ # 构建产物
echo.
echo 🚀 技术栈:
echo • 后端Rust + Actix Web + Embedded-Redis + HeedDB
echo • 前端WXML + WXSS + JavaScript微信小程序原生
echo • 通信WebSocket反向连接 + HTTPS
echo • 数据库HeedDB嵌入式+ Embedded-Redis
echo.
echo ✨ 项目已准备就绪,可以开始开发!
pause

111
Claw/scripts/build.sh Normal file
View File

@@ -0,0 +1,111 @@
#!/bin/bash
# Claw项目构建脚本
# 用于验证项目结构和依赖
echo "🦞 开始构建 Claw 项目..."
# 检查Rust环境
if ! command -v cargo &> /dev/null; then
echo "❌ 未找到Cargo请先安装Rust"
exit 1
fi
echo "✅ Rust环境检查通过"
# 构建共享库
echo "📦 构建共享库..."
cd Server/shared
cargo check
if [ $? -ne 0 ]; then
echo "❌ 共享库构建失败"
exit 1
fi
cd ../..
echo "✅ 共享库构建成功"
# 构建网关服务
echo "🚪 构建网关服务..."
cd Server/gateway
cargo check
if [ $? -ne 0 ]; then
echo "❌ 网关服务构建失败"
exit 1
fi
cd ../..
echo "✅ 网关服务构建成功"
# 构建SmartClaw服务
echo "🤖 构建SmartClaw服务..."
cd Server/SmartClaw
cargo check
if [ $? -ne 0 ]; then
echo "❌ SmartClaw服务构建失败"
exit 1
fi
cd ../..
echo "✅ SmartClaw服务构建成功"
# 检查微信小程序结构
echo "📱 检查微信小程序结构..."
if [ ! -d "client/wechat_app" ]; then
echo "❌ 微信小程序目录不存在"
exit 1
fi
# 检查必要文件
required_files=(
"client/wechat_app/app.json"
"client/wechat_app/app.js"
"client/wechat_app/app.wxss"
"client/wechat_app/project.config.json"
"client/wechat_app/sitemap.json"
)
for file in "${required_files[@]}"; do
if [ ! -f "$file" ]; then
echo "❌ 缺少必要文件: $file"
exit 1
fi
done
echo "✅ 微信小程序结构检查通过"
# 检查企业微信网页应用
echo "🌐 检查企业微信网页应用..."
if [ ! -f "client/web/index.html" ]; then
echo "❌ 企业微信网页应用不存在"
exit 1
fi
echo "✅ 企业微信网页应用检查通过"
echo ""
echo "🎉 项目构建验证完成!"
echo ""
echo "📋 项目结构概览:"
echo "├── Server/"
echo "│ ├── gateway/ # 网关服务服务器A"
echo "│ ├── SmartClaw/ # 智能控制服务服务器B"
echo "│ └── shared/ # 共享代码库"
echo "├── client/"
echo "│ ├── wechat_app/ # 微信小程序(官方原生)"
echo "│ │ ├── pages/ # 页面目录"
echo "│ │ ├── utils/ # 工具函数"
echo "│ │ ├── components/ # 自定义组件"
echo "│ │ └── assets/ # 静态资源"
echo "│ └── web/ # 企业微信网页应用"
echo "├── docs/ # 项目文档"
echo "├── scripts/ # 构建脚本"
echo "└── build/ # 构建产物"
echo ""
echo "🚀 技术栈:"
echo "• 后端Rust + Actix Web + Embedded-Redis + HeedDB"
echo "• 前端WXML + WXSS + JavaScript微信小程序原生"
echo "• 通信WebSocket反向连接 + HTTPS"
echo "• 数据库HeedDB嵌入式+ Embedded-Redis"
echo ""
echo "✨ 项目已准备就绪,可以开始开发!"

View File

@@ -0,0 +1,207 @@
@echo off
echo 🚀 开始配置 Claw 项目 Nginx 和 WebSocket 环境...
echo 📅 配置时间: %date% %time%
REM 检查是否以管理员身份运行
net session >nul 2>&1
if %errorlevel% neq 0 (
echo ⚠️ 警告:请以管理员身份运行此脚本以获得最佳效果
pause
)
REM 设置配置参数
set NGINX_CONF_SOURCE=d:\Projects\trunk\JoyD\Claw\docs\nginx.conf
set NGINX_CONF_TARGET=C:\nginx\conf\nginx.conf
set NGINX_SSL_DIR=C:\nginx\ssl
set GATEWAY_URL=http://localhost:8000
echo 📋 配置参数:
echo Nginx 配置文件: %NGINX_CONF_SOURCE%
echo 目标配置文件: %NGINX_CONF_TARGET%
echo SSL 证书目录: %NGINX_SSL_DIR%
echo 网关服务地址: %GATEWAY_URL%
REM 检查 Nginx 是否已安装
where nginx >nul 2>&1
if %errorlevel% neq 0 (
echo ❌ 错误:未检测到 Nginx 安装
echo 📥 请先安装 Nginx 到 C:\nginx 目录
echo 🔗 下载地址: http://nginx.org/en/download.html
pause
exit /b 1
)
REM 备份现有配置
echo 💾 备份现有 Nginx 配置...
if exist "%NGINX_CONF_TARGET%" (
copy /Y "%NGINX_CONF_TARGET%" "%NGINX_CONF_TARGET%.backup.%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%%time:~6,2%"
echo ✅ 已备份现有配置
) else (
echo 未发现现有配置,跳过备份
)
REM 创建 SSL 目录
echo 📁 创建 SSL 证书目录...
if not exist "%NGINX_SSL_DIR%" mkdir "%NGINX_SSL_DIR%"
REM 检查 SSL 证书
echo 🔐 检查 SSL 证书...
if exist "%NGINX_SSL_DIR%\pactgo.cn-chain.pem" (
echo ✅ SSL 证书已存在
) else (
echo ⚠️ 警告:未找到 SSL 证书文件
echo 📄 请将证书文件复制到: %NGINX_SSL_DIR%
echo 📋 需要的文件:
echo - pactgo.cn-chain.pem (证书链)
echo - pactgo.cn-key.pem (私钥)
)
REM 复制 Nginx 配置
echo 📄 复制 Nginx 配置文件...
copy /Y "%NGINX_CONF_SOURCE%" "%NGINX_CONF_TARGET%"
if %errorlevel% neq 0 (
echo ❌ 错误:配置文件复制失败
pause
exit /b 1
)
REM 验证 Nginx 配置
echo 🔍 验证 Nginx 配置...
nginx -t
if %errorlevel% neq 0 (
echo ❌ 错误Nginx 配置验证失败
echo 🔧 请检查配置文件语法
pause
exit /b 1
)
echo ✅ Nginx 配置验证通过
REM 配置环境变量
echo 🔧 配置环境变量...
echo 📄 创建环境配置文件...
REM 为 Gateway 服务创建环境配置
echo # Gateway 服务环境配置 > "%~dp0..\Server\gateway\.env"
echo PORT=8000 >> "%~dp0..\Server\gateway\.env"
echo ENVIRONMENT=production >> "%~dp0..\Server\gateway\.env"
echo RUST_LOG=info >> "%~dp0..\Server\gateway\.env"
echo.
echo # WebSocket 配置 >> "%~dp0..\Server\gateway\.env"
echo WEBSOCKET_ENABLED=true >> "%~dp0..\Server\gateway\.env"
echo.
echo # 企业微信配置(请根据实际情况修改) >> "%~dp0..\Server\gateway\.env"
echo WECOM_CORP_ID=your_corp_id >> "%~dp0..\Server\gateway\.env"
echo WECOM_SECRET=your_secret >> "%~dp0..\Server\gateway\.env"
echo WECOM_AGENT_ID=your_agent_id >> "%~dp0..\Server\gateway\.env"
echo.
echo # Redis 配置 >> "%~dp0..\Server\gateway\.env"
echo REDIS_URL=redis://127.0.0.1:6379 >> "%~dp0..\Server\gateway\.env"
REM 为 SmartClaw 服务创建环境配置
echo # SmartClaw 服务环境配置 > "%~dp0..\Server\SmartClaw\.env"
echo PORT=3001 >> "%~dp0..\Server\SmartClaw\.env"
echo ENVIRONMENT=production >> "%~dp0..\Server\SmartClaw\.env"
echo RUST_LOG=info >> "%~dp0..\Server\SmartClaw\.env"
echo.
echo # WebSocket 客户端配置 >> "%~dp0..\Server\SmartClaw\.env"
echo GATEWAY_URL=http://localhost:8000 >> "%~dp0..\Server\SmartClaw\.env"
echo WEBSOCKET_ENABLED=true >> "%~dp0..\Server\SmartClaw\.env"
echo.
echo # LMStudio 配置 >> "%~dp0..\Server\SmartClaw\.env"
echo LMSTUDIO_URL=http://127.0.0.1:1234 >> "%~dp0..\Server\SmartClaw\.env"
echo LMSTUDIO_API_KEY= >> "%~dp0..\Server\SmartClaw\.env"
echo ✅ 环境配置文件已创建
REM 配置 Windows 防火墙规则
echo 🔥 配置 Windows 防火墙...
echo 📋 添加防火墙规则...
REM 检查规则是否已存在,如果存在则先删除
echo 🔍 检查现有防火墙规则...
netsh advfirewall firewall show rule name="Claw Gateway HTTP" >nul 2>&1
if %errorlevel%==0 (
echo 🗑️ 删除现有 HTTP 规则...
netsh advfirewall firewall delete rule name="Claw Gateway HTTP"
)
netsh advfirewall firewall show rule name="Claw Gateway HTTPS" >nul 2>&1
if %errorlevel%==0 (
echo 🗑️ 删除现有 HTTPS 规则...
netsh advfirewall firewall delete rule name="Claw Gateway HTTPS"
)
netsh advfirewall firewall show rule name="Claw SmartClaw" >nul 2>&1
if %errorlevel%==0 (
echo 🗑️ 删除现有 SmartClaw 规则...
netsh advfirewall firewall delete rule name="Claw SmartClaw"
)
REM 添加新的防火墙规则
echo 添加新的防火墙规则...
netsh advfirewall firewall add rule name="Claw Gateway HTTP" dir=in action=allow protocol=TCP localport=80
netsh advfirewall firewall add rule name="Claw Gateway HTTPS" dir=in action=allow protocol=TCP localport=443
netsh advfirewall firewall add rule name="Claw SmartClaw" dir=in action=allow protocol=TCP localport=3001
netsh advfirewall firewall add rule name="Claw Gateway Internal" dir=in action=allow protocol=TCP localport=8000
echo ✅ 防火墙配置完成
REM 创建服务启动脚本
echo 📝 创建服务启动脚本...
echo @echo off > "%~dp0nginx_start.bat"
echo echo 🚀 启动 Nginx... >> "%~dp0nginx_start.bat"
echo cd /d C:\nginx >> "%~dp0nginx_start.bat"
echo start nginx >> "%~dp0nginx_start.bat"
echo echo ✅ Nginx 已启动 >> "%~dp0nginx_start.bat"
echo pause >> "%~dp0nginx_start.bat"
echo @echo off > "%~dp0nginx_stop.bat"
echo echo 🛑 停止 Nginx... >> "%~dp0nginx_stop.bat"
echo cd /d C:\nginx >> "%~dp0nginx_stop.bat"
echo nginx -s stop >> "%~dp0nginx_stop.bat"
echo echo ✅ Nginx 已停止 >> "%~dp0nginx_stop.bat"
echo pause >> "%~dp0nginx_stop.bat"
echo @echo off > "%~dp0nginx_reload.bat"
echo echo 🔄 重载 Nginx 配置... >> "%~dp0nginx_reload.bat"
echo cd /d C:\nginx >> "%~dp0nginx_reload.bat"
echo nginx -s reload >> "%~dp0nginx_reload.bat"
echo echo ✅ Nginx 配置已重载 >> "%~dp0nginx_reload.bat"
echo pause >> "%~dp0nginx_reload.bat"
echo ✅ 启动脚本已创建
REM 显示配置信息
echo.
echo 🎉 Nginx 和 WebSocket 环境配置完成!
echo.
echo 📍 配置信息:
echo Nginx 配置文件: %NGINX_CONF_TARGET%
echo SSL 证书目录: %NGINX_SSL_DIR%
echo 网关服务端口: 8000 (内部)
echo HTTP 服务端口: 80 (外部)
echo HTTPS 服务端口: 443 (外部)
echo SmartClaw 端口: 3001 (内部)
echo.
echo 🔧 管理命令:
echo 启动 Nginx: %~dp0nginx_start.bat
echo 停止 Nginx: %~dp0nginx_stop.bat
echo 重载配置: %~dp0nginx_reload.bat
echo.
echo ⚠️ 注意事项:
echo 1. 请确保 SSL 证书文件已放置在 %NGINX_SSL_DIR% 目录
echo 2. 网关服务和 SmartClaw 服务需要单独启动
echo 3. WebSocket 连接将通过 Nginx 代理到网关服务
echo 4. 企业微信回调将通过 HTTPS 访问
echo.
echo 📅 完成时间: %date% %time%
echo.
echo 🚀 下一步:
echo 1. 复制 SSL 证书到 %NGINX_SSL_DIR%
echo 2. 启动 Nginx 服务
echo 3. 启动网关服务 (端口 8000)
echo 4. 启动 SmartClaw 服务 (端口 3001)
echo 5. 测试 WebSocket 连接
echo.
pause

149
Claw/scripts/deploy.bat Normal file
View File

@@ -0,0 +1,149 @@
@echo off
echo 🚀 开始部署 Claw 项目...
echo 📅 部署时间: %date% %time%
REM 检查是否以管理员身份运行
net session >nul 2>&1
if %errorlevel% neq 0 (
echo ⚠️ 警告:请以管理员身份运行此脚本以获得最佳效果
pause
)
REM 设置部署参数
set DEPLOY_DIR=C:\Claw
set SERVICE_NAME_GATEWAY=ClawGateway
set SERVICE_NAME_SMARTCLAW=ClawSmartClaw
echo 📋 部署配置:
echo 部署目录: %DEPLOY_DIR%
echo 网关服务名称: %SERVICE_NAME_GATEWAY%
echo SmartClaw服务名称: %SERVICE_NAME_SMARTCLAW%
REM 创建部署目录
echo 📁 创建部署目录...
if not exist "%DEPLOY_DIR%" mkdir "%DEPLOY_DIR%"
if not exist "%DEPLOY_DIR%\gateway" mkdir "%DEPLOY_DIR%\gateway"
if not exist "%DEPLOY_DIR%\smartclaw" mkdir "%DEPLOY_DIR%\smartclaw"
if not exist "%DEPLOY_DIR%\web" mkdir "%DEPLOY_DIR%\web"
if not exist "%DEPLOY_DIR%\logs" mkdir "%DEPLOY_DIR%\logs"
REM 复制文件
echo 📦 复制构建产物...
cd /d "%~dp0.."
echo 复制网关服务...
copy /Y "build\gateway\gateway.exe" "%DEPLOY_DIR%\gateway\"
copy /Y "Server\gateway\.env" "%DEPLOY_DIR%\gateway\.env" 2>nul
copy /Y "Server\gateway\.env.example" "%DEPLOY_DIR%\gateway\.env.example" 2>nul
echo 复制 SmartClaw 服务...
copy /Y "build\SmartClaw\smartclaw.exe" "%DEPLOY_DIR%\smartclaw\"
copy /Y "Server\SmartClaw\.env" "%DEPLOY_DIR%\smartclaw\.env" 2>nul
copy /Y "Server\SmartClaw\.env.example" "%DEPLOY_DIR%\smartclaw\.env.example" 2>nul
echo 复制 Web 前端...
xcopy /E /Y "build\web\*" "%DEPLOY_DIR%\web\"
echo 复制配置文件...
copy /Y "README.md" "%DEPLOY_DIR%\"
copy /Y "docs\企业微信配置指南.md" "%DEPLOY_DIR%\"
REM 创建 Windows 服务(可选)
echo 🔧 配置 Windows 服务...
echo 注意:服务安装需要管理员权限
choice /C YN /M "是否安装为 Windows 服务"
if %errorlevel%==1 (
echo 正在安装服务...
REM 创建服务启动脚本
echo @echo off > "%DEPLOY_DIR%\gateway\start.bat"
echo cd /d "%~dp0" >> "%DEPLOY_DIR%\gateway\start.bat"
echo gateway.exe >> "%DEPLOY_DIR%\gateway\start.bat"
echo @echo off > "%DEPLOY_DIR%\smartclaw\start.bat"
echo cd /d "%~dp0" >> "%DEPLOY_DIR%\smartclaw\start.bat"
echo smartclaw.exe >> "%DEPLOY_DIR%\smartclaw\start.bat"
REM 安装服务(使用 sc 命令)
sc query %SERVICE_NAME_GATEWAY% >nul 2>&1
if %errorlevel%==0 (
echo 停止现有网关服务...
sc stop %SERVICE_NAME_GATEWAY%
timeout /t 5 /nobreak >nul
sc delete %SERVICE_NAME_GATEWAY%
)
sc query %SERVICE_NAME_SMARTCLAW% >nul 2>&1
if %errorlevel%==0 (
echo 停止现有 SmartClaw 服务...
sc stop %SERVICE_NAME_SMARTCLAW%
timeout /t 5 /nobreak >nul
sc delete %SERVICE_NAME_SMARTCLAW%
)
echo 创建新服务...
sc create %SERVICE_NAME_GATEWAY% binPath= "%DEPLOY_DIR%\gateway\gateway.exe" start= auto DisplayName= "Claw Gateway Service"
sc create %SERVICE_NAME_SMARTCLAW% binPath= "%DEPLOY_DIR%\smartclaw\smartclaw.exe" start= auto DisplayName= "Claw SmartClaw Service"
echo 设置服务描述...
sc description %SERVICE_NAME_GATEWAY% "Claw 项目网关服务 - 企业微信智能助手"
sc description %SERVICE_NAME_SMARTCLAW% "Claw 项目 SmartClaw 服务 - 智能任务处理"
echo 启动服务...
sc start %SERVICE_NAME_GATEWAY%
sc start %SERVICE_NAME_SMARTCLAW%
echo ✅ 服务安装完成!
) else (
echo 跳过服务安装,您需要手动启动应用程序
)
REM 配置防火墙(可选)
choice /C YN /M "是否配置 Windows 防火墙"
if %errorlevel%==1 (
echo 🔥 配置防火墙...
netsh advfirewall firewall add rule name="Claw Gateway" dir=in action=allow protocol=TCP localport=3000
netsh advfirewall firewall add rule name="Claw SmartClaw" dir=in action=allow protocol=TCP localport=3001
netsh advfirewall firewall add rule name="Claw Web" dir=in action=allow protocol=TCP localport=80
echo ✅ 防火墙配置完成!
)
REM 创建启动脚本
echo 📝 创建启动脚本...
echo @echo off > "%DEPLOY_DIR%\start.bat"
echo echo 启动 Claw 服务... >> "%DEPLOY_DIR%\start.bat"
echo echo 🚀 启动网关服务... >> "%DEPLOY_DIR%\start.bat"
echo start "" "%DEPLOY_DIR%\gateway\gateway.exe" >> "%DEPLOY_DIR%\start.bat"
echo timeout /t 3 /nobreak ^>nul >> "%DEPLOY_DIR%\start.bat"
echo echo 🚀 启动 SmartClaw 服务... >> "%DEPLOY_DIR%\start.bat"
echo start "" "%DEPLOY_DIR%\smartclaw\smartclaw.exe" >> "%DEPLOY_DIR%\start.bat"
echo echo ✅ 服务已启动! >> "%DEPLOY_DIR%\start.bat"
echo echo 📡 WebSocket 连接将自动建立 >> "%DEPLOY_DIR%\start.bat"
echo pause >> "%DEPLOY_DIR%\start.bat"
echo @echo off > "%DEPLOY_DIR%\stop.bat"
echo echo 停止 Claw 服务... >> "%DEPLOY_DIR%\stop.bat"
echo taskkill /F /IM gateway.exe >> "%DEPLOY_DIR%\stop.bat"
echo taskkill /F /IM smartclaw.exe >> "%DEPLOY_DIR%\stop.bat"
echo echo 服务已停止! >> "%DEPLOY_DIR%\stop.bat"
echo pause >> "%DEPLOY_DIR%\stop.bat"
echo ✅ 部署完成!
echo 📍 部署信息:
echo 安装目录: %DEPLOY_DIR%
echo 网关服务: %DEPLOY_DIR%\gateway\gateway.exe
echo SmartClaw 服务: %DEPLOY_DIR%\smartclaw\smartclaw.exe
echo Web 前端: %DEPLOY_DIR%\web\
echo 日志目录: %DEPLOY_DIR%\logs\
echo 启动脚本: %DEPLOY_DIR%\start.bat
echo 停止脚本: %DEPLOY_DIR%\stop.bat
echo 📡 WebSocket 配置: 已启用长连接模式
echo 📅 完成时间: %date% %time%
echo.
echo 🎉 Claw 项目部署成功!
echo 请检查服务状态,确保一切正常运行
echo 如有问题,请查看日志文件或联系技术支持
pause

View File

@@ -0,0 +1,20 @@
@echo off
echo 🚀 开始部署网关服务...
REM 停止现有服务
echo 🛑 停止现有网关服务...
taskkill /F /IM gateway.exe 2>nul
REM 复制文件到部署目录
set DEPLOY_DIR=C:\Disk\Gateway
if not exist "%DEPLOY_DIR%" mkdir "%DEPLOY_DIR%"
echo 📁 复制文件到部署目录...
copy /Y "%~dp0..\build\gateway\gateway.exe" "%DEPLOY_DIR%\"
copy /Y "%~dp0..\Server\gateway\.env" "%DEPLOY_DIR%\"
echo ✅ 网关服务部署完成!
echo 📍 部署位置: %DEPLOY_DIR%\gateway.exe
echo 📝 配置文件: %DEPLOY_DIR%\.env
echo 🚀 启动命令: cd /d "%DEPLOY_DIR%" && gateway.exe

View File

@@ -0,0 +1,25 @@
@echo off
echo ========================================
echo 企业微信回调配置验证
echo ========================================
echo.
echo 回调URL: https://pactgo.cn/wecom
echo 代理目标: http://127.0.0.1:8000/api/v1/wechat/callback
echo.
echo [1] 检查Nginx配置语法...
nginx -t
echo.
echo [2] 检查网关服务状态...
curl -s http://127.0.0.1:8000/api/v1/health
echo.
echo [3] 测试回调路径...
curl -I http://localhost:8000/api/v1/wechat/callback
echo.
echo ========================================
echo 验证完成
echo ========================================
pause

View File

@@ -0,0 +1,104 @@
@echo off
echo 🧪 开始测试 WebSocket 连接...
echo 📅 测试时间: %date% %time%
REM 设置测试参数
set GATEWAY_URL=ws://localhost:8000
set TEST_TIMEOUT=5
echo 📋 测试配置:
echo 网关 WebSocket URL: %GATEWAY_URL%
echo 测试超时时间: %TEST_TIMEOUT%
REM 检查 curl 是否可用
where curl >nul 2>&1
if %errorlevel% neq 0 (
echo ❌ 错误:未检测到 curl 命令
echo 📥 请确保 curl 已安装并添加到 PATH
pause
exit /b 1
)
REM 检查网关服务是否运行
echo 🔍 检查网关服务状态...
curl -s -o nul -w "%%{http_code}" http://localhost:8000/api/v1/health > temp_status.txt
set /p STATUS_CODE=<temp_status.txt
del temp_status.txt
if "%STATUS_CODE%"=="200" (
echo ✅ 网关服务运行正常 (状态码: %STATUS_CODE%)
) else (
echo ⚠️ 警告:网关服务可能未运行 (状态码: %STATUS_CODE%)
echo 🔧 请先启动网关服务
)
REM 测试 WebSocket 连接
echo 🌐 测试 WebSocket 连接...
echo 📡 连接到 %GATEWAY_URL%/ws ...
REM 使用 curl 测试 WebSocket 握手
curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Sec-WebSocket-Version: 13" -H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" --max-time %TEST_TIMEOUT% %GATEWAY_URL%/ws > temp_websocket_test.txt 2>&1
REM 检查响应
findstr "HTTP/1.1 101" temp_websocket_test.txt >nul
if %errorlevel%==0 (
echo ✅ WebSocket 连接测试成功!
echo 📊 响应详情:
type temp_websocket_test.txt
) else (
echo ❌ WebSocket 连接测试失败
echo 🔍 错误详情:
type temp_websocket_test.txt
)
del temp_websocket_test.txt 2>nul
REM 测试 Nginx 代理的 WebSocket
echo.
echo 🔄 测试 Nginx WebSocket 代理...
set NGINX_WS_URL=ws://localhost/ws
echo 📡 连接到 %NGINX_WS_URL% ...
curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Sec-WebSocket-Version: 13" -H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" --max-time %TEST_TIMEOUT% %NGINX_WS_URL% > temp_nginx_test.txt 2>&1
findstr "HTTP/1.1 101" temp_nginx_test.txt >nul
if %errorlevel%==0 (
echo ✅ Nginx WebSocket 代理测试成功!
echo 📊 响应详情:
type temp_nginx_test.txt
) else (
echo ❌ Nginx WebSocket 代理测试失败
echo 🔍 错误详情:
type temp_nginx_test.txt
)
del temp_nginx_test.txt 2>nul
REM 测试 SmartClaw WebSocket 客户端连接
echo.
echo 🤖 测试 SmartClaw WebSocket 客户端连接...
echo 🔍 检查 SmartClaw 服务日志...
echo 📍 请检查 SmartClaw 控制台输出中的 WebSocket 连接状态
echo 📄 日志应包含 "WebSocket 客户端连接成功" 或类似信息
REM 提供手动测试命令
echo.
echo 🛠️ 手动测试命令:
echo 测试网关 WebSocket: curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Sec-WebSocket-Version: 13" -H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" ws://localhost:8000/ws
echo 测试 Nginx 代理: curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Sec-WebSocket-Version: 13" -H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" ws://localhost/ws
echo 检查网关健康: curl http://localhost:8000/api/v1/health
echo 检查 Nginx 状态: curl http://localhost/api/v1/health
echo.
echo 📊 测试结果摘要:
echo 网关服务状态: %STATUS_CODE%
echo WebSocket 直连: 见上方结果
echo Nginx WebSocket 代理: 见上方结果
echo.
echo 🎯 下一步:
echo 1. 如果测试失败,请检查服务是否启动
echo 2. 检查防火墙设置是否允许端口 8000 和 80/443
echo 3. 查看服务日志了解详细错误信息
echo 4. 确保 Nginx 配置正确并重载配置
echo.
echo 📅 测试完成时间: %date% %time%
pause

View File

@@ -0,0 +1,45 @@
#!/bin/bash
# WebSocket连接测试脚本
echo "🧪 开始测试WebSocket连接..."
# 测试网关服务WebSocket端点
echo "📡 测试网关服务WebSocket连接..."
echo "URL: ws://localhost:8000/ws"
# 使用websocat或类似的工具进行测试
# 如果没有安装websocat可以使用curl进行基本的握手测试
echo "🔍 使用curl测试WebSocket握手..."
curl -i -N \
-H "Connection: Upgrade" \
-H "Upgrade: websocket" \
-H "Sec-WebSocket-Version: 13" \
-H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" \
-H "Host: localhost:8000" \
-H "Origin: http://localhost:8000" \
http://localhost:8000/ws
echo ""
echo "🔍 测试Nginx WebSocket代理..."
curl -i -N \
-H "Connection: Upgrade" \
-H "Upgrade: websocket" \
-H "Sec-WebSocket-Version: 13" \
-H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" \
-H "Host: localhost" \
-H "Origin: http://localhost" \
http://localhost/ws
echo ""
echo "✅ WebSocket连接测试完成"
echo ""
echo "📋 测试结果说明:"
echo " - HTTP/1.1 101 Switching Protocols 表示WebSocket连接成功"
echo " - 其他状态码表示连接失败"
echo ""
echo "🛠️ 如果测试失败,请检查:"
echo " 1. 网关服务是否已启动 (端口8000)"
echo " 2. Nginx是否已启动 (端口80/443)"
echo " 3. 防火墙是否允许相关端口"
echo " 4. 服务日志中的错误信息"

View File

@@ -0,0 +1,116 @@
@echo off
echo 🔍 验证企业微信回调配置...
echo 📅 验证时间: %date% %time%
echo 📋 配置信息:
echo 回调URL: https://pactgo.cn/wecom
echo 代理目标: http://127.0.0.1:8000/api/v1/wechat/callback
echo 配置文件: d:\Projects\trunk\JoyD\Claw\docs\nginx.conf
REM 检查Nginx配置语法
echo 🔍 检查Nginx配置语法...
nginx -t
if %errorlevel% neq 0 (
echo ❌ Nginx配置语法检查失败
pause
exit /b 1
)
echo ✅ Nginx配置语法正确
REM 检查SSL证书文件
echo 🔍 检查SSL证书文件...
if exist "C:\nginx\ssl\pactgo.cn-chain.pem" (
echo ✅ SSL证书链文件存在
) else (
echo ⚠️ SSL证书链文件不存在: C:\nginx\ssl\pactgo.cn-chain.pem
)
if exist "C:\nginx\ssl\pactgo.cn-key.pem" (
echo ✅ SSL私钥文件存在
) else (
echo ⚠️ SSL私钥文件不存在: C:\nginx\ssl\pactgo.cn-key.pem
)
REM 测试回调URL可达性
echo 🔍 测试回调URL可达性...
echo 📡 测试HTTP到HTTPS重定向...
curl -I http://pactgo.cn/wecom 2>nul | findstr "301" >nul
if %errorlevel%==0 (
echo ✅ HTTP到HTTPS重定向正常
) else (
echo ⚠️ HTTP到HTTPS重定向可能有问题
)
echo 📡 测试HTTPS回调地址...
curl -I -k https://pactgo.cn/wecom 2>nul | findstr "HTTP/" > temp_status.txt
if exist temp_status.txt (
echo ✅ HTTPS回调地址响应:
type temp_status.txt
del temp_status.txt
) else (
echo ⚠️ 无法连接到HTTPS回调地址
)
REM 检查网关服务是否运行
echo 🔍 检查网关服务状态...
curl -s -o nul -w "%%{http_code}" http://127.0.0.1:8000/api/v1/health > temp_gateway_status.txt
set /p GATEWAY_STATUS=<temp_gateway_status.txt
del temp_gateway_status.txt
if "%GATEWAY_STATUS%"=="200" (
echo ✅ 网关服务运行正常 (状态码: %GATEWAY_STATUS%)
) else (
echo ⚠️ 网关服务可能未运行或异常 (状态码: %GATEWAY_STATUS%)
echo 🔧 请确保网关服务已启动并监听在 127.0.0.1:8000
)
REM 测试完整的回调路径
echo 🔍 测试完整回调路径...
echo 📡 测试企业微信回调模拟请求...
curl -X POST -k https://pactgo.cn/wecom \
-H "Content-Type: application/json" \
-d "{\"msg\":\"test\",\"timestamp\":1234567890}" \
-s -o temp_response.txt -w "%%{http_code}" > temp_callback_status.txt
set /p CALLBACK_STATUS=<temp_callback_status.txt
echo 📊 回调响应状态码: %CALLBACK_STATUS%
if exist temp_response.txt (
echo 📄 响应内容:
type temp_response.txt
del temp_response.txt
)
del temp_callback_status.txt
REM 检查Nginx是否运行
echo 🔍 检查Nginx运行状态...
tasklist /FI "IMAGENAME eq nginx.exe" 2>nul | find "nginx.exe" >nul
if %errorlevel%==0 (
echo ✅ Nginx正在运行
) else (
echo ⚠️ Nginx未运行请启动Nginx服务
)
echo.
echo 🎯 企业微信配置建议:
echo 1. 在企业微信管理后台设置回调URL为: https://pactgo.cn/wecom
echo 2. 确保Token和EncodingAESKey与网关服务配置一致
echo 3. 测试消息推送功能
echo 4. 监控回调日志和响应时间
echo.
echo 📊 验证总结:
echo - Nginx配置语法: ✅ 正确
echo - 网关服务状态: %GATEWAY_STATUS% (期望: 200)
echo - SSL证书: 见上方检查结果
echo - 回调URL: 见上方HTTP响应测试
echo.
echo 🚀 下一步:
echo 1. 如果所有检查都通过,可以在企业微信后台配置回调
echo 2. 配置Token和EncodingAESKey
echo 3. 测试实际的消息推送
echo 4. 监控服务日志确保正常工作
echo.
echo 📅 验证完成时间: %date% %time%
pause

97
Claw/scripts/verify.bat Normal file
View File

@@ -0,0 +1,97 @@
@echo off
REM Claw项目构建验证脚本Windows版
echo 🦞 Starting Claw project build verification...
REM Check Rust environment
where cargo >nul 2>nul
if %errorlevel% neq 0 (
echo ❌ Cargo not found, please install Rust first
exit /b 1
)
echo ✅ Rust environment check passed
REM Build shared library
echo 📦 Building shared library...
cd Server\shared
cargo check
if %errorlevel% neq 0 (
echo ❌ Shared library build failed
exit /b 1
)
cd ..\..
echo ✅ Shared library build successful
REM Build gateway service
echo 🚪 Building gateway service...
cd Server\gateway
cargo check
if %errorlevel% neq 0 (
echo ❌ Gateway service build failed
exit /b 1
)
cd ..\..
echo ✅ Gateway service build successful
REM Build SmartClaw service
echo 🤖 Building SmartClaw service...
cd Server\SmartClaw
cargo check
if %errorlevel% neq 0 (
echo ❌ SmartClaw service build failed
exit /b 1
)
cd ..\..
echo ✅ SmartClaw service build successful
REM Check WeChat app structure
echo 📱 Checking WeChat app structure...
if not exist "client\wechat_app" (
echo ❌ WeChat app directory not found
exit /b 1
)
REM Check required files
set required_files=client\wechat_app\app.json client\wechat_app\app.js client\wechat_app\app.wxss client\wechat_app\project.config.json client\wechat_app\sitemap.json
for %%f in (%required_files%) do (
if not exist "%%f" (
echo ❌ Missing required file: %%f
exit /b 1
)
)
echo ✅ WeChat app structure check passed
REM Check web app
echo 🌐 Checking web application...
if not exist "client\web\index.html" (
echo ❌ Web application not found
exit /b 1
)
echo ✅ Web application check passed
echo.
echo 🎉 Project build verification completed!
echo.
echo 📋 Project Structure Overview:
echo ├── Server/
echo │ ├── gateway/ # Gateway service (Server A)
echo │ ├── SmartClaw/ # SmartClaw service (Server B)
echo │ └── shared/ # Shared code library
echo ├── client/
echo │ ├── wechat_app/ # WeChat Mini Program (native)
echo │ │ ├── pages/ # Page directory
echo │ │ ├── utils/ # Utility functions
echo │ │ ├── components/ # Custom components
echo │ │ └── assets/ # Static resources
echo │ └── web/ # Enterprise WeChat web app
echo ├── docs/ # Project documentation
echo ├── scripts/ # Build scripts
echo └── build/ # Build artifacts
echo.
echo 🚀 Technology Stack:
echo • Backend: Rust + Actix Web + Embedded-Redis + HeedDB
echo • Frontend: WXML + WXSS + JavaScript (WeChat native)
echo • Communication: WebSocket reverse connection + HTTPS
echo • Database: HeedDB (embedded) + Embedded-Redis
echo.
echo ✨ Project is ready for development!