Skip to content

Commit ebc951a

Browse files
committed
fix
1 parent 51951c5 commit ebc951a

2 files changed

Lines changed: 38 additions & 15 deletions

File tree

src/file_ops.rs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,16 +242,38 @@ fn execute_vector_mode(path: &Path, args: Vec<String>, gui: HashMap<String, Stri
242242
let has_long = args.iter().any(|arg| arg.contains("long"));
243243

244244
let gui_arg = if has_long {
245-
gui.get("long").unwrap_or(&default_empty)
245+
gui.get("long").unwrap_or(&default_empty).clone()
246246
} else {
247-
gui.get("normal").unwrap_or(&default_empty)
247+
gui.get("normal").unwrap_or(&default_empty).clone()
248248
};
249249

250-
if !gui_arg.is_empty() {
251-
command.arg(gui_arg);
252-
}
250+
let path_clone = path.to_path_buf();
251+
252+
std::thread::spawn(move || {
253+
let mut command = std::process::Command::new(path_clone);
254+
255+
for arg in &args {
256+
command.arg(arg);
257+
}
258+
259+
if !gui_arg.is_empty() {
260+
command.arg(gui_arg);
261+
}
253262

254-
let _ = command.spawn();
263+
match command.status() {
264+
Ok(status) => {
265+
if let Some(code) = status.code() {
266+
println!("Exit code: {}", code);
267+
if code == 8 {
268+
crate::msgbox::show_notification("截图保存", "已保存到文件", crate::msgbox::NotifyIconType::Info, 3000);
269+
} else if code == 9 {
270+
crate::msgbox::show_notification("截图保存", "已保存到剪贴板", crate::msgbox::NotifyIconType::Info, 3000);
271+
}
272+
}
273+
}
274+
Err(e) => eprintln!("Failed to execute command: {}", e),
275+
}
276+
});
255277
}
256278

257279
/// 构建截图操作的命令行参数

src/hotkeys.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,12 @@ pub fn set_hotkeys(
5353
// 如果 last_path = true 且 last_used_dir 非空,使用 last_used_dir
5454
// 否则使用 save_path(配置文件中的 dir)
5555
let use_last_path = settings_collected.path.last_path;
56-
let effective_save_path = if use_last_path
57-
&& !settings_collected.path.last_used_dir.as_os_str().is_empty()
58-
{
59-
settings_collected.path.last_used_dir.clone()
60-
} else {
61-
save_path.clone()
62-
};
56+
let effective_save_path =
57+
if use_last_path && !settings_collected.path.last_used_dir.as_os_str().is_empty() {
58+
settings_collected.path.last_used_dir.clone()
59+
} else {
60+
save_path.clone()
61+
};
6362

6463
// 创建共享的当前保存路径状态
6564
let current_save_path: Arc<Mutex<PathBuf>> = Arc::new(Mutex::new(effective_save_path));
@@ -87,7 +86,8 @@ pub fn set_hotkeys(
8786
guard.clone()
8887
};
8988

90-
let args = crate::file_ops::build_capture_args(comp_val, scale_val, &path_to_use, false);
89+
let args =
90+
crate::file_ops::build_capture_args(comp_val, scale_val, &path_to_use, false);
9191
operate_exe(&exe_path_clone, args, gui_clone.clone());
9292
},
9393
);
@@ -204,7 +204,8 @@ pub fn set_hotkeys(
204204
guard.clone()
205205
};
206206

207-
let args = crate::file_ops::build_capture_args(comp_val2, scale_val2, &path_to_use, true);
207+
let args =
208+
crate::file_ops::build_capture_args(comp_val2, scale_val2, &path_to_use, true);
208209
operate_exe(&exe_path_clone, args, gui_clone.clone());
209210
},
210211
);

0 commit comments

Comments
 (0)