mirror of
https://github.com/patarapolw/cjdic2.git
synced 2026-11-08 17:35:18 +00:00
yomitan init on UI
This commit is contained in:
1 parent
3b5afbc34e
commit
ff64c035e6
8 files changed
+245
-46
No files matched your search
@@ -1,18 +1,41 @@
|
||||
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
|
||||
use cjdic2_core::{AppService, YomitanRow};
|
||||
use tauri::{AppHandle, Emitter, Manager, path::BaseDirectory};
|
||||
|
||||
#[tauri::command]
|
||||
pub fn is_yomitan_setup_yet(state: tauri::State<AppService>) -> Result<bool, String> {
|
||||
state.is_yomitan_setup_yet().map_err(|e| e.to_string())
|
||||
pub async fn init_yomitan(
|
||||
app: AppHandle,
|
||||
state: tauri::State<'_, AppService>,
|
||||
) -> Result<(), String> {
|
||||
let zip_dir = app
|
||||
.path()
|
||||
.resolve("resources/yomitan", BaseDirectory::Resource)
|
||||
.map_err(|e| e.to_string())?;
|
||||
// println!("{:?}", zip_dir.as_path());
|
||||
|
||||
state
|
||||
.load_yomitan_zip_dir(
|
||||
zip_dir,
|
||||
"ja",
|
||||
|r| {
|
||||
app.emit("load-yomitan-dir", r).unwrap();
|
||||
},
|
||||
|r| {
|
||||
app.emit("yomitan-import-progress", r).unwrap();
|
||||
},
|
||||
)
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn search_yomitan(
|
||||
pub async fn search_yomitan(
|
||||
q_term: &str,
|
||||
q_reading: &str,
|
||||
limit: u32,
|
||||
offset: u32,
|
||||
state: tauri::State<AppService>,
|
||||
state: tauri::State<'_, AppService>,
|
||||
) -> Result<Vec<YomitanRow>, String> {
|
||||
state
|
||||
.search_yomitan(q_term, q_reading, limit, offset)
|
||||
|
||||
Reference in new issue
Block a user