74 lines
2.1 KiB
Rust
74 lines
2.1 KiB
Rust
#![allow(dead_code)]
|
|
#![feature(stmt_expr_attributes)]
|
|
|
|
use std::sync::Arc;
|
|
|
|
use tauri::{
|
|
async_runtime::{self, RwLock},
|
|
generate_handler, Manager,
|
|
};
|
|
use tauri_plugin_dialog::DialogExt;
|
|
|
|
mod bluetooth;
|
|
mod canvas_model;
|
|
mod cmd;
|
|
mod config_db;
|
|
mod errors;
|
|
mod fraction;
|
|
mod pattern;
|
|
mod playlist;
|
|
mod protocols;
|
|
mod state;
|
|
|
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
|
pub fn run() {
|
|
#[cfg(debug_assertions)]
|
|
let devtools = tauri_plugin_devtools::init();
|
|
|
|
let mut builder = tauri::Builder::default();
|
|
|
|
#[cfg(debug_assertions)]
|
|
builder = builder.plugin(devtools);
|
|
|
|
builder
|
|
.plugin(tauri_plugin_os::init())
|
|
.plugin(tauri_plugin_opener::init())
|
|
.plugin(tauri_plugin_single_instance::init(|_app, _args, _cwd| {}))
|
|
.plugin(tauri_plugin_dialog::init())
|
|
.plugin(tauri_plugin_notification::init())
|
|
.setup(|app| {
|
|
if let Err(e) = async_runtime::block_on(async {
|
|
let state = state::AppState::new(app.handle()).await?;
|
|
app.manage(Arc::new(RwLock::new(state)));
|
|
Ok::<(), anyhow::Error>(())
|
|
}) {
|
|
app.dialog()
|
|
.message(e.to_string())
|
|
.kind(tauri_plugin_dialog::MessageDialogKind::Error)
|
|
.title("Initialization error")
|
|
.blocking_show();
|
|
return Err(e.into());
|
|
}
|
|
#[cfg(debug_assertions)]
|
|
{
|
|
let window = app.get_webview_window("main").unwrap();
|
|
window.open_devtools();
|
|
}
|
|
Ok(())
|
|
})
|
|
.invoke_handler(generate_handler![
|
|
cmd::central_device_state,
|
|
cmd::connected_peripheral_state,
|
|
cmd::specific_peripheral_state,
|
|
cmd::channel_a_state,
|
|
cmd::channel_b_state,
|
|
cmd::activate_central_adapter,
|
|
cmd::start_scan_devices,
|
|
cmd::stop_scan_devices,
|
|
cmd::list_patterns,
|
|
cmd::save_pattern
|
|
])
|
|
.run(tauri::generate_context!())
|
|
.expect("error while running tauri application");
|
|
}
|