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