ensure that tauri api works
This commit is contained in:
1 parent
ffb6474c08
commit
fc58e68ad7
6 files changed
+565
-9
No files matched your search
@@ -1,7 +1,32 @@
|
||||
use tauri::Listener;
|
||||
use serde::Deserialize;
|
||||
|
||||
#[tauri::command]
|
||||
fn download_q(q: String) {
|
||||
println!("Download q! {q}");
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn timed_q(q: String, t: f32, current_time: f32, data: String) {
|
||||
println!("Timed q! {q} {t} {current_time} {}", &data[..10]);
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
struct SeekQEvent {
|
||||
t: f32,
|
||||
}
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.invoke_handler(tauri::generate_handler![download_q, timed_q])
|
||||
.setup(|app| {
|
||||
app.listen("seek_q", |event| {
|
||||
if let Ok(payload) = serde_json::from_str::<SeekQEvent>(&event.payload()) {
|
||||
println!("downloading {}", payload.t);
|
||||
}
|
||||
});
|
||||
|
||||
if cfg!(debug_assertions) {
|
||||
app.handle().plugin(
|
||||
tauri_plugin_log::Builder::default()
|
||||
|
||||
Reference in new issue
Block a user