feature: make register_uri_scheme_protocol works on tauri v1
This commit is contained in:
parent
db285c8aea
commit
d07221975b
1608
Cargo.lock
generated
1608
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -8,11 +8,13 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2.0.0-beta", features = [] }
|
||||
tauri-build = { version = "1", features = [] }
|
||||
|
||||
[dependencies]
|
||||
tauri = { version = "2.0.0-beta", features = [] }
|
||||
tauri-plugin-shell = "2.0.0-beta"
|
||||
tauri = { version = "1", features = ["shell-open"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
|
||||
[features]
|
||||
# This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!!
|
||||
custom-protocol = ["tauri/custom-protocol"]
|
||||
|
@ -1,17 +0,0 @@
|
||||
{
|
||||
"$schema": "../gen/schemas/desktop-schema.json",
|
||||
"identifier": "default",
|
||||
"description": "Capability for the main window",
|
||||
"windows": ["main"],
|
||||
"permissions": [
|
||||
"path:default",
|
||||
"event:default",
|
||||
"window:default",
|
||||
"app:default",
|
||||
"image:default",
|
||||
"resources:default",
|
||||
"menu:default",
|
||||
"tray:default",
|
||||
"shell:allow-open"
|
||||
]
|
||||
}
|
@ -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");
|
||||
}
|
||||
|
@ -1,12 +1,21 @@
|
||||
{
|
||||
"productName": "tauri",
|
||||
"version": "0.0.0",
|
||||
"identifier": "org.p4pillon.krys4lide",
|
||||
"build": {
|
||||
"frontendDist": "../webapp"
|
||||
"devPath": "../webapp",
|
||||
"distDir": "../webapp",
|
||||
"withGlobalTauri": true
|
||||
},
|
||||
"app": {
|
||||
"withGlobalTauri": true,
|
||||
"package": {
|
||||
"productName": "tauri",
|
||||
"version": "0.0.0"
|
||||
},
|
||||
"tauri": {
|
||||
"allowlist": {
|
||||
"all": false,
|
||||
"shell": {
|
||||
"all": false,
|
||||
"open": true
|
||||
}
|
||||
},
|
||||
"windows": [
|
||||
{
|
||||
"title": "tauri",
|
||||
@ -16,17 +25,18 @@
|
||||
],
|
||||
"security": {
|
||||
"csp": null
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"identifier": "org.p4pillon.krys4lide",
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
"icons/128x128@2x.png",
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
]
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
"icons/128x128@2x.png",
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,9 @@
|
||||
</form>
|
||||
|
||||
<p id="greet-msg"></p>
|
||||
|
||||
<a href="clego://test/scheme/handler">Test `clego://` uri scheme handler</a>
|
||||
<a href="https://clego.localhost/test/scheme/handler">Test `https://clego.localhost` uri scheme handler</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user