fix(Device): retrieve device screen size on reconnect

This commit is contained in:
AkiChase 2024-05-24 12:15:29 +08:00
parent 943454edc5
commit 4b48a6a563
4 changed files with 19 additions and 0 deletions

View File

@ -6,6 +6,8 @@ pub struct ClientInfo {
pub device_name: String, pub device_name: String,
pub device_id: String, pub device_id: String,
pub scid: String, pub scid: String,
pub width: i32,
pub height: i32,
} }
impl ClientInfo { impl ClientInfo {
@ -14,8 +16,15 @@ impl ClientInfo {
device_name, device_name,
device_id, device_id,
scid, scid,
width: 0,
height: 0,
} }
} }
pub fn set_size(&mut self, width: i32, height: i32) {
self.width = width;
self.height = height;
}
} }
lazy_static! { lazy_static! {

View File

@ -166,6 +166,12 @@ async fn handle_device_message(
"height": height "height": height
}) })
.to_string(); .to_string();
share::CLIENT_INFO
.lock()
.unwrap()
.as_mut()
.unwrap()
.set_size(width, height);
device_reply_sender.send(msg).await?; device_reply_sender.send(msg).await?;
} }
}; };

View File

@ -118,6 +118,8 @@ onActivated(async () => {
// restore controledDevice if client exists // restore controledDevice if client exists
if (curClientInfo) { if (curClientInfo) {
message.warning(t("pages.Device.alreadyControled")); message.warning(t("pages.Device.alreadyControled"));
store.screenSizeW = curClientInfo.width;
store.screenSizeH = curClientInfo.height;
store.controledDevice = { store.controledDevice = {
scid: curClientInfo.scid, scid: curClientInfo.scid,
deviceName: curClientInfo.device_name, deviceName: curClientInfo.device_name,

View File

@ -33,6 +33,8 @@ export async function getCurClientInfo(): Promise<{
device_name: string; device_name: string;
device_id: string; device_id: string;
scid: string; scid: string;
width: number;
height: number;
} | null> { } | null> {
return await invoke("get_cur_client_info"); return await invoke("get_cur_client_info");
} }