From 0cf86c5c3928a2daf73be00e1c940c5bddd78491 Mon Sep 17 00:00:00 2001 From: Xianren Studio Date: Thu, 13 Aug 2026 15:13:12 +0800 Subject: [PATCH] fix: enable custom-protocol feature so release embeds frontend assets --- README.md | 19 ++++++++++++++++++- apps/desktop/Cargo.toml | 5 +++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1afb997..52b3590 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,24 @@ npm --prefix ui install npm --prefix apps/desktop run dev ``` +> **重要:调试版(debug)exe 不能直接双击运行。** +> `target\debug\xianren-desktop.exe` 在调试构建下会去连 Vite 开发服务器 +> (`http://localhost:5173`),不先启动前端就会显示“拒绝连接”,并会附带一个空终端窗口。 +> 开发时请始终使用 `npm --prefix apps/desktop run dev`。 + +**直接双击运行的正式版**: + +```powershell +# 编译正式版(内嵌前端页面,无终端窗口;必须带 custom-protocol 特性) +cargo build --release -p xianren-desktop --features custom-protocol + +# 运行 +.\target\release\xianren-desktop.exe +``` + +正式版双击后:设置页确认引擎路径 → 模型库导入 GGUF → 聊天页选择模型即可对话。 +如需安装包,可用 `npm --prefix apps/desktop run build`(tauri build 会自动启用该特性并打 NSIS 安装包)。 + ## 常用脚本 | 脚本 | 用途 | @@ -66,4 +84,3 @@ npm --prefix apps/desktop run dev - `xianren.db`:SQLite 数据库 可在应用“设置”页修改模型目录与引擎路径。 - diff --git a/apps/desktop/Cargo.toml b/apps/desktop/Cargo.toml index de6db1a..88208b1 100644 --- a/apps/desktop/Cargo.toml +++ b/apps/desktop/Cargo.toml @@ -8,6 +8,11 @@ rust-version.workspace = true name = "xianren_desktop_lib" crate-type = ["staticlib", "cdylib", "rlib"] +[features] +# 生产构建启用该特性后,前端资源会内嵌进 exe 并通过自定义协议加载; +# 开发模式(tauri dev)不启用,继续使用 Vite 开发服务器。 +custom-protocol = ["tauri/custom-protocol"] + [build-dependencies] tauri-build = { version = "2", features = [] }