diff --git a/Cargo.lock b/Cargo.lock index bf85b04..3d264dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4062,7 +4062,7 @@ dependencies = [ [[package]] name = "slint_test" -version = "0.1.0" +version = "0.2.0" dependencies = [ "slint", "slint-build", diff --git a/Cargo.toml b/Cargo.toml index 8cde540..84a2efb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "slint_test" -version = "0.1.0" +version = "0.2.0" edition = "2024" license = "Apache-2.0" authors = ["3872006562@qq.com"] diff --git a/src/main.rs b/src/main.rs index 7d78a3c..310dae7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,6 +31,13 @@ fn main() -> Result<(), Box> { main_window.on_launch_taskmgr(|| { let _ = Command::new("taskmgr.exe").spawn(); }); + main_window.on_launch_cmd(|| { + if let Ok(user_profile) = std::env::var("USERPROFILE") { + let _ = Command::new("cmd.exe").current_dir(user_profile).spawn(); + } else { + let _ = Command::new("cmd.exe").spawn(); + } + }); let _ = main_window.run(); Ok(()) diff --git a/ui/slint_ui.slint b/ui/slint_ui.slint index 1fdcc1c..5414851 100644 --- a/ui/slint_ui.slint +++ b/ui/slint_ui.slint @@ -16,6 +16,7 @@ export component MainWindow inherits Window { Button { text: "远程桌面连接"; clicked => { root.launch_mstsc(); } } Button { text: "字符映射表"; clicked => { root.launch_charmap(); } } Button { text: "任务管理器"; clicked => { root.launch_taskmgr(); } } + Button { text: "CMD"; clicked => { root.launch_cmd(); } } } callback launch_powershell(); callback launch_security_center(); @@ -25,4 +26,5 @@ export component MainWindow inherits Window { callback launch_mstsc(); callback launch_charmap(); callback launch_taskmgr(); + callback launch_cmd(); }