first commit
first commit,nothing important.
This commit is contained in:
parent
39b0f09808
commit
f0f8414bf2
26
Cargo.toml
Normal file
26
Cargo.toml
Normal file
@ -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"
|
19
README.md
19
README.md
@ -1,2 +1,21 @@
|
||||
# hardware_toolkit
|
||||
|
||||
## 设计初衷
|
||||
* 设计一个硬件工程师的通用工具
|
||||
|
||||
|
||||
|
||||
## 功能规划
|
||||
|
||||
|
||||
|
||||
|
||||
## 展望
|
||||
|
||||
|
||||
## 待办
|
||||
|
||||
|
||||
|
||||
## 周期性待办
|
||||
* 把所有的警告消灭掉
|
||||
|
1
res/res.rc
Normal file
1
res/res.rc
Normal file
@ -0,0 +1 @@
|
||||
APP_ICON ICON app_icon.ico
|
7
src/main.rs
Normal file
7
src/main.rs
Normal file
@ -0,0 +1,7 @@
|
||||
mod ui;
|
||||
mod utils;
|
||||
mod winsparkle;
|
||||
fn main() {
|
||||
#[cfg(debug_assertions)]
|
||||
tracing_subscriber::fmt::init();
|
||||
}
|
0
src/ui/db_browser.rs
Normal file
0
src/ui/db_browser.rs
Normal file
0
src/ui/home_page.rs
Normal file
0
src/ui/home_page.rs
Normal file
0
src/ui/jlc_downloader.rs
Normal file
0
src/ui/jlc_downloader.rs
Normal file
1
src/ui/main_window.rs
Normal file
1
src/ui/main_window.rs
Normal file
@ -0,0 +1 @@
|
||||
|
5
src/ui/mod.rs
Normal file
5
src/ui/mod.rs
Normal file
@ -0,0 +1,5 @@
|
||||
mod db_browser;
|
||||
mod home_page;
|
||||
mod jlc_downloader;
|
||||
pub mod main_window;
|
||||
mod part_viewer;
|
0
src/ui/part_viewer.rs
Normal file
0
src/ui/part_viewer.rs
Normal file
82
src/utils/app_settings.rs
Normal file
82
src/utils/app_settings.rs
Normal file
@ -0,0 +1,82 @@
|
||||
use registry::Security;
|
||||
|
||||
const APP_REG_PATH: &str = r"Software\HardwareToolkit\";
|
||||
pub fn get_lib_dir() -> Result<String, anyhow::Error> {
|
||||
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<String, anyhow::Error> {
|
||||
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<String, anyhow::Error> {
|
||||
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<u32, anyhow::Error> {
|
||||
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:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
2
src/utils/mod.rs
Normal file
2
src/utils/mod.rs
Normal file
@ -0,0 +1,2 @@
|
||||
pub mod app_settings;
|
||||
pub mod step_downloader;
|
0
src/utils/step_downloader.rs
Normal file
0
src/utils/step_downloader.rs
Normal file
0
src/widgets/mod.rs
Normal file
0
src/widgets/mod.rs
Normal file
1
src/winsparkle/mod.rs
Normal file
1
src/winsparkle/mod.rs
Normal file
@ -0,0 +1 @@
|
||||
pub mod winsparkle;
|
0
src/winsparkle/winsparkle.rs
Normal file
0
src/winsparkle/winsparkle.rs
Normal file
Loading…
x
Reference in New Issue
Block a user