mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-22 19:52:14 +08:00
refactor: simplify function return types and remove unnecessary wraps
This commit is contained in:
@@ -3,6 +3,7 @@ use crate::cmd::StringifyErr as _;
|
||||
use crate::core::{EventDrivenProxyManager, async_proxy_query::AsyncProxyQuery};
|
||||
use crate::process::AsyncHandler;
|
||||
use crate::{logging, utils::logging::Type};
|
||||
use gethostname::gethostname;
|
||||
use network_interface::NetworkInterface;
|
||||
use serde_yaml_ng::Mapping;
|
||||
|
||||
@@ -61,11 +62,9 @@ pub async fn get_auto_proxy() -> CmdResult<Mapping> {
|
||||
|
||||
/// 获取系统主机名
|
||||
#[tauri::command]
|
||||
pub fn get_system_hostname() -> CmdResult<String> {
|
||||
use gethostname::gethostname;
|
||||
|
||||
pub fn get_system_hostname() -> String {
|
||||
// 获取系统主机名,处理可能的非UTF-8字符
|
||||
let hostname = match gethostname().into_string() {
|
||||
match gethostname().into_string() {
|
||||
Ok(name) => name,
|
||||
Err(os_string) => {
|
||||
// 对于包含非UTF-8的主机名,使用调试格式化
|
||||
@@ -73,9 +72,7 @@ pub fn get_system_hostname() -> CmdResult<String> {
|
||||
// 去掉可能存在的引号
|
||||
fallback.trim_matches('"').to_string()
|
||||
}
|
||||
};
|
||||
|
||||
Ok(hostname)
|
||||
}
|
||||
}
|
||||
|
||||
/// 获取网络接口列表
|
||||
|
||||
Reference in New Issue
Block a user