fix: 9 bugs from code review

Critical:
- build script now copies launcher menu + china guide (was missing!)
- Windows PATH: handle fresh accounts + warn on 1024 char limit
- Windows .bat: remove old .env keys before adding new (no duplicates)

Important:
- Menu error message: fix range 0-14 → 0-16
- API key input: use read -s to hide plaintext
- macOS install: default to .zshrc (not .bash_profile)
- Website table: fix column mismatch (td → span inside td)
This commit is contained in:
dongsheng123132
2026-03-09 10:51:19 +08:00
parent 34a9688edc
commit 1b4bfb38d9
6 changed files with 64 additions and 22 deletions

View File

@@ -164,6 +164,11 @@ if /i "%MODEL%"=="a" (
echo 配置 DeepSeek
echo 获取 API Key: https://platform.deepseek.com/
set /p APIKEY=" 请输入 DeepSeek API Key: "
REM 移除旧配置再写入,避免重复
if exist "%ENV_FILE%" (
findstr /v "^OPENAI_API_KEY= ^OPENAI_BASE_URL=" "%ENV_FILE%" > "%ENV_FILE%.tmp" 2>nul
move /y "%ENV_FILE%.tmp" "%ENV_FILE%" >nul 2>nul
)
echo OPENAI_API_KEY=!APIKEY!>> "%ENV_FILE%"
echo OPENAI_BASE_URL=https://api.deepseek.com/v1>> "%ENV_FILE%"
echo DeepSeek 已配置!
@@ -173,6 +178,10 @@ if /i "%MODEL%"=="b" (
echo 配置 Kimi
echo 获取 API Key: https://platform.moonshot.cn/
set /p APIKEY=" 请输入 Moonshot API Key: "
if exist "%ENV_FILE%" (
findstr /v "^OPENAI_API_KEY= ^OPENAI_BASE_URL=" "%ENV_FILE%" > "%ENV_FILE%.tmp" 2>nul
move /y "%ENV_FILE%.tmp" "%ENV_FILE%" >nul 2>nul
)
echo OPENAI_API_KEY=!APIKEY!>> "%ENV_FILE%"
echo OPENAI_BASE_URL=https://api.moonshot.cn/v1>> "%ENV_FILE%"
echo Kimi 已配置!
@@ -182,6 +191,10 @@ if /i "%MODEL%"=="c" (
echo 配置通义千问
echo 获取 API Key: https://dashscope.console.aliyun.com/
set /p APIKEY=" 请输入 Qwen API Key: "
if exist "%ENV_FILE%" (
findstr /v "^ZAI_API_KEY=" "%ENV_FILE%" > "%ENV_FILE%.tmp" 2>nul
move /y "%ENV_FILE%.tmp" "%ENV_FILE%" >nul 2>nul
)
echo ZAI_API_KEY=!APIKEY!>> "%ENV_FILE%"
echo 通义千问已配置!
)

View File

@@ -200,7 +200,7 @@ do_china_models() {
echo -e " ${CYAN}配置 DeepSeek${NC}"
echo " 获取 API Key: https://platform.deepseek.com/"
echo ""
read -p " 请输入 DeepSeek API Key: " API_KEY
read -s -p " 请输入 DeepSeek API Key: " API_KEY; echo
if [ -n "$API_KEY" ]; then
grep -v "OPENAI_API_KEY\|OPENAI_BASE_URL" "$ENV_FILE" > "$ENV_FILE.tmp" 2>/dev/null || true
mv "$ENV_FILE.tmp" "$ENV_FILE"
@@ -213,7 +213,7 @@ do_china_models() {
echo -e " ${CYAN}配置 Kimi (月之暗面)${NC}"
echo " 获取 API Key: https://platform.moonshot.cn/"
echo ""
read -p " 请输入 Moonshot API Key: " API_KEY
read -s -p " 请输入 Moonshot API Key: " API_KEY; echo
if [ -n "$API_KEY" ]; then
grep -v "OPENAI_API_KEY\|OPENAI_BASE_URL" "$ENV_FILE" > "$ENV_FILE.tmp" 2>/dev/null || true
mv "$ENV_FILE.tmp" "$ENV_FILE"
@@ -226,7 +226,7 @@ do_china_models() {
echo -e " ${CYAN}配置通义千问 Qwen${NC}"
echo " 获取 API Key: https://dashscope.console.aliyun.com/"
echo ""
read -p " 请输入 Qwen API Key: " API_KEY
read -s -p " 请输入 Qwen API Key: " API_KEY; echo
if [ -n "$API_KEY" ]; then
grep -v "ZAI_API_KEY" "$ENV_FILE" > "$ENV_FILE.tmp" 2>/dev/null || true
mv "$ENV_FILE.tmp" "$ENV_FILE"
@@ -239,7 +239,7 @@ do_china_models() {
echo " 获取 API Key: https://open.bigmodel.cn/"
echo " 注意: 通过火山引擎(Volcano Engine)接入"
echo ""
read -p " 请输入 API Key: " API_KEY
read -s -p " 请输入 API Key: " API_KEY; echo
if [ -n "$API_KEY" ]; then
echo "# 智谱GLM (via Volcano Engine)" >> "$ENV_FILE"
echo "VOLCENGINE_API_KEY=$API_KEY" >> "$ENV_FILE"
@@ -250,7 +250,7 @@ do_china_models() {
echo -e " ${CYAN}配置 MiniMax${NC}"
echo " 获取 API Key: https://platform.minimaxi.com/"
echo ""
read -p " 请输入 MiniMax API Key: " API_KEY
read -s -p " 请输入 MiniMax API Key: " API_KEY; echo
if [ -n "$API_KEY" ]; then
grep -v "MINIMAX_API_KEY" "$ENV_FILE" > "$ENV_FILE.tmp" 2>/dev/null || true
mv "$ENV_FILE.tmp" "$ENV_FILE"
@@ -262,7 +262,7 @@ do_china_models() {
echo -e " ${CYAN}配置豆包 Doubao (字节跳动)${NC}"
echo " 获取 API Key: https://console.volcengine.com/ark"
echo ""
read -p " 请输入火山引擎 API Key: " API_KEY
read -s -p " 请输入火山引擎 API Key: " API_KEY; echo
if [ -n "$API_KEY" ]; then
grep -v "VOLCENGINE_API_KEY" "$ENV_FILE" > "$ENV_FILE.tmp" 2>/dev/null || true
mv "$ENV_FILE.tmp" "$ENV_FILE"
@@ -274,7 +274,7 @@ do_china_models() {
echo -e " ${CYAN}配置百度千帆${NC}"
echo " 获取 API Key: https://console.bce.baidu.com/qianfan/"
echo ""
read -p " 请输入千帆 API Key: " API_KEY
read -s -p " 请输入千帆 API Key: " API_KEY; echo
if [ -n "$API_KEY" ]; then
echo "QIANFAN_API_KEY=$API_KEY" >> "$ENV_FILE"
echo -e " ${GREEN}百度千帆已配置!${NC}"
@@ -284,7 +284,7 @@ do_china_models() {
echo -e " ${CYAN}配置小米 Mimo${NC}"
echo " 获取 API Key: https://dev.mi.com/mimo"
echo ""
read -p " 请输入 Mimo API Key: " API_KEY
read -s -p " 请输入 Mimo API Key: " API_KEY; echo
if [ -n "$API_KEY" ]; then
echo "MIMO_API_KEY=$API_KEY" >> "$ENV_FILE"
echo -e " ${GREEN}小米 Mimo 已配置!${NC}"
@@ -835,7 +835,7 @@ while true; do
exit 0
;;
*)
echo -e " ${RED}无效选择,请输入 0-14${NC}"
echo -e " ${RED}无效选择,请输入 0-16${NC}"
;;
esac

View File

@@ -61,10 +61,29 @@ echo "%%UCLAW_HOME%%\node\node.exe" "%%UCLAW_HOME%%\openclaw\openclaw.mjs" %%*
echo.
echo 正在添加到系统 PATH...
set "CURRENT_PATH="
for /f "tokens=2*" %%a in ('reg query "HKCU\Environment" /v PATH 2^>nul') do set "CURRENT_PATH=%%b"
echo %CURRENT_PATH% | findstr /i ".uclaw" >nul 2>&1
if errorlevel 1 (
setx PATH "%INSTALL_DIR%;%INSTALL_DIR%\node;%CURRENT_PATH%" >nul 2>&1
REM 检查 PATH 是否为空(全新账户)
if not defined CURRENT_PATH (
setx PATH "%INSTALL_DIR%;%INSTALL_DIR%\node" >nul 2>&1
) else (
REM 检查 setx 1024 字符限制
set "NEW_PATH=%INSTALL_DIR%;%INSTALL_DIR%\node;%CURRENT_PATH%"
setlocal enabledelayedexpansion
if "!NEW_PATH:~1024,1!" neq "" (
echo [警告] PATH 超过 1024 字符setx 会截断!
echo 请手动添加以下路径到系统 PATH:
echo %INSTALL_DIR%
echo %INSTALL_DIR%\node
endlocal
) else (
endlocal
setx PATH "%INSTALL_DIR%;%INSTALL_DIR%\node;%CURRENT_PATH%" >nul 2>&1
)
)
echo 已添加到用户 PATH
) else (
echo PATH 已配置,跳过

View File

@@ -68,9 +68,13 @@ fi
echo -e " ${CYAN}[4/4] 配置环境变量...${NC}"
SHELL_RC="$HOME/.zshrc"
[ ! -f "$SHELL_RC" ] && SHELL_RC="$HOME/.bashrc"
[ ! -f "$SHELL_RC" ] && SHELL_RC="$HOME/.bash_profile"
# macOS Catalina+ 默认 zsh始终写 .zshrc
if [ "$(basename "$SHELL")" = "zsh" ] || [ ! -f "$HOME/.bashrc" -a ! -f "$HOME/.bash_profile" ]; then
SHELL_RC="$HOME/.zshrc"
else
SHELL_RC="$HOME/.bashrc"
fi
touch "$SHELL_RC"
if ! grep -q ".uclaw/node/bin" "$SHELL_RC" 2>/dev/null; then
echo "" >> "$SHELL_RC"