From 5b416bd3bffd7d6740db1da11ff36fa30a7ecb30 Mon Sep 17 00:00:00 2001 From: xintaofei Date: Sun, 8 Mar 2026 20:40:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dfolder=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E7=9A=84=E5=A4=A7=E5=B0=8F=E7=8A=B6=E6=80=81=E6=9C=AA=E4=BF=9D?= =?UTF-8?q?=E6=8C=81=E4=B8=8A=E6=AC=A1=E7=9A=84=E4=BD=8D=E7=BD=AE=E5=92=8C?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/src/commands/windows.rs | 19 +++++++++++++++++-- src-tauri/src/lib.rs | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/commands/windows.rs b/src-tauri/src/commands/windows.rs index f511330..70726c0 100644 --- a/src-tauri/src/commands/windows.rs +++ b/src-tauri/src/commands/windows.rs @@ -16,6 +16,10 @@ pub struct CommitWindowState { owner_by_commit_label: Mutex>, } +pub fn folder_window_label(folder_id: i32) -> String { + format!("folder-{folder_id}") +} + pub(crate) fn apply_platform_window_style<'a, R, M>( builder: WebviewWindowBuilder<'a, R, M>, ) -> WebviewWindowBuilder<'a, R, M> @@ -208,8 +212,19 @@ pub async fn open_folder_window( .await .map_err(AppCommandError::from)?; - // Create folder window with unique label - let label = format!("folder-{}", uuid::Uuid::new_v4()); + let label = folder_window_label(entry.id); + if let Some(existing) = app.get_webview_window(&label) { + ensure_windows_undecorated(&existing); + let _ = existing.unminimize(); + existing.set_focus().map_err(|e| { + AppCommandError::window("Failed to focus folder window", e.to_string()) + })?; + if let Some(w) = app.get_webview_window("welcome") { + let _ = w.close(); + } + return Ok(()); + } + let url = WebviewUrl::App(format!("folder?id={}", entry.id).into()); let builder = WebviewWindowBuilder::new(&app, &label, url) .title(&entry.name) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 2166fcd..f88fa08 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -74,7 +74,7 @@ pub fn run() { let _ = windows::open_welcome_window(app.handle()); } else { for entry in &open_folders { - let label = format!("folder-{}", uuid::Uuid::new_v4()); + let label = windows::folder_window_label(entry.id); let url = tauri::WebviewUrl::App(format!("folder?id={}", entry.id).into()); let builder = tauri::WebviewWindowBuilder::new(app, &label, url) .title(&entry.name)