fix: 切换到后台后一分钟内,截图效率降低的问题。

This commit is contained in:
Ivan Li 2023-01-26 23:30:28 +08:00
parent 2058220ead
commit a33659c8c5
3 changed files with 15 additions and 1 deletions

12
src-tauri/Cargo.lock generated
View File

@ -779,6 +779,7 @@ dependencies = [
"futures",
"hex",
"image",
"macos-app-nap",
"mdns",
"once_cell",
"paris",
@ -1771,6 +1772,17 @@ dependencies = [
"time",
]
[[package]]
name = "macos-app-nap"
version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9701bd74bcff7fb5f9bff8ff4930a889a55f9cccc8a0dfc4c51ea08b786f0c6a"
dependencies = [
"cc",
"cocoa-foundation",
"objc",
]
[[package]]
name = "malloc_buf"
version = "0.0.6"

View File

@ -35,6 +35,7 @@ futures = "0.3.25"
either = "1.8.0"
image = "0.24.5"
mdns = "3.0.0"
macos-app-nap = "0.0.1"
[features]
# by default Tauri runs in production mode

View File

@ -92,6 +92,7 @@ impl CoreManager {
}
pub async fn play_follow(&self) -> anyhow::Result<()> {
macos_app_nap::prevent();
let mut futs = vec![];
let configs = picker::config::Manager::global().reload_config().await;
let configs = match configs {
@ -220,7 +221,7 @@ impl CoreManager {
if let AmbientLightMode::Follow = *lock {
drop(lock);
let screenshot = picker.take_screenshot()?;
// info!("Take Screenshot Spend: {:?}", start.elapsed());
info!("Take Screenshot Spend: {:?}", start.elapsed());
match tx.send(screenshot).await {
Ok(_) => {}
Err(err) => {