feature: make register_uri_scheme_protocol works on tauri v1
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
use tauri::http::ResponseBuilder;
|
||||
|
||||
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
|
||||
#[tauri::command]
|
||||
fn greet(name: &str) -> String {
|
||||
@ -9,8 +11,17 @@ fn greet(name: &str) -> String {
|
||||
|
||||
fn main() {
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_shell::init())
|
||||
.invoke_handler(tauri::generate_handler![greet])
|
||||
.register_uri_scheme_protocol("clego", |_app, request| {
|
||||
let path = request.uri();
|
||||
let body = format!("<html><body>Hello from Rust! Path: {}</body></html>", path);
|
||||
|
||||
println!("body: {}", body);
|
||||
|
||||
let body_bytes: Vec<u8> = body.into_bytes();
|
||||
ResponseBuilder::new()
|
||||
.body(body_bytes)
|
||||
})
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
|
Reference in New Issue
Block a user