()
| 15 | use state::{ProfilerState, ProjectPaths, ScriptWatcherState}; |
| 16 | |
| 17 | fn main() { |
| 18 | // Initialize shared state | 初始化共享状态 |
| 19 | let project_paths: ProjectPaths = Arc::new(Mutex::new(HashMap::new())); |
| 20 | let project_paths_for_protocol = Arc::clone(&project_paths); |
| 21 | |
| 22 | let profiler_state = ProfilerState::new(); |
| 23 | let script_watcher_state = ScriptWatcherState::new(); |
| 24 | |
| 25 | // Build and run the Tauri application |
| 26 | tauri::Builder::default() |
| 27 | // Register plugins |
| 28 | .plugin(tauri_plugin_shell::init()) |
| 29 | .plugin(tauri_plugin_dialog::init()) |
| 30 | .plugin(tauri_plugin_fs::init()) |
| 31 | .plugin(tauri_plugin_updater::Builder::new().build()) |
| 32 | .plugin(tauri_plugin_http::init()) |
| 33 | .plugin(tauri_plugin_cli::init()) |
| 34 | // Register custom URI scheme for project files |
| 35 | .register_uri_scheme_protocol("project", move |_app, request| { |
| 36 | handle_project_protocol(request, &project_paths_for_protocol) |
| 37 | }) |
| 38 | // Setup application state | 设置应用状态 |
| 39 | .setup(move |app| { |
| 40 | app.manage(project_paths); |
| 41 | app.manage(profiler_state); |
| 42 | app.manage(script_watcher_state); |
| 43 | Ok(()) |
| 44 | }) |
| 45 | // Register all commands |
| 46 | .invoke_handler(tauri::generate_handler![ |
| 47 | // Project management |
| 48 | commands::open_project, |
| 49 | commands::save_project, |
| 50 | commands::export_binary, |
| 51 | commands::set_project_base_path, |
| 52 | commands::scan_behavior_trees, |
| 53 | // File system operations |
| 54 | commands::read_file_content, |
| 55 | commands::write_file_content, |
| 56 | commands::write_binary_file, |
| 57 | commands::append_to_log, |
| 58 | commands::path_exists, |
| 59 | commands::create_directory, |
| 60 | commands::create_file, |
| 61 | commands::delete_file, |
| 62 | commands::delete_folder, |
| 63 | commands::rename_file_or_folder, |
| 64 | commands::list_directory, |
| 65 | commands::scan_directory, |
| 66 | commands::read_file_as_base64, |
| 67 | commands::copy_file, |
| 68 | commands::get_file_mtime, |
| 69 | // Dialog operations |
| 70 | commands::open_folder_dialog, |
| 71 | commands::open_file_dialog, |
| 72 | commands::save_file_dialog, |
| 73 | // Profiler server |
| 74 | commands::start_profiler_server, |
nothing calls this directly
no test coverage detected