refactor(store): more reworks

This commit is contained in:
Tony
2024-10-02 18:02:44 +08:00
parent 7e5e34420b
commit 9811756e6c
11 changed files with 204 additions and 157 deletions
@@ -8,6 +8,7 @@
use std::time::Duration;
use serde_json::json;
use tauri::Listener;
use tauri_plugin_store::StoreExt;
mod app;
@@ -22,13 +23,13 @@ fn main() {
.handle()
.store_builder("settings.json")
.auto_save(Duration::from_millis(100))
.build();
// If there are no saved settings yet, this will return an error so we ignore the return value.
let _ = store.load();
.build()
.unwrap();
app.share_store(store.clone());
app.listen("store://change", |event| {
dbg!(event);
});
let app_settings = AppSettings::load_from_store(&store);
match app_settings {
Ok(app_settings) => {
let theme = app_settings.theme;
@@ -3,6 +3,7 @@
"version": "0.1.0",
"identifier": "com.tauri.app-settings-manager",
"build": {
"devUrl": "http://localhost:1420",
"frontendDist": "../dist"
},
"app": {