From acdf24ee1692fb92fc01bddbd571eba0bf5a2504 Mon Sep 17 00:00:00 2001 From: "Henry.Huang" Date: Thu, 28 Mar 2024 05:33:48 +0800 Subject: [PATCH] update --- crates/rs-os/readme.md | 12 +++++++++++ crates/rs-os/rs-cross/try-notify/src/main.rs | 22 +++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 crates/rs-os/readme.md diff --git a/crates/rs-os/readme.md b/crates/rs-os/readme.md new file mode 100644 index 0000000..fea27e7 --- /dev/null +++ b/crates/rs-os/readme.md @@ -0,0 +1,12 @@ +# rs-os + +- OS 操作系统 API 相关的库 & 使用示例. + +## rs-cross: + +- 跨平台相关的库 + +### libs: + +- [try-notify](./rs-cross/try-notify): 系统通知(macOS/Windows/Linux) + - 基于: https://github.com/hoodie/notify-rust \ No newline at end of file diff --git a/crates/rs-os/rs-cross/try-notify/src/main.rs b/crates/rs-os/rs-cross/try-notify/src/main.rs index e7a11a9..9cf9da4 100644 --- a/crates/rs-os/rs-cross/try-notify/src/main.rs +++ b/crates/rs-os/rs-cross/try-notify/src/main.rs @@ -1,3 +1,23 @@ +#[cfg(target_os = "macos")] +fn main() -> Result<(), Box> { + use notify_rust::Notification; + + Notification::new() + .summary("Safari Crashed") + .body("Just kidding, this is just the notify_rust example.") + .appname("Toastify") + .icon("Toastify") + .show()?; + + Ok(()) +} + +#[cfg(all(unix, not(target_os = "macos")))] +fn main() { + println!("this is a mac only feature") +} + +#[cfg(target_os = "windows")] fn main() { - println!("Hello, world!"); + println!("this is a mac only feature") }