62 lines
1.5 KiB
Rust
62 lines
1.5 KiB
Rust
#![cfg_attr(
|
|
all(not(debug_assertions), target_os = "windows"),
|
|
windows_subsystem = "windows"
|
|
)]
|
|
|
|
mod core;
|
|
mod picker;
|
|
mod rpc;
|
|
|
|
use crate::core::AmbientLightMode;
|
|
use crate::core::CoreManager;
|
|
use paris::*;
|
|
use picker::manager::Picker;
|
|
use std::vec;
|
|
|
|
#[tauri::command]
|
|
async fn take_snapshot() -> Vec<String> {
|
|
let manager = Picker::global();
|
|
|
|
let start = time::Instant::now();
|
|
let base64_bitmap_list = match manager.list_displays().await {
|
|
Ok(base64_bitmap_list) => {
|
|
info!("screenshots len: {}", base64_bitmap_list.len());
|
|
base64_bitmap_list
|
|
}
|
|
Err(error) => {
|
|
error!("can not take screenshots for all. {}", error);
|
|
|
|
vec![]
|
|
}
|
|
};
|
|
info!("截图花费 {} s", start.elapsed().as_seconds_f32());
|
|
base64_bitmap_list
|
|
}
|
|
|
|
#[tauri::command]
|
|
fn get_picker_config() -> picker::config::Configuration {
|
|
let configuration = picker::config::Manager::global().get_config();
|
|
info!("configuration: {:?}", configuration);
|
|
configuration
|
|
}
|
|
|
|
#[tauri::command]
|
|
async fn play_mode(target_mode: AmbientLightMode) {
|
|
info!("target mode: {:?}", target_mode);
|
|
|
|
CoreManager::global().set_ambient_light(target_mode).await;
|
|
}
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
rpc::manager::Manager::global();
|
|
tauri::Builder::default()
|
|
.invoke_handler(tauri::generate_handler![
|
|
take_snapshot,
|
|
play_mode,
|
|
get_picker_config,
|
|
])
|
|
.run(tauri::generate_context!())
|
|
.expect("error while running tauri application");
|
|
}
|