From 9ed2fa8b5354245e8faccd8bd441d2712a72e826 Mon Sep 17 00:00:00 2001 From: Ivan Li Date: Mon, 20 Mar 2023 09:35:02 +0800 Subject: [PATCH] =?UTF-8?q?pref:=20=E7=A7=BB=E9=99=A4=E6=97=A7=E7=9A=84?= =?UTF-8?q?=E6=88=AA=E5=9B=BE=E5=9B=BE=E5=83=8F=E5=8F=91=E9=80=81=E5=88=B0?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E7=9A=84=E9=80=BB=E8=BE=91=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/src/main.rs | 9 +++------ src-tauri/src/screenshot.rs | 2 +- src-tauri/src/screenshot_manager.rs | 26 +++++++++++++------------- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 2836328..bd370da 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -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, diff --git a/src-tauri/src/screenshot.rs b/src-tauri/src/screenshot.rs index 148fa02..e610314 100644 --- a/src-tauri/src/screenshot.rs +++ b/src-tauri/src/screenshot.rs @@ -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, } diff --git a/src-tauri/src/screenshot_manager.rs b/src-tauri/src/screenshot_manager.rs index 7cb2c97..7786e62 100644 --- a/src-tauri/src/screenshot_manager.rs +++ b/src-tauri/src/screenshot_manager.rs @@ -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 )