添加8种应用
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/target
|
||||
6134
Cargo.lock
generated
Normal file
6134
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
18
Cargo.toml
Normal file
18
Cargo.toml
Normal file
@@ -0,0 +1,18 @@
|
||||
[package]
|
||||
name = "slint_test"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[[bin]]
|
||||
name = "slint_test"
|
||||
path = "src/main.rs"
|
||||
|
||||
[package.metadata.winres]
|
||||
OriginalFilename = "slint_test.exe"
|
||||
|
||||
[dependencies]
|
||||
slint = "1.4"
|
||||
|
||||
[build-dependencies]
|
||||
slint-build = "1.4"
|
||||
winres = "0.1"
|
||||
3
build.rs
Normal file
3
build.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
slint_build::compile("ui/slint_ui.slint").unwrap();
|
||||
}
|
||||
37
src/main.rs
Normal file
37
src/main.rs
Normal file
@@ -0,0 +1,37 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
use std::process::Command;
|
||||
|
||||
slint::include_modules!();
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let main_window = MainWindow::new().unwrap();
|
||||
|
||||
main_window.on_launch_powershell(|| {
|
||||
let _ = Command::new("cmd").args(["/C", "start powershell"]).spawn();
|
||||
});
|
||||
main_window.on_launch_security_center(|| {
|
||||
// Windows 安全中心
|
||||
let _ = Command::new("cmd").args(["/C", "start windowsdefender:"]).spawn();
|
||||
});
|
||||
main_window.on_launch_math_input_panel(|| {
|
||||
let _ = Command::new("cmd").args(["/C", "start mip"]).spawn();
|
||||
});
|
||||
main_window.on_launch_psr(|| {
|
||||
let _ = Command::new("cmd").args(["/C", "start psr"]).spawn();
|
||||
});
|
||||
main_window.on_launch_notepad(|| {
|
||||
let _ = Command::new("notepad.exe").spawn();
|
||||
});
|
||||
main_window.on_launch_mstsc(|| {
|
||||
let _ = Command::new("mstsc.exe").spawn();
|
||||
});
|
||||
main_window.on_launch_charmap(|| {
|
||||
let _ = Command::new("charmap.exe").spawn();
|
||||
});
|
||||
main_window.on_launch_taskmgr(|| {
|
||||
let _ = Command::new("taskmgr.exe").spawn();
|
||||
});
|
||||
|
||||
let _ = main_window.run();
|
||||
Ok(())
|
||||
}
|
||||
28
ui/slint_ui.slint
Normal file
28
ui/slint_ui.slint
Normal file
@@ -0,0 +1,28 @@
|
||||
// slint_ui.slint
|
||||
import { VerticalBox, Button } from "std-widgets.slint";
|
||||
|
||||
export component MainWindow inherits Window {
|
||||
title: "Windows 系统工具箱";
|
||||
width: 400px;
|
||||
height: 500px;
|
||||
VerticalBox {
|
||||
spacing: 16px;
|
||||
Text { text: "常用系统工具"; font-size: 24px; horizontal-alignment: center; }
|
||||
Button { text: "PowerShell"; clicked => { root.launch_powershell(); } }
|
||||
Button { text: "Windows 安全中心"; clicked => { root.launch_security_center(); } }
|
||||
Button { text: "Math Input Panel"; clicked => { root.launch_math_input_panel(); } }
|
||||
Button { text: "步骤记录器"; clicked => { root.launch_psr(); } }
|
||||
Button { text: "记事本"; clicked => { root.launch_notepad(); } }
|
||||
Button { text: "远程桌面连接"; clicked => { root.launch_mstsc(); } }
|
||||
Button { text: "字符映射表"; clicked => { root.launch_charmap(); } }
|
||||
Button { text: "任务管理器"; clicked => { root.launch_taskmgr(); } }
|
||||
}
|
||||
callback launch_powershell();
|
||||
callback launch_security_center();
|
||||
callback launch_math_input_panel();
|
||||
callback launch_psr();
|
||||
callback launch_notepad();
|
||||
callback launch_mstsc();
|
||||
callback launch_charmap();
|
||||
callback launch_taskmgr();
|
||||
}
|
||||
Reference in New Issue
Block a user