Create src-tauri/ with tauri.conf.json (frameless transparent window, 1200x800 default, system tray), Cargo.toml with tauri v2 dependencies, and main.rs with tray icon click-to-show and global shortcut (Cmd+Shift+A) to toggle window visibility. Auto-updater plugin enabled. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
51 lines
1.8 KiB
Rust
51 lines
1.8 KiB
Rust
// Prevents additional console window on Windows in release.
|
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
|
|
|
use tauri::{
|
|
tray::TrayIconBuilder,
|
|
Manager,
|
|
};
|
|
|
|
fn main() {
|
|
tauri::Builder::default()
|
|
.setup(|app| {
|
|
// Create system tray
|
|
let _tray = TrayIconBuilder::new()
|
|
.tooltip("AIUI")
|
|
.on_tray_icon_event(|tray, event| {
|
|
use tauri::tray::TrayIconEvent;
|
|
if let TrayIconEvent::Click { .. } = event {
|
|
let app = tray.app_handle();
|
|
if let Some(window) = app.get_webview_window("main") {
|
|
let _ = window.show();
|
|
let _ = window.set_focus();
|
|
}
|
|
}
|
|
})
|
|
.build(app)?;
|
|
|
|
// Register global shortcut (Cmd+Shift+A / Ctrl+Shift+A)
|
|
#[cfg(target_os = "macos")]
|
|
let shortcut = "CommandOrControl+Shift+A";
|
|
#[cfg(not(target_os = "macos"))]
|
|
let shortcut = "Ctrl+Shift+A";
|
|
|
|
let app_handle = app.handle().clone();
|
|
app.global_shortcut().on_shortcut(shortcut, move |_app, _shortcut, _event| {
|
|
if let Some(window) = app_handle.get_webview_window("main") {
|
|
if window.is_visible().unwrap_or(false) {
|
|
let _ = window.hide();
|
|
} else {
|
|
let _ = window.show();
|
|
let _ = window.set_focus();
|
|
}
|
|
}
|
|
})?;
|
|
|
|
Ok(())
|
|
})
|
|
.plugin(tauri_plugin_updater::Builder::new().build())
|
|
.run(tauri::generate_context!())
|
|
.expect("error while running tauri application");
|
|
}
|