feat: add tauri-plugin-store for session persistence
This commit is contained in:
17
src-tauri/Cargo.lock
generated
17
src-tauri/Cargo.lock
generated
@@ -3834,6 +3834,7 @@ dependencies = [
|
||||
"tauri",
|
||||
"tauri-build",
|
||||
"tauri-plugin-opener",
|
||||
"tauri-plugin-store",
|
||||
"thiserror 2.0.18",
|
||||
"tokio",
|
||||
"uuid",
|
||||
@@ -6341,6 +6342,22 @@ dependencies = [
|
||||
"zbus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-store"
|
||||
version = "2.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ca1a8ff83c269b115e98726ffc13f9e548a10161544a92ad121d6d0a96e16ea"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tauri",
|
||||
"tauri-plugin",
|
||||
"thiserror 2.0.18",
|
||||
"tokio",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-runtime"
|
||||
version = "2.10.1"
|
||||
|
||||
@@ -20,6 +20,7 @@ tauri-build = { version = "2", features = [] }
|
||||
[dependencies]
|
||||
tauri = { version = "2", features = [] }
|
||||
tauri-plugin-opener = "2"
|
||||
tauri-plugin-store = "2"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
surrealdb = { version = "3.0.5", features = ["native-tls"] }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::collections::HashMap;
|
||||
use std::sync::{Arc, Mutex, LazyLock};
|
||||
use std::env;
|
||||
use std::sync::{Arc, LazyLock, Mutex};
|
||||
|
||||
use surrealdb::engine::remote::ws::{Client, Ws, Wss};
|
||||
use surrealdb::Surreal;
|
||||
@@ -13,26 +13,24 @@ use crate::error::AppError;
|
||||
pub static SURREAL_URL: LazyLock<String> = LazyLock::new(|| {
|
||||
option_env!("SURREAL_URL")
|
||||
.map(str::to_string)
|
||||
.unwrap_or_else(|| env::var("SURREAL_URL")
|
||||
.unwrap_or_else(|_| "ws://localhost:8000".to_string()))
|
||||
.unwrap_or_else(|| {
|
||||
env::var("SURREAL_URL").unwrap_or_else(|_| "ws://localhost:8000".to_string())
|
||||
})
|
||||
});
|
||||
pub static SURREAL_NS: LazyLock<String> = LazyLock::new(|| {
|
||||
option_env!("SURREAL_NS")
|
||||
.map(str::to_string)
|
||||
.unwrap_or_else(|| env::var("SURREAL_NS")
|
||||
.unwrap_or_else(|_| "dev".to_string()))
|
||||
.unwrap_or_else(|| env::var("SURREAL_NS").unwrap_or_else(|_| "dev".to_string()))
|
||||
});
|
||||
pub static SURREAL_DB: LazyLock<String> = LazyLock::new(|| {
|
||||
option_env!("SURREAL_DB")
|
||||
.map(str::to_string)
|
||||
.unwrap_or_else(|| env::var("SURREAL_DB")
|
||||
.unwrap_or_else(|_| "oxyde".to_string()))
|
||||
.unwrap_or_else(|| env::var("SURREAL_DB").unwrap_or_else(|_| "oxyde".to_string()))
|
||||
});
|
||||
pub static SURREAL_ACCESS: LazyLock<String> = LazyLock::new(|| {
|
||||
option_env!("SURREAL_ACCESS")
|
||||
.map(str::to_string)
|
||||
.unwrap_or_else(|| env::var("SURREAL_ACCESS")
|
||||
.unwrap_or_else(|_| "account".to_string()))
|
||||
.unwrap_or_else(|| env::var("SURREAL_ACCESS").unwrap_or_else(|_| "account".to_string()))
|
||||
});
|
||||
|
||||
pub struct AppState {
|
||||
|
||||
@@ -14,6 +14,7 @@ use db::{init_db, AppState, SURREAL_DB, SURREAL_NS, SURREAL_URL};
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
.plugin(tauri_plugin_store::Builder::default().build())
|
||||
.setup(|app| {
|
||||
let app_handle = app.handle().clone();
|
||||
tauri::async_runtime::block_on(async move {
|
||||
|
||||
Reference in New Issue
Block a user