Skip to content

Commit 5e8ffed

Browse files
committed
feat: add store
1 parent 9a3896d commit 5e8ffed

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ tauri-build = { version = "1.5", features = [] }
1414

1515
[dependencies]
1616
tauri = { version = "1.5.2", features = ["shell-open"] }
17+
tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
1718
serde = { version = "1.0.192", features = ["derive"] }
1819
serde_json = "1.0.108"
1920
tokio = "1.34.0"

src-tauri/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub struct AppState {
1919

2020
fn main() {
2121
tauri::Builder::default()
22+
.plugin(tauri_plugin_store::Builder::default().build())
2223
.setup(|app| {
2324
#[cfg(debug_assertions)]
2425
{

src/store/db.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,25 @@ pub struct DBStore {
1818

1919
impl Default for DBStore {
2020
fn default() -> Self {
21-
Self::new()
21+
Self::new(None, None, None, None)
2222
}
2323
}
2424

2525
impl DBStore {
26-
pub fn new() -> Self {
26+
pub fn new(
27+
db_hust: Option<String>,
28+
db_post: Option<String>,
29+
db_user: Option<String>,
30+
db_password: Option<String>,
31+
) -> Self {
2732
Self {
2833
schemas: create_rw_signal(HashMap::new()),
2934
tables: create_rw_signal(HashMap::new()),
3035
is_connecting: create_rw_signal(false),
31-
db_host: create_rw_signal(String::new()),
32-
db_port: create_rw_signal(String::new()),
33-
db_user: create_rw_signal(String::new()),
34-
db_password: create_rw_signal(String::new()),
36+
db_host: create_rw_signal(db_hust.unwrap_or(String::new())),
37+
db_port: create_rw_signal(db_post.unwrap_or(String::new())),
38+
db_user: create_rw_signal(db_user.unwrap_or(String::new())),
39+
db_password: create_rw_signal(db_password.unwrap_or(String::new())),
3540
}
3641
}
3742

0 commit comments

Comments
 (0)