feat: appwide darkmode toggle and daemon connection check
This commit is contained in:
@@ -6,12 +6,16 @@ mod commands;
|
||||
use tauri_plugin_global_shortcut::{Code, GlobalShortcutExt, Modifiers, Shortcut, ShortcutState};
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
use commands::{chat, chat_history, daemon_state, toggle_popup};
|
||||
use commands::{chat, chat_history, daemon_state, toggle_dark_mode, toggle_popup};
|
||||
use shared::ai::ai_daemon_client::AiDaemonClient;
|
||||
|
||||
pub struct AppConfig {
|
||||
dark_mode: bool,
|
||||
}
|
||||
|
||||
pub struct AppState {
|
||||
grpc_client: Mutex<AiDaemonClient<tonic::transport::Channel>>,
|
||||
current_chat: Mutex<Option<i64>>,
|
||||
config: Mutex<AppConfig>,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
@@ -22,14 +26,15 @@ async fn main() {
|
||||
tauri::Builder::default()
|
||||
.manage(AppState {
|
||||
grpc_client: Mutex::new(client),
|
||||
current_chat: Mutex::new(None),
|
||||
config: Mutex::new(AppConfig { dark_mode: true }),
|
||||
})
|
||||
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
toggle_popup,
|
||||
chat_history,
|
||||
chat,
|
||||
daemon_state
|
||||
daemon_state,
|
||||
toggle_dark_mode,
|
||||
])
|
||||
.setup(|app| {
|
||||
/* Auto-hide popup when focus is lost
|
||||
|
||||
Reference in New Issue
Block a user