Manually check for updates

This commit is contained in:
tk103331
2023-01-04 12:43:26 +08:00
parent b8614e73ff
commit c19698bc41
4 changed files with 94 additions and 3 deletions

View File

@@ -24,6 +24,7 @@ pub fn init() -> Menu {
MenuItem::About(name.into(), AboutMetadata::default()).into(),
#[cfg(not(target_os = "macos"))]
CustomMenuItem::new("about".to_string(), "About ChatGPT").into(),
CustomMenuItem::new("check_update".to_string(), "Check for Updates").into(),
MenuItem::Services.into(),
MenuItem::Hide.into(),
MenuItem::HideOthers.into(),
@@ -192,6 +193,17 @@ pub fn menu_handler(event: WindowMenuEvent<tauri::Wry>) {
format!("Version {}", tauri_conf.package.version.unwrap()),
);
}
"check_update" => {
tauri::async_runtime::spawn(async move {
let result = app.updater().check().await;
let update_resp = result.unwrap();
if update_resp.is_update_available() {
tauri::async_runtime::spawn(async move {
utils::prompt_for_install(app, update_resp).await.unwrap();
});
}
});
}
// Preferences
"control_center" => window::control_window(&app),
"restart" => tauri::api::process::restart(&app.env()),