feat: add simple tray icon
This commit is contained in:
@@ -36,7 +36,7 @@ function App() {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => ark.open_editor()}
|
onClick={() => ark.open_editor()}
|
||||||
className="inline-flex h-8 w-max items-center justify-center gap-1 rounded-full bg-blue-500 px-3 text-sm font-medium text-white"
|
className="inline-flex h-7 w-max items-center justify-center gap-1 rounded-full bg-blue-500 px-2.5 text-sm font-medium text-white hover:bg-blue-600"
|
||||||
>
|
>
|
||||||
<EditIcon className="size-4" />
|
<EditIcon className="size-4" />
|
||||||
New
|
New
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
pub mod commands;
|
pub mod commands;
|
||||||
pub mod nostr;
|
pub mod nostr;
|
||||||
|
pub mod tray;
|
||||||
|
|
||||||
use age::secrecy::ExposeSecret;
|
use age::secrecy::ExposeSecret;
|
||||||
use keyring::Entry;
|
use keyring::Entry;
|
||||||
@@ -19,9 +20,9 @@ pub struct Nostr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let ctx = tauri::generate_context!();
|
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.setup(|app| {
|
.setup(|app| {
|
||||||
|
let _tray = tray::create_tray(app.handle()).unwrap();
|
||||||
let handle = app.handle().clone();
|
let handle = app.handle().clone();
|
||||||
let config_dir = handle.path().app_config_dir().unwrap();
|
let config_dir = handle.path().app_config_dir().unwrap();
|
||||||
let keyring_entry = Entry::new("Lume Secret Storage", "AppKey").unwrap();
|
let keyring_entry = Entry::new("Lume Secret Storage", "AppKey").unwrap();
|
||||||
@@ -120,7 +121,7 @@ fn main() {
|
|||||||
commands::folder::get_all_nsecs,
|
commands::folder::get_all_nsecs,
|
||||||
commands::opg::fetch_opg,
|
commands::opg::fetch_opg,
|
||||||
])
|
])
|
||||||
.build(ctx)
|
.build(tauri::generate_context!())
|
||||||
.expect("error while running tauri application")
|
.expect("error while running tauri application")
|
||||||
.run(|_app_handle, event| match event {
|
.run(|_app_handle, event| match event {
|
||||||
tauri::RunEvent::ExitRequested { api, .. } => {
|
tauri::RunEvent::ExitRequested { api, .. } => {
|
||||||
|
|||||||
40
src-tauri/src/tray.rs
Normal file
40
src-tauri/src/tray.rs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
use tauri::{tray::ClickType, Manager, Runtime};
|
||||||
|
|
||||||
|
pub fn create_tray<R: Runtime>(app: &tauri::AppHandle<R>) -> tauri::Result<()> {
|
||||||
|
let menu = tauri::menu::MenuBuilder::new(app)
|
||||||
|
.item(&tauri::menu::MenuItem::with_id(app, "quit", "Quit", true, None::<&str>).unwrap())
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let tray = tauri::tray::TrayIconBuilder::with_id("main_tray")
|
||||||
|
.tooltip("Lume")
|
||||||
|
.icon(tauri::Icon::Rgba {
|
||||||
|
rgba: include_bytes!("../icons/icon.png").to_vec(),
|
||||||
|
width: 500,
|
||||||
|
height: 500,
|
||||||
|
})
|
||||||
|
.icon_as_template(true)
|
||||||
|
.menu(&menu)
|
||||||
|
.build(app)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
tray.on_menu_event(move |app, event| match event.id.0.as_str() {
|
||||||
|
"quit" => {
|
||||||
|
let handle = app.app_handle();
|
||||||
|
handle.exit(0);
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
});
|
||||||
|
|
||||||
|
tray.on_tray_icon_event(|tray, event| {
|
||||||
|
if event.click_type == ClickType::Left {
|
||||||
|
let app = tray.app_handle();
|
||||||
|
if let Some(window) = app.get_webview_window("main") {
|
||||||
|
let _ = window.show();
|
||||||
|
let _ = window.set_focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -1,115 +1,110 @@
|
|||||||
{
|
{
|
||||||
"$schema": "../node_modules/@tauri-apps/cli/schema.json",
|
"$schema": "../node_modules/@tauri-apps/cli/schema.json",
|
||||||
"productName": "Lume",
|
"productName": "Lume",
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"identifier": "nu.lume.Lume",
|
"identifier": "nu.lume.Lume",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeBuildCommand": "pnpm run build",
|
"beforeBuildCommand": "pnpm run build",
|
||||||
"beforeDevCommand": "pnpm desktop:dev",
|
"beforeDevCommand": "pnpm desktop:dev",
|
||||||
"devUrl": "http://localhost:3000",
|
"devUrl": "http://localhost:3000",
|
||||||
"frontendDist": "../dist"
|
"frontendDist": "../dist"
|
||||||
},
|
},
|
||||||
"app": {
|
"app": {
|
||||||
"macOSPrivateApi": true,
|
"macOSPrivateApi": true,
|
||||||
"withGlobalTauri": true,
|
"withGlobalTauri": true,
|
||||||
"security": {
|
"security": {
|
||||||
"assetProtocol": {
|
"assetProtocol": {
|
||||||
"enable": true,
|
"enable": true,
|
||||||
"scope": [
|
"scope": [
|
||||||
"$APPDATA/*",
|
"$APPDATA/*",
|
||||||
"$DATA/*",
|
"$DATA/*",
|
||||||
"$LOCALDATA/*",
|
"$LOCALDATA/*",
|
||||||
"$DESKTOP/*",
|
"$DESKTOP/*",
|
||||||
"$DOCUMENT/*",
|
"$DOCUMENT/*",
|
||||||
"$DOWNLOAD/*",
|
"$DOWNLOAD/*",
|
||||||
"$HOME/*",
|
"$HOME/*",
|
||||||
"$PICTURE/*",
|
"$PICTURE/*",
|
||||||
"$PUBLIC/*",
|
"$PUBLIC/*",
|
||||||
"$VIDEO/*",
|
"$VIDEO/*",
|
||||||
"$APPCONFIG/*",
|
"$APPCONFIG/*",
|
||||||
"$RESOURCE/*"
|
"$RESOURCE/*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
"trayIcon": {
|
},
|
||||||
"id": "lume-tray",
|
"bundle": {
|
||||||
"tooltip": "Lume",
|
"licenseFile": "../LICENSE",
|
||||||
"iconPath": "icons/tray.png"
|
"longDescription": "nostr client for desktop",
|
||||||
}
|
"shortDescription": "nostr client",
|
||||||
},
|
"targets": "all",
|
||||||
"bundle": {
|
"active": true,
|
||||||
"licenseFile": "../LICENSE",
|
"category": "SocialNetworking",
|
||||||
"longDescription": "nostr client for desktop",
|
"resources": ["resources/*", "./locales/*"],
|
||||||
"shortDescription": "nostr client",
|
"icon": [
|
||||||
"targets": "all",
|
"icons/32x32.png",
|
||||||
"active": true,
|
"icons/128x128.png",
|
||||||
"category": "SocialNetworking",
|
"icons/128x128@2x.png",
|
||||||
"resources": ["resources/*", "./locales/*"],
|
"icons/icon.icns",
|
||||||
"icon": [
|
"icons/icon.ico"
|
||||||
"icons/32x32.png",
|
],
|
||||||
"icons/128x128.png",
|
"linux": {
|
||||||
"icons/128x128@2x.png",
|
"appimage": {
|
||||||
"icons/icon.icns",
|
"bundleMediaFramework": true,
|
||||||
"icons/icon.ico"
|
"files": {}
|
||||||
],
|
},
|
||||||
"linux": {
|
"deb": {
|
||||||
"appimage": {
|
"files": {}
|
||||||
"bundleMediaFramework": true,
|
},
|
||||||
"files": {}
|
"rpm": {
|
||||||
},
|
"epoch": 0,
|
||||||
"deb": {
|
"files": {},
|
||||||
"files": {}
|
"release": "1"
|
||||||
},
|
}
|
||||||
"rpm": {
|
},
|
||||||
"epoch": 0,
|
"macOS": {
|
||||||
"files": {},
|
"dmg": {
|
||||||
"release": "1"
|
"appPosition": {
|
||||||
}
|
"x": 180,
|
||||||
},
|
"y": 170
|
||||||
"macOS": {
|
},
|
||||||
"dmg": {
|
"applicationFolderPosition": {
|
||||||
"appPosition": {
|
"x": 480,
|
||||||
"x": 180,
|
"y": 170
|
||||||
"y": 170
|
},
|
||||||
},
|
"windowSize": {
|
||||||
"applicationFolderPosition": {
|
"height": 400,
|
||||||
"x": 480,
|
"width": 660
|
||||||
"y": 170
|
}
|
||||||
},
|
},
|
||||||
"windowSize": {
|
"files": {},
|
||||||
"height": 400,
|
"minimumSystemVersion": "10.15"
|
||||||
"width": 660
|
},
|
||||||
}
|
"windows": {
|
||||||
},
|
"allowDowngrades": true,
|
||||||
"files": {},
|
"certificateThumbprint": null,
|
||||||
"minimumSystemVersion": "10.15"
|
"digestAlgorithm": "sha256",
|
||||||
},
|
"nsis": null,
|
||||||
"windows": {
|
"timestampUrl": null,
|
||||||
"allowDowngrades": true,
|
"tsp": false,
|
||||||
"certificateThumbprint": null,
|
"webviewFixedRuntimePath": null,
|
||||||
"digestAlgorithm": "sha256",
|
"webviewInstallMode": {
|
||||||
"nsis": null,
|
"silent": true,
|
||||||
"timestampUrl": null,
|
"type": "downloadBootstrapper"
|
||||||
"tsp": false,
|
},
|
||||||
"webviewFixedRuntimePath": null,
|
"wix": null
|
||||||
"webviewInstallMode": {
|
}
|
||||||
"silent": true,
|
},
|
||||||
"type": "downloadBootstrapper"
|
"plugins": {
|
||||||
},
|
"updater": {
|
||||||
"wix": null
|
"active": true,
|
||||||
}
|
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEU3OTdCMkM3RjU5QzE2NzkKUldSNUZwejF4N0tYNTVHYjMrU0JkL090SlEyNUVLYU5TM2hTU3RXSWtEWngrZWJ4a0pydUhXZHEK",
|
||||||
},
|
"windows": {
|
||||||
"plugins": {
|
"installMode": "quiet"
|
||||||
"updater": {
|
},
|
||||||
"active": true,
|
"endpoints": [
|
||||||
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEU3OTdCMkM3RjU5QzE2NzkKUldSNUZwejF4N0tYNTVHYjMrU0JkL090SlEyNUVLYU5TM2hTU3RXSWtEWngrZWJ4a0pydUhXZHEK",
|
"https://lus.reya3772.workers.dev/v1/{{target}}/{{arch}}/{{current_version}}",
|
||||||
"windows": {
|
"https://lus.reya3772.workers.dev/{{target}}/{{current_version}}"
|
||||||
"installMode": "quiet"
|
]
|
||||||
},
|
}
|
||||||
"endpoints": [
|
}
|
||||||
"https://lus.reya3772.workers.dev/v1/{{target}}/{{arch}}/{{current_version}}",
|
|
||||||
"https://lus.reya3772.workers.dev/{{target}}/{{current_version}}"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user