feat(hermes): Batch 1 §A + §B + P1-3 lazy_deps 优化 - 占位修 + 中文硬编码清 + 自定义 venv 适配

## §A channels.js 占位路由处理
- /h/channels 当前是 487 字节 placeholder
- 已确认 sidebar 没挂入口(getNavItems 不含 channels)
- 路由表保留但加注释表明这是 reserved,完整实现见 Batch 3

## §B config.js i18n 化(清理 5 处硬编码)
- "重新加载" / "保存配置" / "saving…" / "loading…" / "raw yaml editor"
- "配置已保存,建议重启 Hermes Gateway 生效" toast
- 抽 7 个新键到 locales/modules/engine.js(3 语言):
  · hermesConfigEyebrow / hermesConfigReload / hermesConfigSave
  · hermesConfigSaveSuccess / hermesConfigStatusSaving
  · hermesConfigStatusLoading / hermesConfigStatusReady

## P1-3 lazy_deps 校对稿优化(commit b852ebb 的补丁)
hermes_venv_python() 增加 HERMES_PYTHON 环境变量优先级:
1. HERMES_PYTHON env var(适配 brew / uv tool / 容器等自定义 venv)
2. ~/.hermes-venv/{bin/python | Scripts/python.exe}(默认)

allow_lazy_installs 守门:经核实内核 tools.lazy_deps.ensure 内部已检查
security.allow_lazy_installs,禁用时抛 FeatureUnavailable,Rust 端已捕捉
并友好返回错误(无需额外代码)。

## 累计
- 3 个修改文件(hermes/index.js + config.js + engine.js + hermes.rs)
- 7 个新 i18n 键 × 3 语言
- cargo check ✓ + npm build ✓
This commit is contained in:
晴天
2026-05-14 04:51:16 +08:00
parent efade55f61
commit 832bb9a6ef
4 changed files with 27 additions and 5 deletions

View File

@@ -2164,7 +2164,19 @@ pub async fn hermes_read_config_full() -> Result<Value, String> {
// ---------------------------------------------------------------------------
/// 找到 Hermes venv 的 Python 解释器路径
///
/// 优先级P1-3 优化):
/// 1. 环境变量 `HERMES_PYTHON` — 适配自定义 venvbrew / uv tool / 容器等非默认路径)
/// 2. ~/.hermes-venv/bin/python (Unix) 或 ~/.hermes-venv/Scripts/python.exe (Windows)
fn hermes_venv_python() -> Option<PathBuf> {
// 1. HERMES_PYTHON 环境变量优先
if let Ok(custom) = std::env::var("HERMES_PYTHON") {
let p = PathBuf::from(custom);
if p.exists() {
return Some(p);
}
}
// 2. 默认 venv 位置
let venv_dir = dirs::home_dir()?.join(".hermes-venv");
#[cfg(target_os = "windows")]
let py = venv_dir.join("Scripts").join("python.exe");