feat(api): integrate screenshot commands and link detection
- Add captureUrlScreenshot() API endpoint - Add cleanupScreenshotTempFiles() for maintenance - Register screenshot commands in Tauri backend - Update command module exports
This commit is contained in:
@@ -2,4 +2,5 @@ pub mod claude;
|
||||
pub mod agents;
|
||||
pub mod sandbox;
|
||||
pub mod usage;
|
||||
pub mod mcp;
|
||||
pub mod mcp;
|
||||
pub mod screenshot;
|
@@ -35,6 +35,9 @@ use commands::sandbox::{
|
||||
list_sandbox_violations, log_sandbox_violation, clear_sandbox_violations, get_sandbox_violation_stats,
|
||||
export_sandbox_profile, export_all_sandbox_profiles, import_sandbox_profiles,
|
||||
};
|
||||
use commands::screenshot::{
|
||||
capture_url_screenshot, cleanup_screenshot_temp_files,
|
||||
};
|
||||
use commands::usage::{
|
||||
get_usage_stats, get_usage_by_date_range, get_usage_details, get_session_stats,
|
||||
};
|
||||
@@ -178,7 +181,9 @@ fn main() {
|
||||
mcp_reset_project_choices,
|
||||
mcp_get_server_status,
|
||||
mcp_read_project_config,
|
||||
mcp_save_project_config
|
||||
mcp_save_project_config,
|
||||
capture_url_screenshot,
|
||||
cleanup_screenshot_temp_files
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
|
@@ -1760,4 +1760,37 @@ export const api = {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Captures a screenshot of a specific region in the window
|
||||
* @param url - The URL to capture
|
||||
* @param selector - Optional selector to capture
|
||||
* @param fullPage - Whether to capture the full page
|
||||
* @returns Promise resolving to the path of the saved screenshot
|
||||
*/
|
||||
async captureUrlScreenshot(
|
||||
url: string,
|
||||
selector?: string | null,
|
||||
fullPage: boolean = false
|
||||
): Promise<string> {
|
||||
return await invoke<string>("capture_url_screenshot", {
|
||||
url,
|
||||
selector,
|
||||
fullPage,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Cleans up old screenshot files from the temporary directory
|
||||
* @param olderThanMinutes - Remove files older than this many minutes (default: 60)
|
||||
* @returns Promise resolving to the number of files deleted
|
||||
*/
|
||||
async cleanupScreenshotTempFiles(olderThanMinutes?: number): Promise<number> {
|
||||
try {
|
||||
return await invoke<number>("cleanup_screenshot_temp_files", { olderThanMinutes });
|
||||
} catch (error) {
|
||||
console.error("Failed to cleanup screenshot files:", error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
};
|
Reference in New Issue
Block a user