Compare commits

..

1 Commits

Author SHA1 Message Date
zsyg
57d3d839b2 添加cmd 2025-11-08 10:46:03 +08:00
4 changed files with 11 additions and 2 deletions

2
Cargo.lock generated
View File

@@ -4062,7 +4062,7 @@ dependencies = [
[[package]] [[package]]
name = "slint_test" name = "slint_test"
version = "0.1.0" version = "0.2.0"
dependencies = [ dependencies = [
"slint", "slint",
"slint-build", "slint-build",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "slint_test" name = "slint_test"
version = "0.1.0" version = "0.2.0"
edition = "2024" edition = "2024"
license = "Apache-2.0" license = "Apache-2.0"
authors = ["3872006562@qq.com"] authors = ["3872006562@qq.com"]

View File

@@ -31,6 +31,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
main_window.on_launch_taskmgr(|| { main_window.on_launch_taskmgr(|| {
let _ = Command::new("taskmgr.exe").spawn(); 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(); let _ = main_window.run();
Ok(()) Ok(())

View File

@@ -16,6 +16,7 @@ export component MainWindow inherits Window {
Button { text: "远程桌面连接"; clicked => { root.launch_mstsc(); } } Button { text: "远程桌面连接"; clicked => { root.launch_mstsc(); } }
Button { text: "字符映射表"; clicked => { root.launch_charmap(); } } Button { text: "字符映射表"; clicked => { root.launch_charmap(); } }
Button { text: "任务管理器"; clicked => { root.launch_taskmgr(); } } Button { text: "任务管理器"; clicked => { root.launch_taskmgr(); } }
Button { text: "CMD"; clicked => { root.launch_cmd(); } }
} }
callback launch_powershell(); callback launch_powershell();
callback launch_security_center(); callback launch_security_center();
@@ -25,4 +26,5 @@ export component MainWindow inherits Window {
callback launch_mstsc(); callback launch_mstsc();
callback launch_charmap(); callback launch_charmap();
callback launch_taskmgr(); callback launch_taskmgr();
callback launch_cmd();
} }