mirror of
https://github.com/patarapolw/cjdic2.git
synced 2026-11-08 17:35:18 +00:00
38 lines
1.1 KiB
Rust
38 lines
1.1 KiB
Rust
use std::{fs::create_dir_all, path::Path};
|
|
|
|
use crate::command::*;
|
|
use cjdic2_core::*;
|
|
use tauri::Manager;
|
|
|
|
mod command;
|
|
|
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
|
pub fn run() {
|
|
tauri::Builder::default()
|
|
.plugin(tauri_plugin_opener::init())
|
|
.setup(|app| {
|
|
let app_dir = app.path().app_config_dir()?;
|
|
create_dir_all(&app_dir)?;
|
|
|
|
// db_path is app_dir;
|
|
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,
|
|
search_yomitan
|
|
])
|
|
.build(tauri::generate_context!())
|
|
.expect("error while running tauri application")
|
|
.run(|_app_handle, event| match event {
|
|
// On exit handler should be avoided for mobile
|
|
// and rusqlite already closes gracefully by default
|
|
tauri::RunEvent::ExitRequested { .. } => {}
|
|
_ => {}
|
|
});
|
|
}
|