mirror of
https://github.com/readest/readest.git
synced 2026-04-29 03:50:52 +00:00
This commit is contained in:
parent
11bc7497e8
commit
ba3f060cc4
44 changed files with 341 additions and 97 deletions
|
|
@ -1,6 +1,8 @@
|
|||
use tauri::{command, AppHandle, Runtime};
|
||||
use std::path::PathBuf;
|
||||
use tauri::{command, AppHandle, Runtime, State};
|
||||
|
||||
use crate::models::*;
|
||||
use crate::DirectoryCallbackState;
|
||||
use crate::NativeBridgeExt;
|
||||
use crate::Result;
|
||||
|
||||
|
|
@ -160,8 +162,21 @@ pub(crate) async fn open_external_url<R: Runtime>(
|
|||
#[command]
|
||||
pub(crate) async fn select_directory<R: Runtime>(
|
||||
app: AppHandle<R>,
|
||||
callback_state: State<'_, DirectoryCallbackState<R>>,
|
||||
) -> Result<SelectDirectoryResponse> {
|
||||
app.native_bridge().select_directory()
|
||||
let result = app.native_bridge().select_directory()?;
|
||||
|
||||
if let Some(dir_path) = &result.path {
|
||||
let path = PathBuf::from(dir_path);
|
||||
|
||||
if let Ok(callback_guard) = callback_state.callback.lock() {
|
||||
if let Some(callback) = callback_guard.as_ref() {
|
||||
callback(&app, &path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
#[command]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue