feat: hide command window
This commit is contained in:
parent
bbe2ef4e8e
commit
e8dbcf819b
@ -4,7 +4,7 @@ use crate::{
|
|||||||
utils::{dirs::app_home_dir, fetch::fetch_profile, sysopt::SysProxyConfig},
|
utils::{dirs::app_home_dir, fetch::fetch_profile, sysopt::SysProxyConfig},
|
||||||
};
|
};
|
||||||
use serde_yaml::Mapping;
|
use serde_yaml::Mapping;
|
||||||
use std::process::Command;
|
use std::{path::PathBuf, process::Command};
|
||||||
use tauri::{api, State};
|
use tauri::{api, State};
|
||||||
|
|
||||||
/// get all profiles from `profiles.yaml`
|
/// get all profiles from `profiles.yaml`
|
||||||
@ -175,10 +175,7 @@ pub fn view_profile(index: usize, profiles_state: State<'_, ProfilesState>) -> R
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
match open_command().arg(path).spawn() {
|
open_path_cmd(path, "failed to open file by `open`")
|
||||||
Ok(_) => Ok(()),
|
|
||||||
Err(_) => Err("failed to open file by `open`".into()),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// restart the sidecar
|
/// restart the sidecar
|
||||||
@ -278,30 +275,35 @@ pub fn kill_sidecars() {
|
|||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn open_app_dir() -> Result<(), String> {
|
pub fn open_app_dir() -> Result<(), String> {
|
||||||
let app_dir = app_home_dir();
|
let app_dir = app_home_dir();
|
||||||
|
open_path_cmd(app_dir, "failed to open app dir")
|
||||||
match open_command().arg(app_dir).spawn() {
|
|
||||||
Ok(_) => Ok(()),
|
|
||||||
Err(_) => Err("failed to open logs dir".into()),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// open logs dir
|
/// open logs dir
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn open_logs_dir() -> Result<(), String> {
|
pub fn open_logs_dir() -> Result<(), String> {
|
||||||
let log_dir = app_home_dir().join("logs");
|
let log_dir = app_home_dir().join("logs");
|
||||||
|
open_path_cmd(log_dir, "failed to open logs dir")
|
||||||
match open_command().arg(log_dir).spawn() {
|
|
||||||
Ok(_) => Ok(()),
|
|
||||||
Err(_) => Err("failed to open logs dir".into()),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// get open/explorer command
|
/// get open/explorer command
|
||||||
fn open_command() -> Command {
|
fn open_path_cmd(dir: PathBuf, err_str: &str) -> Result<(), String> {
|
||||||
let open = if cfg!(target_os = "windows") {
|
#[cfg(target_os = "windows")]
|
||||||
"explorer"
|
{
|
||||||
} else {
|
use std::os::windows::process::CommandExt;
|
||||||
"open"
|
|
||||||
};
|
match Command::new("explorer")
|
||||||
Command::new(open)
|
.creation_flags(0x08000000)
|
||||||
|
.arg(dir)
|
||||||
|
.spawn()
|
||||||
|
{
|
||||||
|
Ok(_) => Ok(()),
|
||||||
|
Err(_) => Err(err_str.into()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
match Command::new("open").arg(dir).spawn() {
|
||||||
|
Ok(_) => Ok(()),
|
||||||
|
Err(_) => Err(err_str.into()),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user