diff --git a/UPDATE_LOG.md b/UPDATE_LOG.md index 3e06358..0281771 100644 --- a/UPDATE_LOG.md +++ b/UPDATE_LOG.md @@ -1,5 +1,11 @@ # UPDATE LOG +## v0.1.4 + +feat: +- beautify icons +- add system tray menu + ## v0.1.3 fix: only mac supports `TitleBarStyle` diff --git a/assets/chat.png b/assets/chat.png index f9c5254..917817b 100644 Binary files a/assets/chat.png and b/assets/chat.png differ diff --git a/assets/install.png b/assets/install.png index 5fdc7b5..d00f5db 100644 Binary files a/assets/install.png and b/assets/install.png differ diff --git a/logo.png b/logo.png index 22522b1..58c06c5 100644 Binary files a/logo.png and b/logo.png differ diff --git a/src-tauri/icons/128x128.png b/src-tauri/icons/128x128.png index 829014f..242123d 100644 Binary files a/src-tauri/icons/128x128.png and b/src-tauri/icons/128x128.png differ diff --git a/src-tauri/icons/128x128@2x.png b/src-tauri/icons/128x128@2x.png index 4762e03..ba5288a 100644 Binary files a/src-tauri/icons/128x128@2x.png and b/src-tauri/icons/128x128@2x.png differ diff --git a/src-tauri/icons/32x32.png b/src-tauri/icons/32x32.png index 94c350f..792992a 100644 Binary files a/src-tauri/icons/32x32.png and b/src-tauri/icons/32x32.png differ diff --git a/src-tauri/icons/Square107x107Logo.png b/src-tauri/icons/Square107x107Logo.png index f454c0c..caa9bf6 100644 Binary files a/src-tauri/icons/Square107x107Logo.png and b/src-tauri/icons/Square107x107Logo.png differ diff --git a/src-tauri/icons/Square142x142Logo.png b/src-tauri/icons/Square142x142Logo.png index 5ea9fe6..87a8ef6 100644 Binary files a/src-tauri/icons/Square142x142Logo.png and b/src-tauri/icons/Square142x142Logo.png differ diff --git a/src-tauri/icons/Square150x150Logo.png b/src-tauri/icons/Square150x150Logo.png index 321589e..69fd3c5 100644 Binary files a/src-tauri/icons/Square150x150Logo.png and b/src-tauri/icons/Square150x150Logo.png differ diff --git a/src-tauri/icons/Square284x284Logo.png b/src-tauri/icons/Square284x284Logo.png index fd65fea..e104317 100644 Binary files a/src-tauri/icons/Square284x284Logo.png and b/src-tauri/icons/Square284x284Logo.png differ diff --git a/src-tauri/icons/Square30x30Logo.png b/src-tauri/icons/Square30x30Logo.png index bc8a7cc..c92cbd0 100644 Binary files a/src-tauri/icons/Square30x30Logo.png and b/src-tauri/icons/Square30x30Logo.png differ diff --git a/src-tauri/icons/Square310x310Logo.png b/src-tauri/icons/Square310x310Logo.png index dfc7527..b374869 100644 Binary files a/src-tauri/icons/Square310x310Logo.png and b/src-tauri/icons/Square310x310Logo.png differ diff --git a/src-tauri/icons/Square44x44Logo.png b/src-tauri/icons/Square44x44Logo.png index 481ffb1..0f4e0a6 100644 Binary files a/src-tauri/icons/Square44x44Logo.png and b/src-tauri/icons/Square44x44Logo.png differ diff --git a/src-tauri/icons/Square71x71Logo.png b/src-tauri/icons/Square71x71Logo.png index 9666826..ccc10c4 100644 Binary files a/src-tauri/icons/Square71x71Logo.png and b/src-tauri/icons/Square71x71Logo.png differ diff --git a/src-tauri/icons/Square89x89Logo.png b/src-tauri/icons/Square89x89Logo.png index 000540d..b75aa30 100644 Binary files a/src-tauri/icons/Square89x89Logo.png and b/src-tauri/icons/Square89x89Logo.png differ diff --git a/src-tauri/icons/StoreLogo.png b/src-tauri/icons/StoreLogo.png index ddd488c..54cd253 100644 Binary files a/src-tauri/icons/StoreLogo.png and b/src-tauri/icons/StoreLogo.png differ diff --git a/src-tauri/icons/icon.icns b/src-tauri/icons/icon.icns index 893845f..62dae91 100644 Binary files a/src-tauri/icons/icon.icns and b/src-tauri/icons/icon.icns differ diff --git a/src-tauri/icons/icon.ico b/src-tauri/icons/icon.ico index 0e5a814..8109a20 100644 Binary files a/src-tauri/icons/icon.ico and b/src-tauri/icons/icon.ico differ diff --git a/src-tauri/icons/icon.png b/src-tauri/icons/icon.png index 0bcc90d..fbe2fa0 100644 Binary files a/src-tauri/icons/icon.png and b/src-tauri/icons/icon.png differ diff --git a/src-tauri/src/app/menu.rs b/src-tauri/src/app/menu.rs index 41fd16e..2aed48f 100644 --- a/src-tauri/src/app/menu.rs +++ b/src-tauri/src/app/menu.rs @@ -1,7 +1,8 @@ use crate::utils; use tauri::{ utils::assets::EmbeddedAssets, AboutMetadata, AppHandle, Context, CustomMenuItem, Manager, - Menu, MenuItem, Submenu, SystemTrayEvent, WindowMenuEvent, + Menu, MenuItem, Submenu, SystemTray, SystemTrayEvent, SystemTrayMenu, SystemTrayMenuItem, + WindowMenuEvent, }; // --- Menu @@ -82,56 +83,35 @@ pub fn init(context: &Context) -> Menu { pub fn menu_handler(event: WindowMenuEvent) { let win = Some(event.window()).unwrap(); let app = win.app_handle(); + let script_path = utils::script_path().to_string_lossy().to_string(); + let issues_url = "https://github.com/lencx/ChatGPT/issues".to_string(); match event.menu_item_id() { // App - "inject_script" => { - tauri::api::shell::open( - &app.shell_scope(), - utils::script_path().to_string_lossy(), - None, - ) - .unwrap(); - } + "inject_script" => inject_script(&app, script_path), // View - "go_back" => { - win.eval("window.history.go(-1)").unwrap(); - } - "go_forward" => { - win.eval("window.history.go(1)").unwrap(); - } - "scroll_top" => { - win.eval( + "reload" => win.eval("window.location.reload()").unwrap(), + "go_back" => win.eval("window.history.go(-1)").unwrap(), + "go_forward" => win.eval("window.history.go(1)").unwrap(), + "scroll_top" => win + .eval( r#"window.scroll({ top: 0, left: 0, behavior: "smooth" - })"#, + })"#, ) - .unwrap(); - } - "scroll_bottom" => { - win.eval( + .unwrap(), + "scroll_bottom" => win + .eval( r#"window.scroll({ top: document.body.scrollHeight, left: 0, - behavior: "smooth", - })"#, + behavior: "smooth"})"#, ) - .unwrap(); - } - "reload" => { - win.eval("window.location.reload()").unwrap(); - } + .unwrap(), // Help - "report_bug" => { - tauri::api::shell::open( - &app.shell_scope(), - "https://github.com/lencx/ChatGPT/issues", - None, - ) - .unwrap(); - } + "report_bug" => inject_script(&app, issues_url), "dev_tools" => { win.open_devtools(); win.close_devtools(); @@ -140,20 +120,37 @@ pub fn menu_handler(event: WindowMenuEvent) { } } +// --- SystemTray Menu +pub fn tray_menu() -> SystemTray { + SystemTray::new().with_menu( + SystemTrayMenu::new() + .add_item(CustomMenuItem::new("show".to_string(), "Show ChatGPT")) + .add_item(CustomMenuItem::new("hide".to_string(), "Hide ChatGPT")) + .add_item(CustomMenuItem::new( + "inject_script".to_string(), + "Inject Script", + )) + .add_native_item(SystemTrayMenuItem::Separator) + .add_item(CustomMenuItem::new("quit".to_string(), "Quit ChatGPT")), + ) +} + // --- SystemTray Event pub fn tray_handler(app: &AppHandle, event: SystemTrayEvent) { - if let SystemTrayEvent::LeftClick { - position: _, - size: _, - .. - } = event - { - let win = app.get_window("core").unwrap(); - if win.is_visible().unwrap() { - win.hide().unwrap(); - } else { - win.show().unwrap(); - win.set_focus().unwrap(); + let script_path = utils::script_path().to_string_lossy().to_string(); + let win = app.get_window("core").unwrap(); + + if let SystemTrayEvent::MenuItemClick { id, .. } = event { + match id.as_str() { + "quit" => std::process::exit(0), + "show" => win.show().unwrap(), + "hide" => win.hide().unwrap(), + "inject_script" => inject_script(app, script_path), + _ => (), } } } + +pub fn inject_script(app: &AppHandle, path: String) { + tauri::api::shell::open(&app.shell_scope(), path, None).unwrap(); +} diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 349b234..5f07551 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -7,7 +7,6 @@ mod app; mod utils; use app::{cmd, menu, setup}; -use tauri::SystemTray; fn main() { let context = tauri::generate_context!(); @@ -16,7 +15,7 @@ fn main() { .invoke_handler(tauri::generate_handler![cmd::drag_window, cmd::fullscreen]) .setup(setup::init) .menu(menu::init(&context)) - .system_tray(SystemTray::new()) + .system_tray(menu::tray_menu()) .on_menu_event(menu::menu_handler) .on_system_tray_event(menu::tray_handler) .run(context)