修复: fetch_url obscura spawn 加 CREATE_NO_WINDOW(治 CMD 窗口闪烁)

This commit is contained in:
lxy
2026-08-01 20:48:50 +08:00
parent 3afaff9efe
commit 31aba79512
+16 -4
View File
@@ -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<String> {
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)) {