From 6608bf882f3a804304b09d622bb06d456cd146a9 Mon Sep 17 00:00:00 2001 From: dignow Date: Fri, 11 Aug 2023 19:28:25 +0800 Subject: [PATCH] refactor, remove login device info in sciter Signed-off-by: dignow --- src/ui.rs | 6 +++--- src/ui/index.tis | 15 +-------------- src/ui_interface.rs | 6 +----- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/src/ui.rs b/src/ui.rs index 309d0aa6b..27793b31f 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -595,8 +595,8 @@ impl UI { handle_relay_id(id) } - fn get_hostname(&self) -> String { - get_hostname() + fn get_login_device_info(&self) -> String { + get_login_device_info_json() } } @@ -682,7 +682,7 @@ impl sciter::EventHandler for UI { fn get_langs(); fn default_video_save_directory(); fn handle_relay_id(String); - fn get_hostname(); + fn get_login_device_info(); } } diff --git a/src/ui/index.tis b/src/ui/index.tis index c6286e903..9d09dd7a7 100644 --- a/src/ui/index.tis +++ b/src/ui/index.tis @@ -1323,18 +1323,5 @@ function getHttpHeaders() { } function getDeviceInfo() { - var os; - if (is_win) { - os = 'windows'; - } else if (is_linux) { - os = 'linux'; - } else if (is_osx) { - os = 'macos'; - } - - return { - os: os, - type: 'client', - name: handler.get_hostname() - }; + return JSON.parse(handler.get_login_device_info()); } diff --git a/src/ui_interface.rs b/src/ui_interface.rs index 51f848457..f6791de0b 100644 --- a/src/ui_interface.rs +++ b/src/ui_interface.rs @@ -974,10 +974,6 @@ pub fn get_fingerprint() -> String { return ipc::get_fingerprint(); } -pub fn get_hostname() -> String { - crate::common::hostname() -} - #[inline] pub fn get_login_device_info() -> LoginDeviceInfo { LoginDeviceInfo { @@ -990,7 +986,7 @@ pub fn get_login_device_info() -> LoginDeviceInfo { #[inline] pub fn get_login_device_info_json() -> String { - serde_json::to_string(&get_login_device_info()).unwrap_or_default() + serde_json::to_string(&get_login_device_info()).unwrap_or("{}".to_string()) } // notice: avoiding create ipc connection repeatedly,