fix, login device info
Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
parent
09a6b3c30a
commit
e6dd082b0f
5 changed files with 49 additions and 29 deletions
|
|
@ -44,6 +44,13 @@ pub struct UiStatus {
|
|||
pub id: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct LoginDeviceInfo {
|
||||
pub os: String,
|
||||
pub r#type: String,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref UI_STATUS : Arc<Mutex<UiStatus>> = Arc::new(Mutex::new(UiStatus{
|
||||
status_num: 0,
|
||||
|
|
@ -56,6 +63,13 @@ lazy_static::lazy_static! {
|
|||
}));
|
||||
static ref ASYNC_JOB_STATUS : Arc<Mutex<String>> = Default::default();
|
||||
static ref TEMPORARY_PASSWD : Arc<Mutex<String>> = Arc::new(Mutex::new("".to_owned()));
|
||||
static ref LOGIN_DEVICE_INFO: Arc<LoginDeviceInfo> = Arc::new(LoginDeviceInfo{
|
||||
// std::env::consts::OS is better than whoami::platform() here.
|
||||
os: std::env::consts::OS.to_owned(),
|
||||
r#type: "client".to_owned(),
|
||||
name: crate::common::hostname(),
|
||||
});
|
||||
static ref LOGIN_DEVICE_INFO_JSON: Arc<String> = Arc::new(serde_json::to_string(&**LOGIN_DEVICE_INFO).unwrap_or_default());
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
|
|
@ -959,6 +973,16 @@ pub fn get_hostname() -> String {
|
|||
crate::common::hostname()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_login_device_info() -> LoginDeviceInfo {
|
||||
(**LOGIN_DEVICE_INFO).clone()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_login_device_info_json() -> String {
|
||||
(**LOGIN_DEVICE_INFO_JSON).clone()
|
||||
}
|
||||
|
||||
// notice: avoiding create ipc connection repeatedly,
|
||||
// because windows named pipe has serious memory leak issue.
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue