(feat): add embeds
This commit is contained in:
parent
9f3d610bb4
commit
1e90171ee9
13 changed files with 549 additions and 9 deletions
|
|
@ -1,6 +1,47 @@
|
|||
use tauri::{AppHandle, ipc::Channel};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Clone, Serialize)]
|
||||
#[serde(rename_all = "camelCase", rename_all_fields = "camelCase", tag = "event", content = "data")]
|
||||
enum DownloadEvent<'a> {
|
||||
Started {
|
||||
url: &'a str,
|
||||
download_id: usize,
|
||||
content_length: usize,
|
||||
},
|
||||
Progress {
|
||||
download_id: usize,
|
||||
chunk_length: usize,
|
||||
},
|
||||
Finished {
|
||||
download_id: usize,
|
||||
},
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn download(app: AppHandle, url: String, on_event: Channel<DownloadEvent>) {
|
||||
let content_length = 1000;
|
||||
let download_id = 1;
|
||||
|
||||
on_event.send(DownloadEvent::Started {
|
||||
url: &url,
|
||||
download_id,
|
||||
content_length,
|
||||
}).unwrap();
|
||||
|
||||
for chunk_length in [15, 150, 35, 500, 300] {
|
||||
on_event.send(DownloadEvent::Progress {
|
||||
download_id,
|
||||
chunk_length,
|
||||
}).unwrap();
|
||||
}
|
||||
|
||||
on_event.send(DownloadEvent::Finished { download_id }).unwrap();
|
||||
}
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
let builder = tauri::Builder::default().plugin(tauri_plugin_notification::init());
|
||||
let builder = tauri::Builder::default().plugin(tauri_plugin_log::Builder::new().level(tauri_plugin_log::log::LevelFilter::Info).build()).plugin(tauri_plugin_notification::init());
|
||||
|
||||
let builder = builder
|
||||
.plugin(tauri_plugin_deep_link::init())
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
use lib::log;
|
||||
|
||||
fn main() {
|
||||
mobile_lib::run()
|
||||
mobile_lib::run();
|
||||
log("Test test 123")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue