mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-13 07:34:36 +01:00
new release notifications
This commit is contained in:
@@ -23,6 +23,7 @@ mod file_helpers;
|
||||
mod gamebanana;
|
||||
mod lang;
|
||||
mod proxy;
|
||||
mod release;
|
||||
mod system_helpers;
|
||||
mod unzip;
|
||||
mod web;
|
||||
@@ -57,7 +58,7 @@ fn main() {
|
||||
println!("You running as a non-elevated user. Some stuff will almost definitely not work.");
|
||||
println!("===============================================================================");
|
||||
|
||||
reopen_as_admin();
|
||||
//reopen_as_admin();
|
||||
}
|
||||
|
||||
// Setup datadir/cultivation just in case something went funky and it wasn't made
|
||||
@@ -108,6 +109,7 @@ fn main() {
|
||||
system_helpers::run_un_elevated,
|
||||
proxy::set_proxy_addr,
|
||||
proxy::generate_ca_files,
|
||||
release::get_latest_release,
|
||||
unzip::unzip,
|
||||
file_helpers::rename,
|
||||
file_helpers::dir_create,
|
||||
|
||||
32
src-tauri/src/release.rs
Normal file
32
src-tauri/src/release.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
pub struct Release {
|
||||
pub tag_name: String,
|
||||
pub link: String,
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_latest_release() -> Release {
|
||||
let url = "https://api.github.com/repos/Grasscutters/Cultivation/releases/latest";
|
||||
let client = reqwest::Client::new();
|
||||
let response = client
|
||||
.get(url)
|
||||
.header("User-Agent", "Cultivation")
|
||||
.send()
|
||||
.await
|
||||
.unwrap();
|
||||
let text = response.text().await.unwrap();
|
||||
|
||||
println!("Response: {}", text);
|
||||
|
||||
// Parse "tag_name" from JSON
|
||||
let json: serde_json::Value = serde_json::from_str(&text).unwrap();
|
||||
let tag_name = json["tag_name"].as_str().unwrap();
|
||||
|
||||
// Parse "html_url"
|
||||
let link = json["html_url"].as_str().unwrap();
|
||||
|
||||
Release {
|
||||
tag_name: tag_name.to_string(),
|
||||
link: link.to_string(),
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
},
|
||||
"package": {
|
||||
"productName": "Cultivation",
|
||||
"version": "1.0.25"
|
||||
"version": "1.0.26"
|
||||
},
|
||||
"tauri": {
|
||||
"allowlist": {
|
||||
|
||||
Reference in New Issue
Block a user