mirror of
https://mirror.suhoan.cn/https://github.com/EasyTier/EasyTier.git
synced 2025-12-12 20:57:26 +08:00
🎈 perf: 主机名提示显示本机主机名
This commit is contained in:
@@ -11,7 +11,11 @@ edition = "2021"
|
||||
tauri-build = { version = "1", features = [] }
|
||||
|
||||
[dependencies]
|
||||
tauri = { version = "1", features = [ "process-exit", "system-tray", "shell-open"] }
|
||||
tauri = { version = "1", features = [
|
||||
"process-exit",
|
||||
"system-tray",
|
||||
"shell-open",
|
||||
] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
|
||||
@@ -24,7 +28,7 @@ once_cell = "1.18.0"
|
||||
dashmap = "5.5.3"
|
||||
|
||||
privilege = "0.3"
|
||||
|
||||
gethostname = "0.4.3"
|
||||
[features]
|
||||
# This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!!
|
||||
custom-protocol = ["tauri/custom-protocol"]
|
||||
|
||||
@@ -283,6 +283,11 @@ fn collect_network_infos() -> Result<String, String> {
|
||||
Ok(serde_json::to_string(&ret).map_err(|e| e.to_string())?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn get_os_hostname() -> Result<String, String> {
|
||||
Ok(gethostname::gethostname().to_string_lossy().to_string())
|
||||
}
|
||||
|
||||
fn toggle_window_visibility(window: &Window) {
|
||||
if window.is_visible().unwrap() {
|
||||
window.hide().unwrap();
|
||||
@@ -320,7 +325,8 @@ fn main() {
|
||||
parse_network_config,
|
||||
run_network_instance,
|
||||
retain_network_instance,
|
||||
collect_network_infos
|
||||
collect_network_infos,
|
||||
get_os_hostname
|
||||
])
|
||||
.system_tray(SystemTray::new().with_menu(tray_menu))
|
||||
.on_system_tray_event(|app, event| match event {
|
||||
|
||||
Reference in New Issue
Block a user