feat: portable storage - data directory next to exe
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
use rusqlite::Connection;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::sync::Mutex;
|
||||
use tauri::{Manager, State};
|
||||
use std::path::PathBuf;
|
||||
use tauri::Manager;
|
||||
|
||||
mod database;
|
||||
mod commands;
|
||||
@@ -13,8 +12,7 @@ pub struct AppState {
|
||||
|
||||
fn get_data_dir() -> PathBuf {
|
||||
let exe_path = std::env::current_exe().unwrap();
|
||||
let exe_dir = exe_path.parent().unwrap();
|
||||
let data_dir = exe_dir.join("data");
|
||||
let data_dir = exe_path.parent().unwrap().join("data");
|
||||
std::fs::create_dir_all(&data_dir).ok();
|
||||
data_dir
|
||||
}
|
||||
@@ -30,6 +28,7 @@ pub fn run() {
|
||||
database::init_db(&conn).expect("Failed to initialize database");
|
||||
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_window_state::Builder::new().build())
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
.plugin(tauri_plugin_fs::init())
|
||||
@@ -54,8 +53,12 @@ pub fn run() {
|
||||
commands::get_reports,
|
||||
commands::create_invoice,
|
||||
commands::get_invoices,
|
||||
commands::update_invoice,
|
||||
commands::delete_invoice,
|
||||
commands::get_settings,
|
||||
commands::update_settings,
|
||||
commands::export_data,
|
||||
commands::clear_all_data,
|
||||
])
|
||||
.setup(|app| {
|
||||
#[cfg(desktop)]
|
||||
@@ -69,7 +72,7 @@ pub fn run() {
|
||||
|
||||
let _tray = TrayIconBuilder::new()
|
||||
.menu(&menu)
|
||||
.menu_on_left_click(false)
|
||||
.show_menu_on_left_click(false)
|
||||
.on_menu_event(|app, event| {
|
||||
match event.id.as_ref() {
|
||||
"quit" => {
|
||||
|
||||
Reference in New Issue
Block a user