Phase 2 complete.
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
use serde::Serialize;
|
||||
use tauri::{Manager, GlobalShortcutManager};
|
||||
use tauri::api::notification::Notification;
|
||||
|
||||
#[derive(Serialize, Clone)]
|
||||
struct Keys {
|
||||
@@ -11,19 +13,20 @@ struct Keys {
|
||||
|
||||
#[tauri::command]
|
||||
fn get_env_keys() -> Keys {
|
||||
// In development, the CWD is `src-tauri/target/debug`, so we go up two levels
|
||||
// to find the project root.
|
||||
if let Ok(path) = std::env::current_dir() {
|
||||
if let Some(p) = path.ancestors().nth(2) {
|
||||
let env_path = p.join(".env");
|
||||
dotenvy::from_path(env_path).ok();
|
||||
}
|
||||
} else {
|
||||
dotenvy::dotenv().ok();
|
||||
// Load .env file from the project root. This is more robust than assuming a fixed
|
||||
// directory structure, as it searches upwards from the executable's location.
|
||||
match dotenvy::dotenv() {
|
||||
Ok(_) => println!("✅ [Rust] Successfully loaded .env file."),
|
||||
Err(e) => println!("❌ [Rust] Failed to load .env file: {}", e),
|
||||
}
|
||||
|
||||
let openrouter_api_key = std::env::var("OPENROUTER_API_KEY").ok();
|
||||
let elevenlabs_api_key = std::env::var("ELEVENLABS_API_KEY").ok();
|
||||
|
||||
// Add detailed logging to see what Rust is reading
|
||||
println!("🔑 [Rust] OpenRouter Key Loaded: {}", openrouter_api_key.is_some());
|
||||
println!("🔑 [Rust] ElevenLabs Key Loaded: {}", elevenlabs_api_key.is_some());
|
||||
|
||||
Keys { openrouter_api_key, elevenlabs_api_key }
|
||||
}
|
||||
|
||||
@@ -33,10 +36,41 @@ fn greet(name: &str) -> String {
|
||||
format!("Hello, {}! Welcome to EVE.", name)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn send_notification(app_handle: tauri::AppHandle, title: String, body: String) -> Result<(), String> {
|
||||
Notification::new(&app_handle.config().tauri.bundle.identifier)
|
||||
.title(&title)
|
||||
.body(&body)
|
||||
.show()
|
||||
.map_err(|e| e.to_string())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Note: System tray temporarily disabled on Linux due to icon format issues
|
||||
// The app works perfectly without it - you can minimize/maximize normally
|
||||
|
||||
tauri::Builder::default()
|
||||
.invoke_handler(tauri::generate_handler![greet, get_env_keys])
|
||||
.setup(|_app| {
|
||||
.invoke_handler(tauri::generate_handler![greet, get_env_keys, send_notification])
|
||||
.setup(|app| {
|
||||
// Register global shortcut to show/hide EVE
|
||||
let window = app.get_window("main").unwrap();
|
||||
let window_clone = window.clone();
|
||||
|
||||
// Try to register global shortcut, but don't panic if it fails
|
||||
match app.global_shortcut_manager()
|
||||
.register("CommandOrControl+Shift+E", move || {
|
||||
if window_clone.is_visible().unwrap_or(true) {
|
||||
let _ = window_clone.hide();
|
||||
} else {
|
||||
let _ = window_clone.show();
|
||||
let _ = window_clone.set_focus();
|
||||
}
|
||||
}) {
|
||||
Ok(_) => println!("✅ Global shortcut registered: Ctrl+Shift+E"),
|
||||
Err(e) => eprintln!("⚠️ Failed to register global shortcut: {}. The app will work without it.", e),
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
// DevTools are available via F12 or the context menu
|
||||
|
||||
Reference in New Issue
Block a user