#!/usr/bin/env python3
"""
更新 guide.html + quick-start.html
- 添加 OneClick 一键安装器下载
- 更新版本号: 34 Hooks, v2.0
- 三平台下载按钮
"""
import re, os
WEBDIR = '/opt/bookworm-web/public'
# ═══════════════════════════════════════
# 1. guide.html
# ═══════════════════════════════════════
guide = os.path.join(WEBDIR, 'guide.html')
with open(guide, 'r', encoding='utf-8') as f:
html = f.read()
# (a) 版本号 29 Hooks → 34 Hooks
html = html.replace('29 Hooks', '34 Hooks')
# (b) 版本号 v1.5 → v2.0
html = html.replace('Portable v1.5', 'Portable v2.0')
html = html.replace('v1.5 |', 'v2.0 |')
# (c) 替换单一下载按钮为三平台下载
old_download = '''⬇ 下载一键安装器'''
new_download = '''
全新电脑? 双击即装 — 自动安装 Node.js + Git + Claude Code + Bookworm 配置
'''
html = html.replace(old_download, new_download)
# (d) 更新 "最快方式" 卡片 — 提及全自动
old_fastest = '''最快方式:一键安装器
获取 Bookworm-Setup.bat (4KB) → 双击运行 → 输入密码 → 完成
安装器自动检测依赖、下载配置、创建桌面快捷方式、启动 Claude Code
'''
new_fastest = '''最快方式:全自动一键安装器 v2.0
下载 OneClick 安装器 → 双击运行 → 输入密码 → 完成
全新电脑零依赖:自动安装 Node.js + Git + Claude Code + 下载配置 + 创建桌面快捷方式
Win 11: winget 自动装
Win 10: 下载 MSI 静默装
macOS: Homebrew 自动装
'''
html = html.replace(old_fastest, new_fastest)
# (e) 更新手动流程提示
old_manual = '手动安装流程:
'
new_manual = '如需手动安装(一键安装器失败时的备选方案):
'
html = html.replace(old_manual, new_manual)
# (f) 更新首次安装行 "快速参考" 表
old_ref = '| 首次安装 | git clone + 双击 更新并启动Bookworm.bat | pwsh -ExecutionPolicy Bypass -File install.ps1 |
'
new_ref = '| 首次安装 | 双击 Bookworm-OneClick.bat 自动装 Node.js + Git + Claude Code | pwsh -ExecutionPolicy Bypass -File install.ps1 |
'
html = html.replace(old_ref, new_ref)
# (g) 在 "安装检查清单" 前插入 OneClick 安装段
oneclick_section = '''
0全自动一键安装 (推荐)
⚡
全新电脑? 从这里开始!
OneClick 安装器会自动完成所有步骤:安装 Node.js、Git、Claude Code,下载 Bookworm 配置,创建桌面快捷方式。
你只需要输入 Gitea 密码和主密码。
1
Windows: 下载并双击
下载对应版本 → 双击运行 → UAC 点"是" → 按提示输入 Gitea 密码和主密码 → 完成
2
macOS: 终端一行命令
打开终端,粘贴以下命令并回车:
curl -fsSL -o ~/bookworm-install.sh https://bookworm.letcareme.com/download/Bookworm-OneClick-Mac.sh && bash ~/bookworm-install.sh
💡
OneClick 安装器已包含以下所有步骤
如果一键安装成功,可跳过下方的手动步骤 1-3,直接查看
每日使用部分。
'''
# 在 "安装检查清单" 部分前插入
checklist_marker = '\n '
html = html.replace(checklist_marker, oneclick_section + ' ' + checklist_marker)
# (h) 更新时间首次安装 "约 10 分钟" → 区分 OneClick / 手动
old_time = '首次安装约 10 分钟(含依赖下载),之后每次双击启动约 10-30 秒'
new_time = '一键安装约 5 分钟(自动下载依赖),手动安装约 15 分钟。之后每次双击启动约 10-30 秒'
html = html.replace(old_time, new_time)
with open(guide, 'w', encoding='utf-8') as f:
f.write(html)
print(f'[OK] guide.html 已更新 ({len(html)} bytes)')
# ═══════════════════════════════════════
# 2. quick-start.html
# ═══════════════════════════════════════
qs = os.path.join(WEBDIR, 'quick-start.html')
with open(qs, 'r', encoding='utf-8') as f:
qhtml = f.read()
# (a) 版本号
qhtml = qhtml.replace('v1.5 |', 'v2.0 |')
qhtml = qhtml.replace('29 Hooks', '34 Hooks')
qhtml = qhtml.replace('Portable v1.5', 'Portable v2.0')
# (b) 更新启动流程 — 添加 OneClick
old_flow = '''
开代理
➔
双击 Bookworm
➔
等横幅出现
➔
开始工作
'''
new_flow = '''
开代理
➔
双击 Bookworm
➔
等横幅出现
➔
开始工作
全新电脑? 用 OneClick 一键安装器
下载 Bookworm-OneClick.bat (Win11) / *-Win10.bat (Win10) / *-Mac.sh (macOS) → 双击即装
自动安装 Node.js + Git + Claude Code + Bookworm,零依赖
'''
qhtml = qhtml.replace(old_flow, new_flow)
# (c) 启动表添加 OneClick 行
old_startup_table_end = '| 命令行启动 | '
new_startup_row = '''
| 首次安装 | 双击 Bookworm-OneClick.bat (全自动装依赖+配置+启动) |
| 命令行启动 | '''
qhtml = qhtml.replace(old_startup_table_end, new_startup_row)
with open(qs, 'w', encoding='utf-8') as f:
f.write(qhtml)
print(f'[OK] quick-start.html 已更新 ({len(qhtml)} bytes)')
# ═══════════════════════════════════════
# 3. guide-mac.html (同步版本号)
# ═══════════════════════════════════════
guide_mac = os.path.join(WEBDIR, 'guide-mac.html')
if os.path.exists(guide_mac):
with open(guide_mac, 'r', encoding='utf-8') as f:
mhtml = f.read()
mhtml = mhtml.replace('29 Hooks', '34 Hooks')
mhtml = mhtml.replace('Portable v1.5', 'Portable v2.0')
mhtml = mhtml.replace('v1.5 |', 'v2.0 |')
# 添加 OneClick Mac 下载按钮 (如有旧按钮替换)
old_mac_dl = 'Bookworm-Setup.sh'
new_mac_dl = '/download/Bookworm-OneClick-Mac.sh'
mhtml = mhtml.replace('href="/Bookworm-Setup.sh"', f'href="{new_mac_dl}"')
with open(guide_mac, 'w', encoding='utf-8') as f:
f.write(mhtml)
print(f'[OK] guide-mac.html 已更新 ({len(mhtml)} bytes)')
print('\n[DONE] 所有页面更新完成')