From 31aba795126f6abd9ec14e128a6e190ad7b73177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=9D=E5=B0=98?= <237809796@qq.com> Date: Sat, 1 Aug 2026 20:48:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:=20fetch=5Furl=20obscura=20s?= =?UTF-8?q?pawn=20=E5=8A=A0=20CREATE=5FNO=5FWINDOW(=E6=B2=BB=20CMD=20?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E9=97=AA=E7=83=81)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/src/commands/ai/fetch_url.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src-tauri/src/commands/ai/fetch_url.rs b/src-tauri/src/commands/ai/fetch_url.rs index 837e4f4..8aec5cc 100644 --- a/src-tauri/src/commands/ai/fetch_url.rs +++ b/src-tauri/src/commands/ai/fetch_url.rs @@ -262,6 +262,12 @@ async fn fetch_with_obscura(url_raw: &str, max_length: usize) -> anyhow::Result< cmd.args(["fetch", "--dump", "markdown", url_raw]) .stdout(std::process::Stdio::piped()) .stderr(std::process::Stdio::piped()); + // CREATE_NO_WINDOW:防 obscura spawn 弹控制台窗口闪烁(对齐 shell.rs build_command)。 + #[cfg(windows)] + { + use std::os::windows::process::CommandExt; + cmd.creation_flags(0x0800_0000); + } let output = match tokio::time::timeout( Duration::from_secs(OBSCURA_TIMEOUT_SECS), @@ -343,11 +349,17 @@ fn find_obscura() -> Option { let (tx, rx) = std::sync::mpsc::channel(); let cand_owned = cand.to_string(); std::thread::spawn(move || { - let out = std::process::Command::new(&cand_owned) - .arg("--version") + let mut c = std::process::Command::new(&cand_owned); + c.arg("--version") .stdout(std::process::Stdio::null()) - .stderr(std::process::Stdio::null()) - .output(); + .stderr(std::process::Stdio::null()); + // CREATE_NO_WINDOW:防 obscura --version 探测弹控制台(每次 fetch_url render=true 都探测,不弹窗)。 + #[cfg(windows)] + { + use std::os::windows::process::CommandExt; + c.creation_flags(0x0800_0000); + } + let out = c.output(); let _ = tx.send(out); }); match rx.recv_timeout(Duration::from_secs(5)) {