Refactoring code, fixing name and adding readme
This commit is contained in:
0
src-tauri/src/client/mod.rs
Normal file
0
src-tauri/src/client/mod.rs
Normal file
@@ -3,3 +3,17 @@ mod collection;
|
||||
|
||||
pub use workspace::*;
|
||||
pub use collection::*;
|
||||
|
||||
pub fn handlers() -> impl Fn(tauri::ipc::Invoke) -> bool {
|
||||
tauri::generate_handler![
|
||||
create_workspace,
|
||||
get_workspaces,
|
||||
get_workspace,
|
||||
update_workspace,
|
||||
delete_workspace,
|
||||
create_collection,
|
||||
get_workspace_collections,
|
||||
update_collection,
|
||||
delete_collection
|
||||
]
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
mod api;
|
||||
mod models;
|
||||
mod storage;
|
||||
mod commands;
|
||||
mod client;
|
||||
|
||||
use commands::handlers as h;
|
||||
use storage::Storage;
|
||||
use tauri::Manager;
|
||||
use std::sync::Mutex;
|
||||
|
||||
fn main() {
|
||||
let handlers = h();
|
||||
tauri::Builder::default()
|
||||
.setup(|app| {
|
||||
let app_dir = app.path().app_data_dir()
|
||||
@@ -19,17 +21,7 @@ fn main() {
|
||||
app.manage(Mutex::new(storage));
|
||||
Ok(())
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
commands::create_workspace,
|
||||
commands::get_workspaces,
|
||||
commands::get_workspace,
|
||||
commands::update_workspace,
|
||||
commands::delete_workspace,
|
||||
commands::create_collection,
|
||||
commands::get_workspace_collections,
|
||||
commands::update_collection,
|
||||
commands::delete_collection,
|
||||
])
|
||||
.invoke_handler(handlers)
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ pub struct Storage {
|
||||
|
||||
impl Storage {
|
||||
pub fn new(app_dir: PathBuf) -> rusqlite::Result<Self> {
|
||||
let db_path = app_dir.join("api-client.db");
|
||||
let db_path = app_dir.join("resona.db");
|
||||
let data_dir = app_dir.join("data");
|
||||
|
||||
fs::create_dir_all(&data_dir).map_err(|e| rusqlite::Error::InvalidPath(data_dir.clone()))?;
|
||||
|
||||
Reference in New Issue
Block a user