-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
561 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
pub const SUCCESS: i32 = 0; | ||
pub const MAA_CLI_NEED_UPDATE:i32 = 50; | ||
pub const MAA_CLI_NEED_UPDATE: i32 = 50; | ||
pub const DONE: i32 = 1; | ||
pub const ERROR: i32 = -999; | ||
pub const MAA_STATUS_STOP:u8 = 0; | ||
pub const MAA_STATUS_RUNNING:u8 = 1; | ||
pub const MAA_STATUS_STOP: u8 = 0; | ||
pub const MAA_STATUS_RUNNING: u8 = 1; | ||
pub const MAABO_ONLINE_VERSION_URL: &str = | ||
"https://api.github.com/repos/BoredTape/MaaBo/releases/latest"; | ||
pub const REQUEST_QA:&str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
pub const EVENT_GLOBAL_NOTIFICATION: &str = "global_notification"; | ||
pub const EVENT_INIT_MSG: &str = "init_msg"; | ||
pub const EVENT_UPDATE_CONFIG_STATUS: &str = "update_config_status"; | ||
pub const EVENT_UPDATE_MAA_CLI:&str = "maa_cli_update_msg"; | ||
pub const EVENT_UPDATE_MAA_CLI: &str = "maa_cli_update_msg"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use serde::Serialize; | ||
|
||
use crate::consts; | ||
use crate::events::payload; | ||
use crate::maa_cli; | ||
use crate::utils; | ||
|
||
#[derive(Debug, Clone, Serialize)] | ||
pub struct VersionInfo { | ||
maabo: String, | ||
maa_cli: String, | ||
maa_core: String, | ||
tauri: String, | ||
webview: String, | ||
} | ||
|
||
#[tauri::command] | ||
pub fn version_info() -> payload::Payload<VersionInfo> { | ||
let wv_version = tauri::webview_version().unwrap_or_else(|error| { | ||
log::info!("获取webview版本失败,请确认是否安装\n{}", error.to_string()); | ||
"获取失败".to_string() | ||
}); | ||
let (maa_cli_version, maa_core_version) = | ||
maa_cli::get_current_version().unwrap_or_else(|error| { | ||
log::info!("获取本地组件版本失败\n{}", error.to_string()); | ||
return ("获取失败".to_string(), "获取失败".to_string()); | ||
}); | ||
let info = VersionInfo { | ||
maabo: env!("CARGO_PKG_VERSION").to_string(), | ||
maa_cli: maa_cli_version, | ||
maa_core: maa_core_version, | ||
tauri: tauri::VERSION.to_string(), | ||
webview: wv_version, | ||
}; | ||
payload::new(consts::SUCCESS, "success".to_string(), info) | ||
} | ||
|
||
#[derive(Debug, Clone, Serialize)] | ||
pub struct CheckUpdateData { | ||
require_update: bool, | ||
from: String, | ||
to: String, | ||
} | ||
|
||
#[tauri::command] | ||
pub fn check_update() -> payload::Payload<CheckUpdateData> { | ||
let online_version = semver::Version::parse(&utils::fetch_online_version()) | ||
.unwrap_or_else(|_| semver::Version::parse(&"0.0.0").unwrap()); | ||
let current_version = semver::Version::parse(env!("CARGO_PKG_VERSION")) | ||
.unwrap_or_else(|_| semver::Version::parse(&"0.0.0").unwrap()); | ||
|
||
let resp_data = CheckUpdateData { | ||
require_update: online_version > current_version, | ||
from: current_version.to_string(), | ||
to: online_version.to_string(), | ||
}; | ||
payload::new(consts::SUCCESS, "success".to_string(), resp_data) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.