mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-29 19:18:13 +08:00
WIP
This commit is contained in:
+23
-35
@@ -1,20 +1,20 @@
|
|||||||
const UPDATE_CHECK_URL: &str = "https://localhost:8080/v1/update";
|
const UPDATE_CHECK_URL: &str = "https://localhost:8080/v1/update";
|
||||||
|
|
||||||
async fn check_for_update(info: Info) -> UpdateCheckRsponse {
|
async fn check_for_update(info: Info) -> UpdateCheckResponse {
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
let response = client.post(UPDATE_CHECK_URL).json(&info).send().await;
|
let response = client.post(UPDATE_CHECK_URL).json(&info).send().await;
|
||||||
|
|
||||||
match response {
|
match response {
|
||||||
Ok(response) if response.status().is_success() => {
|
Ok(response) if response.status().is_success() => {
|
||||||
if let Ok(result) = response.json::<UpdateCheckRsponse>().await {
|
if let Ok(result) = response.json::<UpdateCheckResponse>().await {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
UpdateCheckRsponse {
|
UpdateCheckResponse {
|
||||||
status: Status::Unknown,
|
status: Status::Unknown,
|
||||||
messages: Vec::new(),
|
prompts: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ pub struct Info {
|
|||||||
pub commit: Commit,
|
pub commit: Commit,
|
||||||
pub version: Version,
|
pub version: Version,
|
||||||
pub system: System,
|
pub system: System,
|
||||||
pub source: Option<Source>,
|
pub distribution: Distribution,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
#[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
@@ -33,10 +33,9 @@ pub struct Commit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
#[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct Version {
|
pub enum Version {
|
||||||
pub major: u64,
|
Stable { major: u32, minor: u32, patch: u32 },
|
||||||
pub minor: u64,
|
Dev,
|
||||||
pub patch: u64,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
#[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
@@ -56,49 +55,38 @@ pub enum Os {
|
|||||||
pub enum Arch {
|
pub enum Arch {
|
||||||
X86_64,
|
X86_64,
|
||||||
Aarch64,
|
Aarch64,
|
||||||
|
Wasm32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
#[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum Source {
|
pub enum Distribution {
|
||||||
|
WebOfficial,
|
||||||
|
WebUnknown,
|
||||||
Flathub,
|
Flathub,
|
||||||
Nixpkgs,
|
Nixpkgs,
|
||||||
Steam,
|
Steam,
|
||||||
AppleAppStore,
|
MacAppStore,
|
||||||
WindowsStore,
|
WindowsStore,
|
||||||
Other(String),
|
Installer,
|
||||||
|
Portable,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
#[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct UpdateCheckRsponse {
|
pub struct UpdateCheckResponse {
|
||||||
status: Status,
|
status: Option<Prompt>,
|
||||||
messages: Vec<Message>,
|
prompts: Vec<Prompt>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
#[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct Message {
|
pub struct Prompt {
|
||||||
title: String,
|
title: String,
|
||||||
body: String,
|
body: String,
|
||||||
action: Action,
|
resolution: Option<Resolution>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
#[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||||
pub enum Action {
|
pub enum Resolution {
|
||||||
OpenUrl(String),
|
Visit { url: String },
|
||||||
PerformAutoUpdate,
|
AutoInstall { url: String, hash: String, version: Version, commit: Commit },
|
||||||
None,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
|
||||||
pub enum Status {
|
|
||||||
Available(Method),
|
|
||||||
Outdated,
|
|
||||||
Unknown,
|
|
||||||
Latest,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
|
||||||
pub enum Method {
|
|
||||||
Manual,
|
|
||||||
Auto { url: String },
|
|
||||||
PackageManager,
|
PackageManager,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user