添加cmd

This commit is contained in:
zsyg
2025-11-08 10:46:03 +08:00
parent 9a8afd4dae
commit 57d3d839b2
4 changed files with 11 additions and 2 deletions

2
Cargo.lock generated
View File

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

View File

@@ -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"]

View File

@@ -31,6 +31,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
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(())

View File

@@ -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();
}