added system tray

This commit is contained in:
Ren Amamiya 2023-02-25 21:02:56 +07:00
parent 16680f456e
commit 4a5ad7b677
5 changed files with 46 additions and 9 deletions

36
src-tauri/Cargo.lock generated
View File

@ -1393,6 +1393,30 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libappindicator"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db2d3cb96d092b4824cb306c9e544c856a4cb6210c1081945187f7f1924b47e8"
dependencies = [
"glib",
"gtk",
"gtk-sys",
"libappindicator-sys",
"log",
]
[[package]]
name = "libappindicator-sys"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1b3b6681973cea8cc3bce7391e6d7d5502720b80a581c9a95c9cbaf592826aa"
dependencies = [
"gtk-sys",
"libloading",
"once_cell",
]
[[package]]
name = "libc"
version = "0.2.139"
@ -1408,6 +1432,16 @@ dependencies = [
"pkg-config",
]
[[package]]
name = "libloading"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
dependencies = [
"cfg-if",
"winapi",
]
[[package]]
name = "libsqlite3-sys"
version = "0.24.2"
@ -2917,6 +2951,7 @@ dependencies = [
"core-foundation",
"core-graphics",
"crossbeam-channel",
"dirs-next",
"dispatch",
"gdk",
"gdk-pixbuf",
@ -2930,6 +2965,7 @@ dependencies = [
"instant",
"jni",
"lazy_static",
"libappindicator",
"libc",
"log",
"ndk",

View File

@ -16,7 +16,7 @@ tauri-build = { version = "1.2", features = [] }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.2", features = ["clipboard-all", "notification-all", "shell-open", "window-start-dragging"] }
tauri = { version = "1.2", features = ["clipboard-all", "notification-all", "shell-open", "system-tray", "window-start-dragging"] }
webpage = "1.5.0"
[dependencies.tauri-plugin-sql]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 159 KiB

After

Width:  |  Height:  |  Size: 106 KiB

View File

@ -9,7 +9,7 @@ extern crate objc;
use std::time::Duration;
use tauri::{Manager, WindowEvent};
use tauri::{Manager, WindowEvent, SystemTray};
use webpage::{Webpage, WebpageOptions};
use window_ext::WindowExt;
@ -49,6 +49,8 @@ async fn opengraph(url: String) -> OpenGraphResponse {
}
fn main() {
let tray = SystemTray::new();
tauri::Builder::default()
.setup(|app| {
let main_window = app.get_window("main").unwrap();
@ -57,6 +59,7 @@ fn main() {
Ok(())
})
.system_tray(tray)
.invoke_handler(tauri::generate_handler![opengraph])
.plugin(tauri_plugin_sql::Builder::default().build())
.on_window_event(|e| {

View File

@ -37,13 +37,7 @@
"depends": []
},
"externalBin": [],
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
],
"icon": ["icons/32x32.png", "icons/128x128.png", "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico"],
"identifier": "com.uselume.xyz",
"longDescription": "",
"macOS": {
@ -68,6 +62,10 @@
"updater": {
"active": false
},
"systemTray": {
"iconPath": "icons/icon.png",
"iconAsTemplate": true
},
"windows": [
{
"theme": "Dark",