From f0f8414bf29fd5b17133fd0f78ef19a664436f61 Mon Sep 17 00:00:00 2001 From: z_lenovo Date: Thu, 19 Jun 2025 18:58:30 +0800 Subject: [PATCH] first commit first commit,nothing important. --- Cargo.toml | 26 ++++++++++++ README.md | 19 +++++++++ res/res.rc | 1 + src/main.rs | 7 +++ src/ui/db_browser.rs | 0 src/ui/home_page.rs | 0 src/ui/jlc_downloader.rs | 0 src/ui/main_window.rs | 1 + src/ui/mod.rs | 5 +++ src/ui/part_viewer.rs | 0 src/utils/app_settings.rs | 82 ++++++++++++++++++++++++++++++++++++ src/utils/mod.rs | 2 + src/utils/step_downloader.rs | 0 src/widgets/mod.rs | 0 src/winsparkle/mod.rs | 1 + src/winsparkle/winsparkle.rs | 0 16 files changed, 144 insertions(+) create mode 100644 Cargo.toml create mode 100644 res/res.rc create mode 100644 src/main.rs create mode 100644 src/ui/db_browser.rs create mode 100644 src/ui/home_page.rs create mode 100644 src/ui/jlc_downloader.rs create mode 100644 src/ui/main_window.rs create mode 100644 src/ui/mod.rs create mode 100644 src/ui/part_viewer.rs create mode 100644 src/utils/app_settings.rs create mode 100644 src/utils/mod.rs create mode 100644 src/utils/step_downloader.rs create mode 100644 src/widgets/mod.rs create mode 100644 src/winsparkle/mod.rs create mode 100644 src/winsparkle/winsparkle.rs diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..4ebdbf3 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "hardware_toolkit" +version = "0.1.0" +edition = "2024" + +[dependencies] +tokio = { version = "1.45.1", features = ["full"] } +iced = { git = "https://github.com/iced-rs/iced.git" } +iced_aw = { git = "https://github.com/iced-rs/iced_aw.git" } +reqwest = "0.12.20" +tracing-subscriber = { version = "0.3.19", features = [ + "chrono", + "env-filter", + "json", + "once_cell", + "regex", + "serde", + "serde_json", + "time", + "tracing", +] } +utfx = "0.1.0" +registry = "1.3.0" +anyhow = { version = "1.0.98", features = ["backtrace"] } +log = "0.4.27" +env_logger = "0.11.8" diff --git a/README.md b/README.md index 413c67d..361a618 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,21 @@ # hardware_toolkit +## 设计初衷 +* 设计一个硬件工程师的通用工具 + + + +## 功能规划 + + + + +## 展望 + + +## 待办 + + + +## 周期性待办 +* 把所有的警告消灭掉 diff --git a/res/res.rc b/res/res.rc new file mode 100644 index 0000000..60ab2d4 --- /dev/null +++ b/res/res.rc @@ -0,0 +1 @@ +APP_ICON ICON app_icon.ico diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..79c39d0 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,7 @@ +mod ui; +mod utils; +mod winsparkle; +fn main() { + #[cfg(debug_assertions)] + tracing_subscriber::fmt::init(); +} diff --git a/src/ui/db_browser.rs b/src/ui/db_browser.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/ui/home_page.rs b/src/ui/home_page.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/ui/jlc_downloader.rs b/src/ui/jlc_downloader.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/ui/main_window.rs b/src/ui/main_window.rs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/ui/main_window.rs @@ -0,0 +1 @@ + diff --git a/src/ui/mod.rs b/src/ui/mod.rs new file mode 100644 index 0000000..cb9db82 --- /dev/null +++ b/src/ui/mod.rs @@ -0,0 +1,5 @@ +mod db_browser; +mod home_page; +mod jlc_downloader; +pub mod main_window; +mod part_viewer; diff --git a/src/ui/part_viewer.rs b/src/ui/part_viewer.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/utils/app_settings.rs b/src/utils/app_settings.rs new file mode 100644 index 0000000..7023c96 --- /dev/null +++ b/src/utils/app_settings.rs @@ -0,0 +1,82 @@ +use registry::Security; + +const APP_REG_PATH: &str = r"Software\HardwareToolkit\"; +pub fn get_lib_dir() -> Result { + let reg = registry::Hive::CurrentUser.open(APP_REG_PATH, Security::AllAccess)?; + let path = reg.value("lib_path")?; + Ok(path.to_string()) +} + +pub fn set_lib_dir(path: &str) -> Result<(), anyhow::Error> { + let path = utfx::U16CString::from_str(path)?; + let reg = registry::Hive::CurrentUser.create(APP_REG_PATH, Security::AllAccess)?; + reg.set_value("lib_path", ®istry::Data::String(path))?; + Ok(()) +} + +pub fn get_odbc_name() -> Result { + let reg = registry::Hive::CurrentUser.open(APP_REG_PATH, Security::AllAccess)?; + let name = reg.value("odbc_name")?; + Ok(name.to_string()) +} + +pub fn set_odbc_name(name: &str) -> Result<(), anyhow::Error> { + let name = utfx::U16CString::from_str(name)?; + registry::Hive::CurrentUser + .create(APP_REG_PATH, Security::AllAccess)? + .set_value("odbc_name", ®istry::Data::String(name))?; + Ok(()) +} + +pub fn get_step_dir() -> Result { + let reg = registry::Hive::CurrentUser.open(APP_REG_PATH, Security::AllAccess)?; + let path = reg.value("step_path")?; + Ok(path.to_string()) +} + +pub fn set_step_dir(path: &str) -> Result<(), anyhow::Error> { + let path = utfx::U16CString::from_str(path)?; + let reg = registry::Hive::CurrentUser.create(APP_REG_PATH, Security::AllAccess)?; + reg.set_value("step_path", ®istry::Data::String(path))?; + Ok(()) +} + +pub fn set_curr_page(c: u32) -> Result<(), anyhow::Error> { + let reg = registry::Hive::CurrentUser.create(APP_REG_PATH, Security::AllAccess)?; + reg.set_value("curr_page", ®istry::Data::U32(c))?; + Ok(()) +} +pub fn get_curr_page() -> Result { + let reg = registry::Hive::CurrentUser.open(APP_REG_PATH, Security::AllAccess)?; + match reg.value("curr_page")? { + registry::Data::U32(v) => { + return Ok(v); + } + _ => { + log::info!("The curr_page is an empty value."); + } + } + Ok(0) +} + +#[cfg(test)] +mod app_settings_test { + use crate::utils::app_settings::{get_step_dir, set_step_dir}; + + #[test] + fn test_get_set_step_dir() { + let test_path = "DEADBEAF"; + let ori = get_step_dir(); + assert!(set_step_dir(test_path).is_ok()); + assert!(get_step_dir().is_ok()); + assert_eq!(get_step_dir().unwrap().as_str(), test_path); + match ori { + Ok(r) => { + assert!(set_step_dir(r.as_str()).is_ok()); + } + Err(e) => { + println!("FUCK: {e:?}"); + } + } + } +} diff --git a/src/utils/mod.rs b/src/utils/mod.rs new file mode 100644 index 0000000..80d2075 --- /dev/null +++ b/src/utils/mod.rs @@ -0,0 +1,2 @@ +pub mod app_settings; +pub mod step_downloader; diff --git a/src/utils/step_downloader.rs b/src/utils/step_downloader.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/widgets/mod.rs b/src/widgets/mod.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/winsparkle/mod.rs b/src/winsparkle/mod.rs new file mode 100644 index 0000000..d0bf91f --- /dev/null +++ b/src/winsparkle/mod.rs @@ -0,0 +1 @@ +pub mod winsparkle; diff --git a/src/winsparkle/winsparkle.rs b/src/winsparkle/winsparkle.rs new file mode 100644 index 0000000..e69de29