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

@@ -128,13 +128,19 @@ info "复制用户脚本..."
# 从 scripts 模板目录复制(构建脚本同级的 uclaw-scripts/ 目录) # 从 scripts 模板目录复制(构建脚本同级的 uclaw-scripts/ 目录)
SCRIPTS_SRC="$SCRIPT_DIR/uclaw-scripts" SCRIPTS_SRC="$SCRIPT_DIR/uclaw-scripts"
if [ -d "$SCRIPTS_SRC" ]; then if [ -d "$SCRIPTS_SRC" ]; then
cp "$SCRIPTS_SRC/启动菜单.command" "$UCLAW_DIR/" 2>/dev/null || true
cp "$SCRIPTS_SRC/启动菜单.bat" "$UCLAW_DIR/" 2>/dev/null || true
cp "$SCRIPTS_SRC/运行.command" "$UCLAW_DIR/" 2>/dev/null || true cp "$SCRIPTS_SRC/运行.command" "$UCLAW_DIR/" 2>/dev/null || true
cp "$SCRIPTS_SRC/运行.bat" "$UCLAW_DIR/" 2>/dev/null || true cp "$SCRIPTS_SRC/运行.bat" "$UCLAW_DIR/" 2>/dev/null || true
cp "$SCRIPTS_SRC/安装到电脑.command" "$UCLAW_DIR/" 2>/dev/null || true cp "$SCRIPTS_SRC/安装到电脑.command" "$UCLAW_DIR/" 2>/dev/null || true
cp "$SCRIPTS_SRC/安装到电脑.bat" "$UCLAW_DIR/" 2>/dev/null || true cp "$SCRIPTS_SRC/安装到电脑.bat" "$UCLAW_DIR/" 2>/dev/null || true
cp "$SCRIPTS_SRC/使用说明.txt" "$UCLAW_DIR/" 2>/dev/null || true cp "$SCRIPTS_SRC/使用说明.txt" "$UCLAW_DIR/" 2>/dev/null || true
chmod +x "$UCLAW_DIR/运行.command" "$UCLAW_DIR/安装到电脑.command" 2>/dev/null || true cp "$SCRIPTS_SRC/中国用户指南.txt" "$UCLAW_DIR/" 2>/dev/null || true
ok "用户脚本已复制" # 复制教程文档
mkdir -p "$UCLAW_DIR/docs"
cp "$SCRIPT_DIR/docs/教程-OpenClaw中国区完全指南.md" "$UCLAW_DIR/docs/" 2>/dev/null || true
chmod +x "$UCLAW_DIR/启动菜单.command" "$UCLAW_DIR/运行.command" "$UCLAW_DIR/安装到电脑.command" 2>/dev/null || true
ok "用户脚本已复制(含启动菜单、中国用户指南)"
else else
warn "找不到 uclaw-scripts/ 目录,请手动复制脚本到 U-Claw/" warn "找不到 uclaw-scripts/ 目录,请手动复制脚本到 U-Claw/"
fi fi

View File

