From d8997597dc78104cec93e85302709bef9938fb3d Mon Sep 17 00:00:00 2001 From: chenyida7-prog Date: Wed, 26 Aug 2026 17:00:27 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(frontend):=20Enchante=20Agent=20?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E7=BD=AE=E7=81=B0=E5=BC=80=E5=85=B3=20+=20?= =?UTF-8?q?=E5=8F=82=E8=80=83=E4=BD=BF=E7=94=A8=E6=89=8B=E5=86=8C=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=EF=BC=8C=E5=81=9C=E7=94=A8=20agent=20deeplink?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enchante 的 Agent deeplink(enchante://agent/install)在真机上验证不可靠 (即便 PR #3 补上了缺失的顶层 name 字段,deeplink 本身对 Enchanté 版本/环境的 依赖仍不稳定),改为引导用户直接看使用手册,避免继续给一个不可靠的安装入口。 改动范围仅 Enchante + agent 这一格: - 设置弹窗 Agent 分组、首次引导 2.2 结论页,Enchante 那一行都改成不可点的置灰 开关(视觉与 Hooks 分组里 Enchante 那行「平台原生不支持」的置灰渲染一致), 描述文字改为「参考使用手册」,旁边加一个「查看手册」链接。 - store.js: usesDeeplink() 收窄为仅 Enchante+MCP;新增 isEnchanteAgentManual() 判定 + openEnchanteAgentManual() 打开手册。 - desktop/main.js + preload.js: 新增独立的 open-manual IPC 通道,用 shell.openPath 打开手册文件。没有复用 open-external,因为那个通道专门 block 了 file: 前缀(避免渲染层任意打开本地文件/命令);手册路径由主进程硬编码, 渲染层不传参,同样是为了不给渲染层传任意本地路径的口子。 TODO(分发前必须替换,已在代码里标注):MANUAL_PATH 目前是本机开发路径占位, 正式版应指向打包进 app 资源目录的手册文件,并加入 electron-builder 的 extraResources / build-backend datas。 Enchante 的 MCP deeplink、其它平台的 Agent 配置均未改动。 测试:只跑了改动直接影响的静态结构测试(不含全局前端/浏览器测试套件): pytest tests/frontend/test_stage3.py::TestStage3StaticStructure # 16 passed pytest tests/frontend/test_stage3.py::TestStage3Build # 1 passed(对新 build 的 standalone 断言) 同时更新了这两类测试里跟 Agent deeplink 按钮相关的断言(按钮已移除、改为手册引导), 以及一个受影响的浏览器测试(TestStage3Browser,未在本地跑,留给 review/CI)。 --- desktop/main.js | 22 +++++++++++++++++++++ desktop/preload.js | 5 +++++ frontend/css/components.css | 12 ++++++++++++ frontend/index.html | 37 ++++++++++++++++++++++------------- frontend/js/store.js | 29 +++++++++++++++++++++++++-- tests/frontend/test_stage3.py | 36 ++++++++++++++++++++++------------ 6 files changed, 112 insertions(+), 29 deletions(-) diff --git a/desktop/main.js b/desktop/main.js index 902f750..93abc3b 100644 --- a/desktop/main.js +++ b/desktop/main.js @@ -477,6 +477,28 @@ app.whenReady().then(async () => { } }); + // ── 使用手册系统级打开(IPC)────────────────────────────── + // Enchante 的 Agent deeplink 在真机验证不可靠(2026-08-26),改为引导用户看使用 + // 手册。手册是本地文件,open-external 专门 block 了 file: 前缀(避免渲染层任意打 + // 开本地文件/命令),所以走独立的、路径由主进程硬编码(渲染层不传路径)的 IPC 通 + // 道,用 shell.openPath 交给系统默认程序(.html → 默认浏览器)打开。 + // + // TODO(分发前替换):MANUAL_PATH 目前是本机开发路径占位,正式版应改为打包进 app + // 资源目录的手册文件(如 path.join(process.resourcesPath, "docs", "MyKnowledge使用手册.html")), + // 并把手册一并加入 electron-builder 的 extraResources / build-backend datas。 + const MANUAL_PATH = + "/Users/chenyida/Library/Containers/com.tencent.xinWeChat/Data/Documents/xwechat_files/wxid_6qcy1jhgv90312_a764/msg/file/2026-08/MyKnowledge使用手册3_2.html"; + ipcMain.handle("open-manual", async () => { + try { + const err = await shell.openPath(MANUAL_PATH); + // shell.openPath 失败时返回非空错误字符串(不像 openExternal 那样 reject) + if (err) return { ok: false, error: err }; + return { ok: true }; + } catch (err) { + return { ok: false, error: String(err) }; + } + }); + try { if (DEV_BACKEND_URL) { // 开发模式:直接连开发者后端 diff --git a/desktop/preload.js b/desktop/preload.js index 10d7a87..5dc339e 100644 --- a/desktop/preload.js +++ b/desktop/preload.js @@ -58,3 +58,8 @@ contextBridge.exposeInMainWorld("__mykOnCloseChoice__", (payload) => { contextBridge.exposeInMainWorld("__mykOpenExternal__", (url) => { return ipcRenderer.invoke("open-external", url); }); + +// 使用手册系统级打开(本地文件,路径由主进程硬编码,渲染层不传参,避免任意路径注入) +contextBridge.exposeInMainWorld("__mykOpenManual__", () => { + return ipcRenderer.invoke("open-manual"); +}); diff --git a/frontend/css/components.css b/frontend/css/components.css index c826976..ca797e1 100644 --- a/frontend/css/components.css +++ b/frontend/css/components.css @@ -2561,6 +2561,18 @@ color: var(--text-secondary); font-style: italic; } +/* Enchante Agent「参考使用手册」行内链接:与置灰状态文字同级,不额外抢视觉焦点 */ +.ai-platform-row__manual-link { + margin-left: 6px; + font-size: 12px; + color: var(--accent); + text-decoration: underline; + text-underline-offset: 2px; + cursor: pointer; +} +.ai-platform-row__manual-link:hover { + color: var(--accent-hover, var(--accent)); +} /* ── 连接态(MCP 卡平台行右,平台级四态:not_connected/connected/inactive/lost;置灰仅 !installed) ── */ .ai-platform-row__connection { diff --git a/frontend/index.html b/frontend/index.html index 6f43d58..3f77bf7 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -47,7 +47,7 @@ - + @@ -69,7 +69,7 @@ - + @@ -1743,7 +1743,8 @@ - +