11
This commit is contained in:
@@ -211,6 +211,7 @@ impl AppConfig {
|
||||
self.clear_server().await;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
match fetch_from_server(token).await {
|
||||
Ok(map) => {
|
||||
let mut g = self.inner.write().await;
|
||||
@@ -243,10 +244,15 @@ async fn fetch_from_server(token: &str) -> Result<HashMap<String, String>, AppCo
|
||||
format!("Bearer {}", token.trim()),
|
||||
);
|
||||
|
||||
let (status, v) = crate::api_client::request_json("GET", "/appConfig", None, headers)
|
||||
.await
|
||||
.map_err(|e| AppConfigError::Fetch(e))?;
|
||||
|
||||
let (status, v) = match crate::api_client::request_json("GET", "/appConfig", None, headers).await
|
||||
{
|
||||
Ok(pair) => pair,
|
||||
Err(e) => {
|
||||
log::warn!(target: "app_config", "GET /appConfig 请求失败(未拿到响应体): {e}");
|
||||
println!("GET /appConfig 请求失败(未拿到响应体): {e}");
|
||||
return Err(AppConfigError::Fetch(e));
|
||||
}
|
||||
};
|
||||
if status == 401 {
|
||||
return Err(AppConfigError::Fetch("未认证或令牌已失效".into()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user