From f8ea694986203077f1487272b46201368f53e9c8 Mon Sep 17 00:00:00 2001 From: xintaofei Date: Fri, 20 Mar 2026 21:35:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dwindows=E4=B8=8B=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E9=83=A8=E5=88=86git=E5=91=BD=E4=BB=A4=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=B8=A6=E4=B8=8ACREATE=5FNO=5FWINDOW=E6=A0=87?= =?UTF-8?q?=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/src/commands/folders.rs | 4 ++-- src-tauri/src/process.rs | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/commands/folders.rs b/src-tauri/src/commands/folders.rs index f27cc7f..9b5155d 100644 --- a/src-tauri/src/commands/folders.rs +++ b/src-tauri/src/commands/folders.rs @@ -3,7 +3,7 @@ use std::fs::{File, OpenOptions}; use std::hash::{Hash, Hasher}; use std::io::Write; use std::path::{Component, Path, PathBuf}; -use std::process::{Command, Stdio}; +use std::process::Stdio; use std::sync::{mpsc, LazyLock, Mutex}; use std::time::{Duration, Instant, UNIX_EPOCH}; @@ -1883,7 +1883,7 @@ fn git_check_ignored_paths( return Ok(HashSet::new()); } - let mut child = Command::new("git") + let mut child = crate::process::std_command("git") .args(["check-ignore", "--stdin", "-z"]) .current_dir(repo_path) .stdin(Stdio::piped()) diff --git a/src-tauri/src/process.rs b/src-tauri/src/process.rs index 4407e6c..22e1ea6 100644 --- a/src-tauri/src/process.rs +++ b/src-tauri/src/process.rs @@ -1,4 +1,5 @@ use std::ffi::{OsStr, OsString}; +use std::process::Command; #[cfg(windows)] use std::path::Path; @@ -6,6 +7,25 @@ use std::path::Path; #[cfg(windows)] const CREATE_NO_WINDOW: u32 = 0x0800_0000; +pub fn configure_std_command(command: &mut Command) -> &mut Command { + #[cfg(windows)] + { + use std::os::windows::process::CommandExt; + command.creation_flags(CREATE_NO_WINDOW); + } + + command +} + +pub fn std_command(program: S) -> Command +where + S: AsRef, +{ + let mut command = Command::new(normalized_program(program)); + configure_std_command(&mut command); + command +} + pub fn configure_tokio_command( command: &mut tokio::process::Command, ) -> &mut tokio::process::Command {