fix(windows): hide subprocess console windows

This commit is contained in:
t8y2 committed 2026-07-10 09:50:18 +08:00
1 parent b44882d7ba
commit 6671400fd4
15 files changed
+63 -74

No files matched your search

+3 -3
View File
@@ -16,7 +16,7 @@ use dbx_core::path_utils::expand_tilde;
pub fn reveal_in_file_manager(path: &Path) -> Result<(), String> {
#[cfg(target_os = "macos")]
{
std::process::Command::new("open")
dbx_core::process::new_std_command("open")
.arg("-R")
.arg(path)
.spawn()
@@ -30,7 +30,7 @@ pub fn reveal_in_file_manager(path: &Path) -> Result<(), String> {
// after the comma. `Command::arg` does not invoke a shell, so the path
// is forwarded as-is — spaces and non-ASCII characters survive.
let arg = format!("/select,{}", path.display());
std::process::Command::new("explorer")
dbx_core::process::new_std_command("explorer")
.arg(arg)
.spawn()
.map(|_| ())
@@ -40,7 +40,7 @@ pub fn reveal_in_file_manager(path: &Path) -> Result<(), String> {
#[cfg(all(not(target_os = "macos"), not(target_os = "windows")))]
{
let target: PathBuf = path.parent().map(|p| p.to_path_buf()).unwrap_or_else(|| path.to_path_buf());
std::process::Command::new("xdg-open")
dbx_core::process::new_std_command("xdg-open")
.arg(&target)
.spawn()
.map(|_| ())
+1 -1
View File
@@ -18,7 +18,7 @@ pub async fn read_keychain_password(service: String, account: Option<String>) ->
#[cfg(target_os = "macos")]
fn read_keychain_password_blocking(service: String, account: Option<String>) -> Result<String, String> {
let mut cmd = std::process::Command::new("security");
let mut cmd = dbx_core::process::new_std_command("security");
cmd.args(["find-generic-password", "-s", &service, "-w"]);
if let Some(ref acct) = account {
cmd.args(["-a", acct]);
+1 -9
View File
@@ -1,7 +1,6 @@
#[cfg(not(windows))]
use std::env;
use std::path::Path;
use std::process::Command;
use std::time::Duration;
use serde::{Deserialize, Serialize};
@@ -10,8 +9,6 @@ const MCP_PACKAGE_NAME: &str = "@dbx-app/mcp-server";
const MCP_LATEST_URL: &str = "https://registry.npmjs.org/@dbx-app%2fmcp-server/latest";
const MCP_INSTALL_COMMAND: &str = "npm install -g @dbx-app/mcp-server@latest --registry=https://registry.npmjs.org";
const SHELL_COMMAND_MARKER: &str = "__DBX_MCP_COMMAND_OUTPUT_START__";
#[cfg(windows)]
const CREATE_NO_WINDOW: u32 = 0x08000000;
#[derive(Debug, Serialize)]
pub struct McpServerStatus {
@@ -238,13 +235,8 @@ fn command_output(command: &str, args: &[&str]) -> Result<CommandOutput, String>
}
fn run_command(command: &str, args: &[&str]) -> Result<CommandOutput, String> {
let mut cmd = Command::new(command);
let mut cmd = dbx_core::process::new_std_command(command);
cmd.args(args);
#[cfg(windows)]
{
use std::os::windows::process::CommandExt;
cmd.creation_flags(CREATE_NO_WINDOW);
}
let output = cmd.output().map_err(|e| e.to_string())?;
Ok(CommandOutput {
success: output.status.success(),
+3 -3
View File
@@ -206,21 +206,21 @@ fn unique_file_path(dir: &Path, file_name: &str) -> PathBuf {
fn open_path(path: &Path) -> Result<(), String> {
#[cfg(target_os = "macos")]
let mut command = {
let mut command = std::process::Command::new("open");
let mut command = dbx_core::process::new_std_command("open");
command.arg(path);
command
};
#[cfg(target_os = "windows")]
let mut command = {
let mut command = std::process::Command::new("explorer");
let mut command = dbx_core::process::new_std_command("explorer");
command.arg(path);
command
};
#[cfg(all(not(target_os = "macos"), not(target_os = "windows")))]
let mut command = {
let mut command = std::process::Command::new("xdg-open");
let mut command = dbx_core::process::new_std_command("xdg-open");
command.arg(path);
command
};
+3 -1
View File
@@ -127,7 +127,9 @@ fn platform_product_version() -> Option<String> {
#[cfg(any(target_os = "macos", target_os = "windows"))]
fn command_first_line(command: &str, args: &[&str]) -> Option<String> {
let output = std::process::Command::new(command).args(args).output().ok()?;
let mut process = dbx_core::process::new_std_command(command);
process.args(args);
let output = process.output().ok()?;
if !output.status.success() {
return None;
}