feat(update): 应用内更新提示支持英文 release notes
This commit is contained in:
1 parent
f45011977f
commit
9cbe857a2a
11 files changed
+214
-20
No files matched your search
@@ -1,4 +1,4 @@
|
||||
use axum::Json;
|
||||
use axum::{extract::Query, Json};
|
||||
use dbx_core::update;
|
||||
|
||||
use crate::error::AppError;
|
||||
@@ -7,8 +7,15 @@ pub async fn get_version() -> Json<serde_json::Value> {
|
||||
Json(serde_json::json!({ "version": env!("CARGO_PKG_VERSION") }))
|
||||
}
|
||||
|
||||
pub async fn check_for_updates() -> Result<Json<serde_json::Value>, AppError> {
|
||||
let release = update::fetch_latest_release().await.map_err(AppError)?;
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct UpdateCheckParams {
|
||||
#[serde(default)]
|
||||
pub locale: Option<String>,
|
||||
}
|
||||
|
||||
pub async fn check_for_updates(Query(params): Query<UpdateCheckParams>) -> Result<Json<serde_json::Value>, AppError> {
|
||||
let locale = params.locale.unwrap_or_else(|| "zh-CN".to_string());
|
||||
let release = update::fetch_latest_release(&locale).await.map_err(AppError)?;
|
||||
let info = update::build_update_info(release, env!("CARGO_PKG_VERSION"));
|
||||
Ok(Json(serde_json::to_value(info).map_err(|e| AppError(e.to_string()))?))
|
||||
}
|
||||
Reference in new issue
Block a user