// 四层架构模块定义 pub mod infrastructure; pub mod data; pub mod business; pub mod presentation; // 应用状态和配置 pub mod app_state; pub mod config; // 测试模块 #[cfg(test)] mod tests; use app_state::AppState; use presentation::commands; use tauri::Manager; #[cfg_attr(mobile, tauri::mobile_entry_point)] pub fn run() { tauri::Builder::default() .plugin(tauri_plugin_opener::init()) .plugin(tauri_plugin_fs::init()) .plugin(tauri_plugin_dialog::init()) .manage(AppState::new()) .invoke_handler(tauri::generate_handler![ commands::project_commands::create_project, commands::project_commands::get_all_projects, commands::project_commands::get_project_by_id, commands::project_commands::update_project, commands::project_commands::delete_project, commands::project_commands::validate_project_path, commands::project_commands::get_default_project_name, commands::system_commands::select_directory, commands::system_commands::get_app_info, commands::system_commands::validate_directory, commands::system_commands::get_directory_name, commands::system_commands::get_database_info, commands::system_commands::get_performance_report, commands::system_commands::cleanup_invalid_projects, commands::material_commands::import_materials, commands::material_commands::get_project_materials, commands::material_commands::get_material_by_id, commands::material_commands::delete_material, commands::material_commands::get_project_material_stats, commands::material_commands::batch_process_materials, commands::material_commands::update_material_status, commands::material_commands::cleanup_invalid_materials, commands::material_commands::is_supported_format, commands::material_commands::get_supported_extensions, commands::material_commands::select_material_files, commands::material_commands::validate_material_files, commands::material_commands::get_file_info, commands::material_commands::check_ffmpeg_available, commands::material_commands::get_ffmpeg_version, commands::material_commands::get_ffmpeg_status, commands::material_commands::extract_file_metadata, commands::material_commands::detect_video_scenes, commands::material_commands::generate_video_thumbnail, commands::material_commands::test_scene_detection, commands::material_commands::get_material_segments, commands::material_commands::test_video_split ]) .setup(|app| { // 初始化应用状态 let app_handle = app.handle(); let state: tauri::State = app_handle.state(); // 初始化数据库 if let Err(e) = state.initialize_database() { eprintln!("Failed to initialize database: {}", e); return Err(e.into()); } // 发布应用启动事件 let event_bus_manager = state.event_bus_manager.clone(); tauri::async_runtime::spawn(async move { let _ = event_bus_manager.publish_app_started().await; }); // 记录启动性能指标 { let mut monitor = state.performance_monitor.lock().unwrap(); monitor.record_metric("startup_time_ms", 0.0); // 实际应该测量真实启动时间 } Ok(()) }) .run(tauri::generate_context!()) .expect("error while running tauri application"); }