mirror of
https://github.com/haexhub/haex-hub.git
synced 2025-12-16 22:20:51 +01:00
Add showImage handler stub and mobile file provider foundation
- Add haextension.fs.showImage handler that delegates to frontend PhotoSwipe - Add mobile.rs with open_file_with_provider command for future Android FileProvider integration - Keep showImage as backwards-compatible no-op since image viewing is now handled client-side 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
33
src-tauri/src/mobile.rs
Normal file
33
src-tauri/src/mobile.rs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
use tauri::command;
|
||||||
|
|
||||||
|
#[command]
|
||||||
|
pub async fn open_file_with_provider(path: String, mime_type: Option<String>) -> Result<(), String> {
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
{
|
||||||
|
open_file_android(path, mime_type).await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "android"))]
|
||||||
|
{
|
||||||
|
// On other platforms, use the opener plugin
|
||||||
|
use tauri_plugin_opener::OpenerExt;
|
||||||
|
tauri::AppHandle::opener()
|
||||||
|
.open_path(path, None::<&str>)
|
||||||
|
.map_err(|e| e.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
async fn open_file_android(path: String, mime_type: Option<String>) -> Result<(), String> {
|
||||||
|
use jni::{
|
||||||
|
objects::{JObject, JString, JValue},
|
||||||
|
JNIEnv,
|
||||||
|
};
|
||||||
|
use tauri::Manager;
|
||||||
|
|
||||||
|
// This will be called from the Rust side
|
||||||
|
// We need to call into the Android Activity to use FileProvider
|
||||||
|
|
||||||
|
// For now, return an error - we need to implement the Java/Kotlin side first
|
||||||
|
Err("Android FileProvider implementation needed".to_string())
|
||||||
|
}
|
||||||
@ -44,6 +44,15 @@ export async function handleFilesystemMethodAsync(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 'haextension.fs.showImage': {
|
||||||
|
// This method is now handled by the frontend using PhotoSwipe
|
||||||
|
// We keep it for backwards compatibility but it's a no-op
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
useFrontend: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case 'haextension.fs.openFile': {
|
case 'haextension.fs.openFile': {
|
||||||
const params = request.params as {
|
const params = request.params as {
|
||||||
data: number[]
|
data: number[]
|
||||||
|
|||||||
Reference in New Issue
Block a user