pref: 移除旧的截图图像发送到前端的逻辑。
This commit is contained in:
parent
85ef261c51
commit
9ed2fa8b53
@ -167,12 +167,9 @@ async fn main() {
|
||||
subscribe_encoded_screenshot_updated
|
||||
])
|
||||
.register_uri_scheme_protocol("ambient-light", move |_app, request| {
|
||||
info!("request: {:?}", request.uri());
|
||||
// prepare our response
|
||||
let response = ResponseBuilder::new().header("Access-Control-Allow-Origin", "*");
|
||||
// get the file path
|
||||
let uri = request.uri();
|
||||
|
||||
let uri = request.uri();
|
||||
let uri = percent_encoding::percent_decode_str(uri)
|
||||
.decode_utf8()
|
||||
.unwrap()
|
||||
@ -226,7 +223,7 @@ async fn main() {
|
||||
.unwrap();
|
||||
(screenshot.width as f32 / width as f32, width, height)
|
||||
} else {
|
||||
info!("scale by scale_factor");
|
||||
log::debug!("scale by scale_factor");
|
||||
let scale_factor = screenshot.scale_factor;
|
||||
(
|
||||
scale_factor,
|
||||
@ -234,7 +231,7 @@ async fn main() {
|
||||
(screenshot.height as f32 / scale_factor) as u32,
|
||||
)
|
||||
};
|
||||
info!(
|
||||
log::debug!(
|
||||
"scale by query. width: {}, height: {}, scale_factor: {}, len: {}",
|
||||
width,
|
||||
height,
|
||||
|
@ -38,5 +38,5 @@ pub struct ScreenshotPayload {
|
||||
pub display_id: u32,
|
||||
pub height: u32,
|
||||
pub width: u32,
|
||||
pub base64_image: String,
|
||||
// pub base64_image: String,
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ impl ScreenshotManager {
|
||||
}
|
||||
loop {
|
||||
Self::take_screenshot_loop(display_id, scale_factor, &tx).await;
|
||||
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
|
||||
tokio::time::sleep(std::time::Duration::from_millis(20)).await;
|
||||
}
|
||||
});
|
||||
|
||||
@ -150,31 +150,31 @@ impl ScreenshotManager {
|
||||
break;
|
||||
}
|
||||
let screenshot = rx.borrow().clone();
|
||||
let base64_image = Self::encode_screenshot_to_base64(&screenshot).await;
|
||||
// let base64_image = Self::encode_screenshot_to_base64(&screenshot).await;
|
||||
let height = screenshot.height;
|
||||
let width = screenshot.width;
|
||||
|
||||
if base64_image.is_err() {
|
||||
error!(
|
||||
"subscribe_encoded_screenshot_updated: encode_screenshot_to_base64 error {}",
|
||||
base64_image.err().unwrap()
|
||||
);
|
||||
continue;
|
||||
}
|
||||
// if base64_image.is_err() {
|
||||
// error!(
|
||||
// "subscribe_encoded_screenshot_updated: encode_screenshot_to_base64 error {}",
|
||||
// base64_image.err().unwrap()
|
||||
// );
|
||||
// continue;
|
||||
// }
|
||||
|
||||
let base64_image = base64_image.unwrap();
|
||||
// let base64_image = base64_image.unwrap();
|
||||
for window in windows.unwrap().into_iter() {
|
||||
let base64_image = base64_image.clone();
|
||||
// let base64_image = base64_image.clone();
|
||||
let payload = ScreenshotPayload {
|
||||
display_id,
|
||||
base64_image,
|
||||
// base64_image,
|
||||
height,
|
||||
width,
|
||||
};
|
||||
if let Err(err) = window.emit("encoded-screenshot-updated", payload) {
|
||||
error!("subscribe_encoded_screenshot_updated: emit error {}", err)
|
||||
} else {
|
||||
info!(
|
||||
log::debug!(
|
||||
"subscribe_encoded_screenshot_updated: emit success. display#{}",
|
||||
display_id
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user