Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

feat(remote): 远端窗口复用壳层建窗真值 build_shell_window

Menghuan1918c51b21339afd
diff --git a/src-tauri/src/bridge/remote.rs b/src-tauri/src/bridge/remote.rs
index d94ff920..2004c63f 100644
--- a/src-tauri/src/bridge/remote.rs
+++ b/src-tauri/src/bridge/remote.rs
@@ -17,7 +17,7 @@
//! remote URL 面与主窗口一致(仅 loopback)。错误遵循仓库约定:
//! `Result<_, String>`,Err 以大写协议前缀开头(如 `REMOTE_URL_INVALID:`)。
-use tauri::{AppHandle, Manager, WebviewUrl, WebviewWindowBuilder};
+use tauri::{AppHandle, Manager};
/// 弹窗窗口 label 前缀(与 capability 的 `remote-*` glob 对应)。
const REMOTE_WINDOW_LABEL_PREFIX: &str = "remote-";
@@ -96,27 +96,11 @@ pub fn remote_open_window(
let _ = existing.set_focus();
return Ok(());
}
- // 加载壳层应用本体(label 即机器寻址:前端 remote-<id> 自切换);
- // 多窗口按 machineId 分 label 天然并存。窗口 chrome 与主窗口逐项对齐
- // (desktop/builder.rs):远端窗口与本体唯一区别是连接的后端。
- let builder = WebviewWindowBuilder::new(
- &app_handle,
- &label,
- WebviewUrl::App("index.html".into()),
- )
- .title(format!("DSH Remote · {machine_id}"))
- .inner_size(1280.0, 840.0)
- .min_inner_size(860.0, 620.0)
- .resizable(true);
- // macOS:原生交通灯 + Overlay 标题栏与 44px 壳层导航栏融合(同主窗口)。
- #[cfg(target_os = "macos")]
- let builder = builder
- .decorations(true)
- .title_bar_style(tauri::TitleBarStyle::Overlay)
- .hidden_title(true)
- .traffic_light_position(tauri::LogicalPosition::new(14.0, 24.0));
- builder
- .build()
+ // 建窗 chrome 全部取壳层建窗真值(`build_shell_window`):52px 导航栏交通灯、
+ // 桥脚本按窗口注入、(Windows)WebView2 共用数据目录等,远端窗口与本体
+ // 唯一区别是连接的后端。label 即机器寻址:前端 remote-<id> 自切换。
+ let title = format!("DSH Remote · {machine_id}");
+ crate::desktop::builder::build_shell_window(&app_handle, label, &title)
.map(|_| ())
.map_err(|err| format!("REMOTE_WINDOW_FAILED: {err}"))
}
diff --git a/src-tauri/src/desktop/builder.rs b/src-tauri/src/desktop/builder.rs
index ef2684f2..f0db6fb0 100644
--- a/src-tauri/src/desktop/builder.rs
+++ b/src-tauri/src/desktop/builder.rs
@@ -617,22 +617,23 @@ pub fn build_main_window(app: &tauri::AppHandle<Wry>) -> tauri::Result<tauri::We
Ok(webview_window)
}
-/// 「文件 → 新建窗口」:以同一 `index.html` 再开一个独立 webview 窗口。
-///
-/// 与主窗口共用同一份平台 chrome、外链/下载接管与(Windows)WebView2 用户数据
-/// 目录,但**不**参与主窗口几何恢复与落盘:`on_window_event` 只对
-/// `MAIN_WINDOW_LABEL` 采样,否则第二个窗口的移动/缩放会覆盖用户保存的主窗口尺寸。
+/// 以壳层 `index.html` 再开一个独立 webview 窗口(`文件 → 新建窗口` 与 SSH 远端
+/// 弹窗共用的建窗真值):与主窗口共用同一份平台 chrome、外链/下载接管、
+/// (Windows)WebView2 用户数据目录与按窗口注入的桥脚本,但**不**参与主窗口
+/// 几何恢复与落盘(`on_window_event` 只对 `MAIN_WINDOW_LABEL` 采样)。
///
/// 只能在异步运行时的命令任务里调用(与 `pet::ensure_pet_window` 同样的约束:
/// `WebviewWindowBuilder::build()` 需要主线程事件循环回包,主线程调用会死锁)。
-pub fn build_extra_window(app: &tauri::AppHandle<Wry>) -> tauri::Result<tauri::WebviewWindow<Wry>> {
- let sequence = EXTRA_WINDOW_SEQ.fetch_add(1, Ordering::SeqCst) + 1;
- let label = format!("window-{sequence}");
+pub fn build_shell_window(
+ app: &tauri::AppHandle<Wry>,
+ label: String,
+ title: &str,
+) -> tauri::Result<tauri::WebviewWindow<Wry>> {
let app_handle = app.clone();
let webview_builder =
WebviewWindowBuilder::new(app, label, WebviewUrl::App("index.html".into()))
- .title("Deepseek Harness Desktop")
+ .title(title)
.inner_size(1280.0, 840.0)
.min_inner_size(860.0, 620.0)
.resizable(true);
@@ -707,6 +708,12 @@ pub fn build_extra_window(app: &tauri::AppHandle<Wry>) -> tauri::Result<tauri::W
Ok(window)
}
+/// 「文件 → 新建窗口」:`window-<N>` 序号 label,chrome 全部取 `build_shell_window`。
+pub fn build_extra_window(app: &tauri::AppHandle<Wry>) -> tauri::Result<tauri::WebviewWindow<Wry>> {
+ let sequence = EXTRA_WINDOW_SEQ.fetch_add(1, Ordering::SeqCst) + 1;
+ build_shell_window(app, format!("window-{sequence}"), "Deepseek Harness Desktop")
+}
+
#[cfg(all(test, windows))]
mod tests {
use super::windows_drag_browser_args;