added tauri specta
This commit is contained in:
@@ -3,7 +3,7 @@ name = "wyd"
|
||||
version = "0.1.0"
|
||||
description = "A Tauri App"
|
||||
authors = ["you"]
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
@@ -28,6 +28,9 @@ ed25519-dalek = "3.0.0"
|
||||
getrandom = "0.4.3"
|
||||
device_query = "4.0.1"
|
||||
tokio = "1.53.1"
|
||||
tauri-specta = { version = "2.0.0-rc.21", features = ["derive", "typescript"] }
|
||||
specta = "2.0.0-rc.21"
|
||||
specta-typescript = { version = "0.0.9" }
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
windows = "0.58"
|
||||
|
||||
+14
-1
@@ -9,9 +9,22 @@ fn launch_app(app: &tauri::App) {
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
let specta_builder = tauri_specta::Builder::<tauri::Wry>::new()
|
||||
.error_handling(tauri_specta::ErrorHandlingMode::Throw)
|
||||
.commands(tauri_specta::collect_commands![])
|
||||
.events(tauri_specta::collect_events![]);
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
specta_builder
|
||||
.export(
|
||||
specta_typescript::Typescript::default(),
|
||||
"../src/lib/bindings.ts",
|
||||
)
|
||||
.expect("Failed to export TypeScript bindings");
|
||||
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
.invoke_handler(tauri::generate_handler![])
|
||||
.invoke_handler(specta_builder.invoke_handler())
|
||||
.setup(|app| {
|
||||
launch_app(app);
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user