mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 17:15:38 +08:00
fix: #3227, use async operations to avoid blocking on
This commit is contained in:
@@ -36,13 +36,8 @@ impl PlatformSpecification {
|
||||
let config = handler.config();
|
||||
let verge_version = config.version.clone().unwrap_or("Null".into());
|
||||
|
||||
// Get running mode asynchronously
|
||||
let running_mode = tokio::task::block_in_place(|| {
|
||||
tokio::runtime::Handle::current().block_on(async {
|
||||
let running_mode = CoreManager::global().get_running_mode().await;
|
||||
running_mode.to_string()
|
||||
})
|
||||
});
|
||||
// 使用默认值避免在同步上下文中执行异步操作
|
||||
let running_mode = "NotRunning".to_string();
|
||||
|
||||
let is_admin = match system::is_admin() {
|
||||
Ok(value) => value,
|
||||
@@ -59,4 +54,14 @@ impl PlatformSpecification {
|
||||
is_admin,
|
||||
}
|
||||
}
|
||||
|
||||
// 异步方法来获取完整的系统信息
|
||||
pub async fn new_async() -> Self {
|
||||
let mut info = Self::new();
|
||||
|
||||
let running_mode = CoreManager::global().get_running_mode().await;
|
||||
info.running_mode = running_mode.to_string();
|
||||
|
||||
info
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user