mirror of
https://github.com/patarapolw/cjdic2.git
synced 2026-11-09 17:39:35 +00:00
is init yet from Rust
This commit is contained in:
1 parent
9b5ae1cd8b
commit
dcfe074535
9 files changed
+38
-91
No files matched your search
@@ -1,16 +1,9 @@
|
||||
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
|
||||
use cjdic2_core::{AppService, Entry, db::YomitanRow};
|
||||
use cjdic2_core::{AppService, YomitanRow};
|
||||
|
||||
#[tauri::command]
|
||||
pub fn add_entry(name: &str, state: tauri::State<AppService>) -> Result<(), String> {
|
||||
state
|
||||
.add_entry(name, "definition")
|
||||
.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn list_entries(state: tauri::State<AppService>) -> Result<Vec<Entry>, String> {
|
||||
state.list_entries().map_err(|e| e.to_string())
|
||||
pub fn is_yomitan_setup_yet(state: tauri::State<AppService>) -> bool {
|
||||
state.is_yomitan_setup_yet()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::{fs::create_dir_all, path::Path};
|
||||
use std::fs::create_dir_all;
|
||||
|
||||
use crate::command::*;
|
||||
use cjdic2_core::*;
|
||||
@@ -15,15 +15,15 @@ pub fn run() {
|
||||
create_dir_all(&app_dir)?;
|
||||
|
||||
// db_path is app_dir;
|
||||
let db_dir = Path::new(r"D:\Projects\cjdic2\tmp\save-db");
|
||||
let db_dir = app_dir.as_path();
|
||||
// let db_dir = Path::new(r"D:\Projects\cjdic2\tmp\save-db");
|
||||
let service = AppService::new(&db_dir)?;
|
||||
app.manage(service);
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
add_entry,
|
||||
list_entries,
|
||||
is_yomitan_setup_yet,
|
||||
search_yomitan
|
||||
])
|
||||
.build(tauri::generate_context!())
|
||||
|
||||
Reference in new issue
Block a user