pub mod api_client; pub mod api_crypto; pub mod app_config; pub mod audio_db; pub mod audio_store; pub mod avatar_db; pub mod avatar_store; pub mod video_db; pub mod video_store; pub mod local_config; pub mod asr; pub mod auth_session; pub mod chat; pub mod commands; pub mod cover_python; pub mod device_serial; pub mod ffmpeg; pub mod http; pub mod js_runtime; pub mod nodejs; pub mod agent_id; pub mod oem_context; pub mod oem_id; pub mod oss; pub mod publish_db; pub mod publish_store; use tauri::Manager; #[cfg_attr(mobile, tauri::mobile_entry_point)] pub fn run() { let _ = env_logger::try_init(); tauri::Builder::default() .manage(auth_session::AuthSession::default()) .manage(app_config::AppConfig::new()) .manage(avatar_store::AvatarStore::new()) .manage(audio_store::AudioStore::new()) .manage(video_store::VideoStore::new()) .manage(publish_store::PublishStore::new()) .setup(|app| { let handle = app.handle().clone(); let heartbeat_handle = handle.clone(); let oem_id = oem_id::load_oem_id(&handle); let agent_id = agent_id::load_agent_id(&handle); let install_ctx = oem_context::OemContext { oem_id, agent_id }; oem_context::init(install_ctx.clone()); app.manage(install_ctx); tauri::async_runtime::block_on(async move { let app_config = handle.state::(); let avatar_store = handle.state::(); let audio_store = handle.state::(); let video_store = handle.state::(); let publish_store = handle.state::(); let dir = handle .path() .app_data_dir() .map_err(|e| format!("无法获取应用数据目录: {e}"))?; let db_path = dir.join("local_config.db"); app_config.init_local_store(db_path).await?; avatar_store.init(dir.join("avatars.db")).await?; audio_store.init(dir.join("generated_audios.db")).await?; video_store.init(dir.join("generated_videos.db")).await?; publish_store.init(dir.join("publish_accounts.db")).await?; Ok::<(), String>(()) }) .map_err(|e| -> Box { e.into() })?; api_client::spawn_heartbeat_loop(heartbeat_handle); Ok(()) }) .plugin(tauri_plugin_single_instance::init(|app, _args, _cwd| { if let Some(window) = app.get_webview_window("main") { let _ = window.unminimize(); let _ = window.show(); let _ = window.set_focus(); } })) .plugin(tauri_plugin_opener::init()) .plugin(tauri_plugin_dialog::init()) .invoke_handler(tauri::generate_handler![ commands::api::api_request, commands::software_info::get_software_info, commands::auth::sync_auth_session, commands::app_config::get_app_config, commands::app_config::get_app_config_last_message, commands::app_config::get_server_app_config, commands::app_config::get_app_config_detail, commands::app_config::list_local_app_config, commands::app_config::set_local_app_config, commands::app_config::delete_local_app_config, commands::quickjs::run_quickjs_script, commands::quickjs::run_quickjs_script_source, commands::quickjs::list_quickjs_scripts, commands::nodejs::run_nodejs_script, commands::nodejs::run_nodejs_script_source, commands::nodejs::list_nodejs_scripts, commands::fs_util::read_local_file_base64, commands::fs_util::get_media_duration_seconds, commands::avatar::list_avatars, commands::avatar::insert_avatar, commands::avatar::update_avatar_name, commands::avatar::delete_avatar, commands::avatar::avatar_name_exists, commands::avatar::import_avatar_video, commands::audio::list_generated_audios, commands::audio::insert_generated_audio, commands::audio::delete_generated_audio, commands::video::list_generated_videos, commands::video::insert_generated_video, commands::video::import_generated_video, commands::video::delete_generated_video, commands::publish::publish_list_accounts, commands::publish::publish_login, commands::publish::publish_check_login, commands::publish::publish_execute, commands::publish::publish_delete_account, ]) .build(tauri::generate_context!()) .expect("error while building tauri application") .run(|app_handle, event| { if let tauri::RunEvent::Ready = event { if let Some(window) = app_handle.get_webview_window("main") { let _ = window.maximize(); } } }); }