add the winsparkle
没想到还挺简单
This commit is contained in:
parent
21353af9e4
commit
88d23ca773
@ -2,6 +2,7 @@
|
|||||||
name = "hardware_toolkit"
|
name = "hardware_toolkit"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
build = "build.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
iced = { git = "https://github.com/iced-rs/iced.git", features = [
|
iced = { git = "https://github.com/iced-rs/iced.git", features = [
|
||||||
@ -29,3 +30,7 @@ anyhow = { version = "1.0.98", features = ["backtrace"] }
|
|||||||
log = "0.4.27"
|
log = "0.4.27"
|
||||||
env_logger = "0.11.8"
|
env_logger = "0.11.8"
|
||||||
iced_fonts = { version = "0.2.1", features = ["full"] }
|
iced_fonts = { version = "0.2.1", features = ["full"] }
|
||||||
|
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
embed-resource = "3.0.3"
|
||||||
|
3
build.rs
Normal file
3
build.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fn main() {
|
||||||
|
println!("cargo:rustc-link-search=dylib=runtime");
|
||||||
|
}
|
BIN
runtime/WinSparkle.dll
Normal file
BIN
runtime/WinSparkle.dll
Normal file
Binary file not shown.
BIN
runtime/WinSparkle.lib
Normal file
BIN
runtime/WinSparkle.lib
Normal file
Binary file not shown.
@ -1,9 +1,15 @@
|
|||||||
mod ui;
|
mod ui;
|
||||||
mod utils;
|
mod utils;
|
||||||
mod widgets;
|
mod widgets;
|
||||||
mod winsparkle;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
tracing_subscriber::fmt::init();
|
tracing_subscriber::fmt::init();
|
||||||
|
unsafe {
|
||||||
|
use utils::winsparkle::*;
|
||||||
|
win_sparkle_set_appcast_url(
|
||||||
|
"https://dl.wuembed.com/hardware_tk/appcast.xml\0".as_ptr() as *const i8
|
||||||
|
);
|
||||||
|
win_sparkle_init();
|
||||||
|
}
|
||||||
ui::main_window::main_window();
|
ui::main_window::main_window();
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@ struct MainWindow {
|
|||||||
title: String,
|
title: String,
|
||||||
theme: iced::Theme,
|
theme: iced::Theme,
|
||||||
curr_tab: TabId,
|
curr_tab: TabId,
|
||||||
tabs: Vec<TabItem>,
|
|
||||||
home_page: crate::ui::home_page::HomePage,
|
home_page: crate::ui::home_page::HomePage,
|
||||||
jlc_downloader: crate::ui::jlc_downloader::JlcDownloader,
|
jlc_downloader: crate::ui::jlc_downloader::JlcDownloader,
|
||||||
db_browser: crate::ui::db_browser::DbBrowser,
|
db_browser: crate::ui::db_browser::DbBrowser,
|
||||||
@ -45,7 +44,6 @@ impl Default for MainWindow {
|
|||||||
curr_tab: Default::default(),
|
curr_tab: Default::default(),
|
||||||
home_page: Default::default(),
|
home_page: Default::default(),
|
||||||
jlc_downloader: Default::default(),
|
jlc_downloader: Default::default(),
|
||||||
tabs: Vec::new(),
|
|
||||||
db_browser: Default::default(),
|
db_browser: Default::default(),
|
||||||
part_viewer: Default::default(),
|
part_viewer: Default::default(),
|
||||||
}
|
}
|
||||||
@ -81,11 +79,6 @@ pub(crate) enum TabId {
|
|||||||
DbBrowser,
|
DbBrowser,
|
||||||
PartViewer,
|
PartViewer,
|
||||||
}
|
}
|
||||||
#[allow(dead_code)]
|
|
||||||
struct TabItem {
|
|
||||||
pub id: TabId,
|
|
||||||
content: Box<dyn Fn() -> Element<'static, MainWindowMsg>>,
|
|
||||||
}
|
|
||||||
impl Display for TabId {
|
impl Display for TabId {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(
|
write!(
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
pub mod app_settings;
|
pub mod app_settings;
|
||||||
pub mod step_downloader;
|
pub mod step_downloader;
|
||||||
|
pub mod winsparkle;
|
||||||
|
64
src/utils/winsparkle.rs
Normal file
64
src/utils/winsparkle.rs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
// lib.rs
|
||||||
|
// winsparkle-sys
|
||||||
|
|
||||||
|
#![cfg(target_os = "windows")]
|
||||||
|
|
||||||
|
// Link to the WinSparkle.dll
|
||||||
|
#[cfg_attr(target_os = "windows", link(name = "WinSparkle", kind = "dylib"))]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
unsafe extern "C" {
|
||||||
|
/// Initialize WinSparkle.
|
||||||
|
///
|
||||||
|
/// This initializes WinSparkle and should be called at application startup.
|
||||||
|
pub fn win_sparkle_init();
|
||||||
|
|
||||||
|
/// Clean up after WinSparkle.
|
||||||
|
///
|
||||||
|
/// Should be called at application shutdown.
|
||||||
|
/// Cancels any pending update checks and shuts down its helper threads.
|
||||||
|
pub fn win_sparkle_cleanup();
|
||||||
|
|
||||||
|
/// Set the URL for the appcast file.
|
||||||
|
///
|
||||||
|
/// This specifies the URL where WinSparkle will look for updates.
|
||||||
|
pub fn win_sparkle_set_appcast_url(url: *const i8);
|
||||||
|
|
||||||
|
/// Set DSA public key.
|
||||||
|
///
|
||||||
|
/// Only PEM format is supported.
|
||||||
|
/// Public key will be used to verify DSA signatures of the update file.
|
||||||
|
/// PEM data will be set only if it contains valid DSA public key.
|
||||||
|
///
|
||||||
|
/// If this function isn't called by the app, public key is obtained from
|
||||||
|
/// Windows resource named "DSAPub" of type "DSAPEM".
|
||||||
|
///
|
||||||
|
/// returns 1 if valid DSA public key provided, 0 otherwise.
|
||||||
|
pub fn win_sparkle_set_dsa_pub_pem(dsa_pub_pem: *const i8) -> i32;
|
||||||
|
|
||||||
|
/// Set the path in the registry where WinSparkle will store its settings.
|
||||||
|
///
|
||||||
|
/// This sets the path where WinSparkle will store its settings in the registry.
|
||||||
|
pub fn win_sparkle_set_registry_path(path: *const i8);
|
||||||
|
|
||||||
|
/// Set the callback function for handling shutdown requests.
|
||||||
|
///
|
||||||
|
/// This sets the callback function that WinSparkle will call when it receives a
|
||||||
|
/// request to shut down the application during an update.
|
||||||
|
pub fn win_sparkle_set_shutdown_request_callback(callback: Option<extern "C" fn() -> ()>);
|
||||||
|
|
||||||
|
/// Check for updates with the WinSparkle UI.
|
||||||
|
///
|
||||||
|
/// This checks for updates and displays the WinSparkle UI if an update is available.
|
||||||
|
pub fn win_sparkle_check_update_with_ui();
|
||||||
|
|
||||||
|
/// Check for updates with the WinSparkle UI
|
||||||
|
/// and immediately install the update if one is available.
|
||||||
|
pub fn win_sparkle_check_update_with_ui_and_install();
|
||||||
|
|
||||||
|
/// Check for updates.
|
||||||
|
///
|
||||||
|
/// No progress UI is shown to the user when checking.
|
||||||
|
/// If an update is available, the usual "update available" UI is shown.
|
||||||
|
/// This function is *not* completely UI-less.
|
||||||
|
pub fn win_sparkle_check_update_without_ui();
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user