mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-08-02 13:48:15 +02:00
Open with stirling mac
This commit is contained in:
parent
499829bd69
commit
7c4e8dc267
@ -11,7 +11,19 @@ pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
.plugin(tauri_plugin_fs::init())
|
||||
.setup(|_app| {Ok(())})
|
||||
.setup(|app| {
|
||||
// Check command line arguments at startup for macOS file opening
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
for arg in args.iter().skip(1) {
|
||||
if arg.ends_with(".pdf") && std::path::Path::new(arg).exists() {
|
||||
add_log(format!("📂 File argument detected at startup: {}", arg));
|
||||
set_opened_file(arg.clone());
|
||||
break; // Only handle the first PDF file
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![start_backend, check_backend_health, get_opened_file, clear_opened_file])
|
||||
.build(tauri::generate_context!())
|
||||
.expect("error while building tauri application")
|
||||
@ -28,21 +40,6 @@ pub fn run() {
|
||||
cleanup_backend();
|
||||
// Allow the window to close
|
||||
}
|
||||
// Handle macOS file open events
|
||||
RunEvent::Opened { urls } => {
|
||||
for url in urls {
|
||||
add_log(format!("📂 File opened via macOS event: {}", url));
|
||||
|
||||
// Convert URL to file path if it's a file URL
|
||||
if let Ok(path) = url.to_file_path() {
|
||||
if let Some(path_str) = path.to_str() {
|
||||
if path_str.ends_with(".pdf") {
|
||||
set_opened_file(path_str.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
|
@ -38,7 +38,8 @@
|
||||
"ext": ["pdf"],
|
||||
"name": "PDF Document",
|
||||
"description": "Open PDF files with Stirling-PDF",
|
||||
"role": "Editor"
|
||||
"role": "Editor",
|
||||
"mimeType": "application/pdf"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user