@@ -164,6 +164,11 @@ if /i "%MODEL%"=="a" (
echo 配置 DeepSeek echo 配置 DeepSeek
echo 获取 API Key: https://platform.deepseek.com/ echo 获取 API Key: https://platform.deepseek.com/
set /p APIKEY=" 请输入 DeepSeek API Key: " 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_API_KEY=!APIKEY!>> "%ENV_FILE%"
echo OPENAI_BASE_URL=https://api.deepseek.com/v1>> "%ENV_FILE%" echo OPENAI_BASE_URL=https://api.deepseek.com/v1>> "%ENV_FILE%"
echo DeepSeek 已配置! echo DeepSeek 已配置!
@@ -173,6 +178,10 @@ if /i "%MODEL%"=="b" (
echo 配置 Kimi echo 配置 Kimi
echo 获取 API Key: https://platform.moonshot.cn/ echo 获取 API Key: https://platform.moonshot.cn/
set /p APIKEY=" 请输入 Moonshot API Key: " 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_API_KEY=!APIKEY!>> "%ENV_FILE%"
echo OPENAI_BASE_URL=https://api.moonshot.cn/v1>> "%ENV_FILE%" echo OPENAI_BASE_URL=https://api.moonshot.cn/v1>> "%ENV_FILE%"
echo Kimi 已配置! echo Kimi 已配置!
@@ -182,6 +191,10 @@ if /i "%MODEL%"=="c" (
echo 配置通义千问 echo 配置通义千问
echo 获取 API Key: https://dashscope.console.aliyun.com/ echo 获取 API Key: https://dashscope.console.aliyun.com/
set /p APIKEY=" 请输入 Qwen API Key: " 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 ZAI_API_KEY=!APIKEY!>> "%ENV_FILE%"
echo 通义千问已配置! echo 通义千问已配置!
) )

View File

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

View File

@@ -61,10 +61,29 @@ echo "%%UCLAW_HOME%%\node\node.exe" "%%UCLAW_HOME%%\openclaw\openclaw.mjs" %%*
echo. echo.
echo 正在添加到系统 PATH... echo 正在添加到系统 PATH...
set "CURRENT_PATH="
for /f "tokens=2*" %%a in ('reg query "HKCU\Environment" /v PATH 2^>nul') do set "CURRENT_PATH=%%b" 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 echo %CURRENT_PATH% | findstr /i ".uclaw" >nul 2>&1
if errorlevel 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 echo 已添加到用户 PATH
) else ( ) else (
echo PATH 已配置,跳过 echo PATH 已配置,跳过

View File

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

View File

@@ -500,43 +500,43 @@
<tr> <tr>
<td><strong>DeepSeek</strong></td> <td><strong>DeepSeek</strong></td>
<td>深度求索</td> <td>深度求索</td>
<td class="zh">编程,性价比之王</td><td class="en hidden">Coding, best value</td> <td><span class="zh">编程,性价比之王</span><span class="en hidden">Coding, best value</span></td>
<td><span class="badge badge-hot">★ 推荐</span></td> <td><span class="badge badge-hot">★ 推荐</span></td>
</tr> </tr>
<tr> <tr>
<td><strong>Kimi K2.5</strong></td> <td><strong>Kimi K2.5</strong></td>
<td>月之暗面</td> <td>月之暗面</td>
<td class="zh">256K 超长上下文</td><td class="en hidden">256K context</td> <td><span class="zh">256K 超长上下文</span><span class="en hidden">256K context</span></td>
<td><span class="badge badge-cheap">长文档</span></td> <td><span class="badge badge-cheap">长文档</span></td>
</tr> </tr>
<tr> <tr>
<td><strong>Qwen</strong></td> <td><strong>Qwen</strong></td>
<td>阿里通义千问</td> <td>阿里通义千问</td>
<td class="zh">免费额度最大</td><td class="en hidden">Large free tier</td> <td><span class="zh">免费额度最大</span><span class="en hidden">Large free tier</span></td>
<td><span class="badge badge-free">免费</span></td> <td><span class="badge badge-free">免费</span></td>
</tr> </tr>
<tr> <tr>
<td><strong>GLM 4.7</strong></td> <td><strong>GLM 4.7</strong></td>
<td>智谱 AI</td> <td>智谱 AI</td>
<td class="zh">学术,中文 NLP</td><td class="en hidden">Academic</td> <td><span class="zh">学术,中文 NLP</span><span class="en hidden">Academic</span></td>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
<td><strong>MiniMax</strong></td> <td><strong>MiniMax</strong></td>
<td>MiniMax</td> <td>MiniMax</td>
<td class="zh">语音,多模态</td><td class="en hidden">Voice, multimodal</td> <td><span class="zh">语音,多模态</span><span class="en hidden">Voice, multimodal</span></td>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
<td><strong>Doubao</strong></td> <td><strong>Doubao</strong></td>
<td>字节豆包</td> <td>字节豆包</td>
<td class="zh">火山引擎生态</td><td class="en hidden">ByteDance ecosystem</td> <td><span class="zh">火山引擎生态</span><span class="en hidden">ByteDance ecosystem</span></td>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
<td><strong>Claude</strong></td> <td><strong>Claude</strong></td>
<td>Anthropic</td> <td>Anthropic</td>
<td class="zh">最强综合能力</td><td class="en hidden">Best overall</td> <td><span class="zh">最强综合能力</span><span class="en hidden">Best overall</span></td>
<td><span class="badge badge-hot">Global</span></td> <td><span class="badge badge-hot">Global</span></td>
</tr> </tr>
</tbody> </tbody>