From 312ccd553bbae537bf532f5addb0c8c114dbd369 Mon Sep 17 00:00:00 2001 From: KawaiiYusora Date: Sun, 16 Mar 2025 05:12:23 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=94=A7=20chore(.gitattributes):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20MaiLauncher.bat=20=E7=9A=84=E7=BC=96?= =?UTF-8?q?=E7=A0=81=E5=92=8C=E6=8D=A2=E8=A1=8C=E7=AC=A6=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index cf5cffa22..1c4521779 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,3 @@ *.bat text eol=crlf -*.cmd text eol=crlf \ No newline at end of file +*.cmd text eol=crlf +MaiLauncher.bat text eol=crlf working-tree-encoding=GBK \ No newline at end of file From a746a8a81d7fa4648af38296074847a8ae3f54e1 Mon Sep 17 00:00:00 2001 From: KawaiiYusora Date: Sun, 16 Mar 2025 05:48:47 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E2=9C=A8=20feat(MaiLauncher.bat):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=99=9A=E6=8B=9F=E7=8E=AF=E5=A2=83=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E5=8A=9F=E8=83=BD=E5=B9=B6=E4=BC=98=E5=8C=96=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E7=AE=B1=E8=8F=9C=E5=8D=95=E9=80=89=E9=A1=B9=20?= =?UTF-8?q?=F0=9F=94=A7=20fix(MaiLauncher.bat):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E6=9B=B4=E6=96=B0=E5=92=8C?= =?UTF-8?q?=E5=AD=A6=E4=B9=A0=E7=9F=A5=E8=AF=86=E5=BA=93=E7=9A=84=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4=E9=80=BB=E8=BE=91=20=E2=9E=95=20feat(MaiLauncher.bat)?= =?UTF-8?q?:=20=E6=96=B0=E5=A2=9E=E5=88=86=E6=94=AF=E9=87=8D=E7=BD=AE?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MaiLauncher.bat | 69 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 63 insertions(+), 6 deletions(-) diff --git a/MaiLauncher.bat b/MaiLauncher.bat index 5613f05c2..80deb04d0 100644 --- a/MaiLauncher.bat +++ b/MaiLauncher.bat @@ -254,11 +254,49 @@ if "!BRANCH!"=="main" ( @REM endlocal & set "BRANCH_COLOR=%BRANCH_COLOR%" +:check_is_venv +echo 正在检查是否在虚拟环境中... +if exist "%_root%\config\no_venv" ( + echo 检测到no_venv,跳过虚拟环境检查 + goto menu +) +if not defined VIRTUAL_ENV ( + echo 当前使用的Python环境为: + echo !PYTHON_HOME! + echo 似乎没有使用虚拟环境,是否要创建一个新的虚拟环境? + set /p confirm="继续?(Y/N): " + if /i "!confirm!"=="Y" ( + echo 正在创建虚拟环境... + python -m virtualenv venv + call venv\Scripts\activate.bat + echo 要安装依赖吗? + set /p install_confirm="继续?(Y/N): " + if /i "%install_confirm%"=="Y" ( + echo 正在安装依赖... + python -m pip config set global.index-url https://mirrors.aliyun.com/pypi/simple + python -m pip install -r requirements.txt + ) + echo 虚拟环境创建完成,按任意键返回... + ) else ( + echo 要永久跳过虚拟环境检查吗? + set /p no_venv_confirm="继续?(Y/N): " + if /i "!no_venv_confirm!"=="Y" ( + echo 正在创建no_venv文件... + echo 1 > "%_root%\config\no_venv" + echo 已创建no_venv文件,按任意键返回... + ) else ( + echo 取消跳过虚拟环境检查,按任意键返回... + ) + ) + pause >nul +) +goto menu :menu @chcp 936 cls echo 麦麦Bot控制台 v%VERSION% 当前分支: %BRANCH_COLOR%%BRANCH% +echo 当前Python环境: !PYTHON_HOME! echo ====================== echo 1. 更新并启动麦麦Bot (默认) echo 2. 直接启动麦麦Bot @@ -296,6 +334,7 @@ start python webui.py goto menu + :tools_menu @chcp 936 cls @@ -313,10 +352,11 @@ echo ====================== set /p choice="请输入选项数字: " if "!choice!"=="1" goto update_dependencies if "!choice!"=="2" goto switch_branch -if "!choice!"=="3" goto update_config -if "!choice!"=="4" goto learn_new_knowledge -if "!choice!"=="5" goto open_knowledge_folder -if "!choice!"=="6" goto menu +if "!choice!"=="3" goto reset_branch +if "!choice!"=="4" goto update_config +if "!choice!"=="5" goto learn_new_knowledge +if "!choice!"=="6" goto open_knowledge_folder +if "!choice!"=="7" goto menu echo 无效的输入,请输入1-6之间的数字 timeout /t 2 >nul @@ -369,13 +409,30 @@ pause >nul goto tools_menu +:reset_branch +cls +echo 正在重置当前分支... +echo 当前分支: !BRANCH! +echo 确认要重置当前分支吗? +set /p confirm="继续?(Y/N): " +if /i "!confirm!"=="Y" ( + echo 正在重置当前分支... + git reset --hard !BRANCH! + echo 分支重置完成,按任意键返回工具箱菜单... +) else ( + echo 取消重置当前分支,按任意键返回工具箱菜单... +) +pause >nul +goto tools_menu + + :update_config cls echo 正在更新配置文件... echo 请确保已备份重要数据,继续将修改当前配置文件。 echo 继续请按Y,取消请按任意键... set /p confirm="继续?(Y/N): " -if /i "%confirm%"=="Y" ( +if /i "!confirm!"=="Y" ( echo 正在更新配置文件... python.exe config\auto_update.py echo 配置文件更新完成,按任意键返回工具箱菜单... @@ -391,7 +448,7 @@ echo 正在学习新的知识库... echo 请确保已备份重要数据,继续将修改当前知识库。 echo 继续请按Y,取消请按任意键... set /p confirm="继续?(Y/N): " -if /i "%confirm%"=="Y" ( +if /i "!confirm!"=="Y" ( echo 正在学习新的知识库... python.exe src\plugins\zhishi\knowledge_library.py echo 学习完成,按任意键返回工具箱菜单... From 26ead12dce7597daa6023d3b308980a935ed068c Mon Sep 17 00:00:00 2001 From: KawaiiYusora Date: Sun, 16 Mar 2025 06:11:26 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E2=9C=A8=20fix(MaiLauncher.bat):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8DMongoDB=E6=9C=8D=E5=8A=A1=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MaiLauncher.bat | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/MaiLauncher.bat b/MaiLauncher.bat index 80deb04d0..c3dce052a 100644 --- a/MaiLauncher.bat +++ b/MaiLauncher.bat @@ -169,10 +169,14 @@ if exist "%_root%\tools\git\bin" ( :search_mongodb cls sc query | findstr /i "MongoDB" >nul -if %errorlevel% neq 0 ( +if !errorlevel! neq 0 ( echo MongoDB服务未运行,正在尝试启动... - net start MongoDB >nul 2>&1 - if %errorlevel% neq 0 ( + powershell -Command "Start-Process -Verb RunAs cmd -ArgumentList '/c net start MongoDB'" + echo 正在等待MongoDB服务启动... + echo 按下任意键跳过等待... + timeout /t 30 >nul + sc query | findstr /i "MongoDB" >nul + if !errorlevel! neq 0 ( echo MongoDB服务启动失败,可能是没有安装,要安装吗? set /p confirm="继续?(Y/N): " if /i "!confirm!"=="Y" (