Skip to content

Commit

Permalink
🐛 fix: tray icon
Browse files Browse the repository at this point in the history
Signed-off-by: SimonShiki <[email protected]>
  • Loading branch information
SimonShiki committed Aug 13, 2024
1 parent cbab1a3 commit b023648
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use cache_manager::{CacheManager, CacheManagerState};
use media_control::MediaControlState;
use rodio::OutputStream;
use std::sync::{Arc, Condvar, Mutex, Once};
use tauri::{Emitter, Manager};
use tauri::{image::Image, Emitter, Manager};
use std::sync::atomic::AtomicBool;
use tauri::{
menu::{MenuBuilder, MenuItemBuilder},
Expand Down Expand Up @@ -48,8 +48,11 @@ pub async fn run() {
let pause_resume = MenuItemBuilder::with_id("pause_resume", "Pause/Resume").build(app)?;
let quit = MenuItemBuilder::with_id("quit", "Quit").build(app)?;
let menu = MenuBuilder::new(app).items(&[&show, &pause_resume, &quit]).build()?;

let tray = TrayIconBuilder::new()

let _tray = TrayIconBuilder::new()
.title("Cicadas")
.tooltip("Cicadas")
.icon(Image::from_path("./icons/32x32.png")?) // Set the icon using the resolved path
.menu(&menu)
.on_menu_event(move |app, event| {
match event.id().as_ref() {
Expand Down Expand Up @@ -83,9 +86,6 @@ pub async fn run() {
})
.build(app)?;

tray.set_title(Some("Cicadas"))?;
tray.set_tooltip(Some("Cicadas"))?;

Ok(())
})
.on_window_event(|window, event| {
Expand Down
5 changes: 4 additions & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
"icons/[email protected]",
"icons/icon.icns",
"icons/icon.ico"
]
],
"resources": {
"icons/32x32.png": "icons/"
}
}
}
4 changes: 3 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ function App () {
document.addEventListener('contextmenu', disableContextMenu);
return () => {
document.removeEventListener('contextmenu', disableContextMenu);
document.removeEventListener('keydown', disableRefresh);
if (import.meta.env.PROD) {
document.removeEventListener('keydown', disableRefresh);
}
};
}, []);
return (
Expand Down

0 comments on commit b023648

Please sign in to comment.