mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-09-26 21:41:48 +02:00
feat: update to tauri 2.12
- (MSRV bump - Android compiler options update - notification plugin windows7 feature deprecation
This commit is contained in:
@@ -36,10 +36,6 @@ impl<R: Runtime> crate::NotificationBuilder<R> {
|
||||
///
|
||||
/// Returns an error when the notification could not be prepared,
|
||||
/// e.g. when the path of the running executable cannot be resolved on Windows.
|
||||
///
|
||||
/// ## Platform-specific
|
||||
///
|
||||
/// - **Windows**: Not supported on Windows 7 unless the `windows7-compat` Cargo feature is enabled.
|
||||
pub fn show(self) -> crate::Result<()> {
|
||||
let mut notification = imp::Notification::new(self.app.config().identifier.clone());
|
||||
|
||||
@@ -59,11 +55,6 @@ impl<R: Runtime> crate::NotificationBuilder<R> {
|
||||
if let Some(sound) = self.data.sound {
|
||||
notification = notification.sound(sound);
|
||||
}
|
||||
#[cfg(feature = "windows7-compat")]
|
||||
{
|
||||
notification.notify(&self.app)?;
|
||||
}
|
||||
#[cfg(not(feature = "windows7-compat"))]
|
||||
notification.show()?;
|
||||
|
||||
Ok(())
|
||||
@@ -209,14 +200,6 @@ mod imp {
|
||||
/// .run(tauri::generate_context!("test/tauri.conf.json"))
|
||||
/// .expect("error while running tauri application");
|
||||
/// ```
|
||||
///
|
||||
/// ## Platform-specific
|
||||
///
|
||||
/// - **Windows**: Not supported on Windows 7. If your app targets it, enable the `windows7-compat` feature and use [`Self::notify`].
|
||||
#[cfg_attr(
|
||||
all(not(docsrs), feature = "windows7-compat"),
|
||||
deprecated = "This function does not work on Windows 7. Use `Self::notify` instead."
|
||||
)]
|
||||
pub fn show(self) -> crate::Result<()> {
|
||||
let mut notification = notify_rust::Notification::new();
|
||||
if let Some(body) = self.body {
|
||||
@@ -261,70 +244,12 @@ mod imp {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Shows the notification. This API is similar to [`Self::show`], but it also works on Windows 7.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```no_run
|
||||
/// use tauri_plugin_notification::NotificationExt;
|
||||
///
|
||||
/// tauri::Builder::default()
|
||||
/// .setup(move |app| {
|
||||
/// app.notification().builder()
|
||||
/// .title("Tauri")
|
||||
/// .body("Tauri is awesome!")
|
||||
/// .show()
|
||||
/// .unwrap();
|
||||
/// Ok(())
|
||||
/// })
|
||||
/// .run(tauri::generate_context!("test/tauri.conf.json"))
|
||||
/// .expect("error while running tauri application");
|
||||
/// ```
|
||||
/// Shows the notification. Same as [`Self::show`].
|
||||
#[cfg(feature = "windows7-compat")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "windows7-compat")))]
|
||||
#[allow(unused_variables)]
|
||||
pub fn notify<R: tauri::Runtime>(self, app: &tauri::AppHandle<R>) -> crate::Result<()> {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
fn is_windows_7() -> bool {
|
||||
let v = windows_version::OsVersion::current();
|
||||
// windows 7 is 6.1
|
||||
v.major == 6 && v.minor == 1
|
||||
}
|
||||
|
||||
if is_windows_7() {
|
||||
self.notify_win7(app)
|
||||
} else {
|
||||
#[allow(deprecated)]
|
||||
self.show()
|
||||
}
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
#[allow(deprecated)]
|
||||
self.show()
|
||||
}
|
||||
}
|
||||
|
||||
/// Shows the notification on Windows 7.
|
||||
#[cfg(all(windows, feature = "windows7-compat"))]
|
||||
fn notify_win7<R: tauri::Runtime>(self, app: &tauri::AppHandle<R>) -> crate::Result<()> {
|
||||
let app_ = app.clone();
|
||||
let _ = app.clone().run_on_main_thread(move || {
|
||||
let mut notification = win7_notifications::Notification::new();
|
||||
if let Some(body) = self.body {
|
||||
notification.body(&body);
|
||||
}
|
||||
if let Some(title) = self.title {
|
||||
notification.summary(&title);
|
||||
}
|
||||
if let Some(icon) = app_.default_window_icon() {
|
||||
notification.icon(icon.rgba().to_vec(), icon.width(), icon.height());
|
||||
}
|
||||
let _ = notification.show();
|
||||
});
|
||||
|
||||
Ok(())
|
||||
#[deprecated = "Tauri no longer supports Windows 7, use `Self::show` instead."]
|
||||
pub fn notify<R: tauri::Runtime>(self, _app: &tauri::AppHandle<R>) -> crate::Result<()> {
|
||||
self.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user