Fix file picker for Android: gate blocking_pick behind desktop cfg
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c40e093d01
commit
19a95b7c45
1 changed files with 26 additions and 10 deletions
|
|
@ -1645,21 +1645,37 @@ struct AddressInfoDto {
|
|||
|
||||
#[tauri::command]
|
||||
async fn pick_file(app: tauri::AppHandle, title: String, filter_name: Option<String>, filter_ext: Option<Vec<String>>) -> Result<Option<String>, String> {
|
||||
use tauri_plugin_dialog::DialogExt;
|
||||
let mut builder = app.dialog().file().set_title(&title);
|
||||
if let (Some(name), Some(exts)) = (filter_name, filter_ext) {
|
||||
let ext_refs: Vec<&str> = exts.iter().map(|s| s.as_str()).collect();
|
||||
builder = builder.add_filter(&name, &ext_refs);
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
{
|
||||
use tauri_plugin_dialog::DialogExt;
|
||||
let mut builder = app.dialog().file().set_title(&title);
|
||||
if let (Some(name), Some(exts)) = (filter_name, filter_ext) {
|
||||
let ext_refs: Vec<&str> = exts.iter().map(|s| s.as_str()).collect();
|
||||
builder = builder.add_filter(&name, &ext_refs);
|
||||
}
|
||||
let path = builder.blocking_pick_file();
|
||||
Ok(path.map(|p| p.to_string()))
|
||||
}
|
||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
{
|
||||
let _ = (app, title, filter_name, filter_ext);
|
||||
Ok(None) // Mobile: file picker not supported via this command
|
||||
}
|
||||
let path = builder.blocking_pick_file();
|
||||
Ok(path.map(|p| p.to_string()))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn pick_folder(app: tauri::AppHandle, title: String) -> Result<Option<String>, String> {
|
||||
use tauri_plugin_dialog::DialogExt;
|
||||
let path = app.dialog().file().set_title(&title).blocking_pick_folder();
|
||||
Ok(path.map(|p| p.to_string()))
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
{
|
||||
use tauri_plugin_dialog::DialogExt;
|
||||
let path = app.dialog().file().set_title(&title).blocking_pick_folder();
|
||||
Ok(path.map(|p| p.to_string()))
|
||||
}
|
||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
{
|
||||
let _ = (app, title);
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue