diff --git a/packages/editor-app/src-tauri/src/commands/file_system.rs b/packages/editor-app/src-tauri/src/commands/file_system.rs index dac7738c..361c0a20 100644 --- a/packages/editor-app/src-tauri/src/commands/file_system.rs +++ b/packages/editor-app/src-tauri/src/commands/file_system.rs @@ -254,6 +254,25 @@ pub fn read_file_as_base64(file_path: String) -> Result { Ok(general_purpose::STANDARD.encode(&file_content)) } +/// Get file modification time (milliseconds since UNIX epoch) +/// 获取文件修改时间(Unix 纪元以来的毫秒数) +#[tauri::command] +pub fn get_file_mtime(path: String) -> Result { + let metadata = fs::metadata(&path) + .map_err(|e| format!("Failed to get metadata for {}: {}", path, e))?; + + let modified = metadata + .modified() + .map_err(|e| format!("Failed to get modified time for {}: {}", path, e))?; + + let millis = modified + .duration_since(std::time::UNIX_EPOCH) + .map_err(|e| format!("Time error: {}", e))? + .as_millis() as u64; + + Ok(millis) +} + /// Copy file from source to destination #[tauri::command] pub fn copy_file(src: String, dst: String) -> Result<(), String> { diff --git a/packages/editor-app/src-tauri/src/main.rs b/packages/editor-app/src-tauri/src/main.rs index e1f01b5a..bf075541 100644 --- a/packages/editor-app/src-tauri/src/main.rs +++ b/packages/editor-app/src-tauri/src/main.rs @@ -65,6 +65,7 @@ fn main() { commands::scan_directory, commands::read_file_as_base64, commands::copy_file, + commands::get_file_mtime, // Dialog operations commands::open_folder_dialog, commands::open_file_dialog, @@ -183,18 +184,27 @@ fn handle_project_protocol( } /// Get MIME type based on file extension +/// 根据文件扩展名获取 MIME 类型 fn get_mime_type(file_path: &str) -> &'static str { if file_path.ends_with(".ts") || file_path.ends_with(".tsx") { "application/javascript" - } else if file_path.ends_with(".js") { + } else if file_path.ends_with(".js") || file_path.ends_with(".mjs") { "application/javascript" } else if file_path.ends_with(".json") { "application/json" + } else if file_path.ends_with(".wasm") { + "application/wasm" } else if file_path.ends_with(".css") { "text/css" } else if file_path.ends_with(".html") { "text/html" + } else if file_path.ends_with(".png") { + "image/png" + } else if file_path.ends_with(".jpg") || file_path.ends_with(".jpeg") { + "image/jpeg" + } else if file_path.ends_with(".svg") { + "image/svg+xml" } else { - "text/plain" + "application/octet-stream" } } diff --git a/packages/editor-app/src-tauri/tauri.conf.json b/packages/editor-app/src-tauri/tauri.conf.json index 6829671c..3872cb72 100644 --- a/packages/editor-app/src-tauri/tauri.conf.json +++ b/packages/editor-app/src-tauri/tauri.conf.json @@ -81,7 +81,8 @@ { "identifier": "main", "windows": [ - "main" + "main", + "frame-debugger" ], "permissions": [ "core:default", @@ -91,6 +92,9 @@ "core:window:allow-toggle-maximize", "core:window:allow-close", "core:window:allow-is-maximized", + "core:window:allow-create", + "core:webview:allow-create-webview", + "core:webview:allow-create-webview-window", "shell:default", "dialog:default", "updater:default",