Skip to content

Commit

Permalink
fix: 🐛 tray icon
Browse files Browse the repository at this point in the history
  • Loading branch information
maqi1520 committed Sep 9, 2024
1 parent 5a65a6f commit e6858c0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
1 change: 0 additions & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
Binary file added src-tauri/icons/appleTrayIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src-tauri/icons/social-square.png
Binary file not shown.
20 changes: 8 additions & 12 deletions src-tauri/src/tray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,20 @@ fn create_window<R: Runtime>(app: &tauri::AppHandle<R>, label: String, path: Str
.center()
.resizable(true)
.visible(false)
.decorations(true);
.decorations(false);
#[cfg(target_os = "macos")]
{
builder
.hidden_title(true)
.title_bar_style(tauri::TitleBarStyle::Overlay)
.decorations(true)
.build()
.unwrap();
}

#[cfg(not(target_os = "macos"))]
{
builder.decorations(true).build().unwrap();
builder.decorations(false).build().unwrap();
}
}

Expand Down Expand Up @@ -81,8 +82,12 @@ pub fn create_tray<R: Runtime>(app: &tauri::AppHandle<R>) -> tauri::Result<()> {
_ => {}
})
.tooltip("MDX editor")
.icon(if cfg!(target_os = "macos") {
Image::from_bytes(include_bytes!("../icons/appleTrayIcon.png"))
} else {
Image::from_bytes(include_bytes!("../icons/128x128.png"))
}?)
.icon_as_template(true)
.icon(Image::from_path("icons/social-square.png")?)
.on_tray_icon_event(|tray, event| match event {
TrayIconEvent::Click {
id: _,
Expand All @@ -92,15 +97,6 @@ pub fn create_tray<R: Runtime>(app: &tauri::AppHandle<R>) -> tauri::Result<()> {
button_state: _,
} => match button {
MouseButton::Left {} => {
// let windows = tray.app_handle().webview_windows();
// for (key, value) in windows {
// if key == "login" || key == "main" {
// value.show().unwrap();
// value.unminimize().unwrap();
// value.set_focus().unwrap();
// }
// }

tray.app_handle().emit("tray_menu", position).unwrap();
}
MouseButton::Right {} => {}
Expand Down

0 comments on commit e6858c0

Please sign in to comment.