WIP: Feature: setup de Tauri v1 avec le routing fait par Axum #19

Closed
florian_briand wants to merge 3 commits from feature-setup-tauri-v1-with-axum into main
6 changed files with 546 additions and 1147 deletions
Showing only changes of commit d07221975b - Show all commits

1608
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -8,11 +8,13 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[build-dependencies] [build-dependencies]
tauri-build = { version = "2.0.0-beta", features = [] } tauri-build = { version = "1", features = [] }
[dependencies] [dependencies]
tauri = { version = "2.0.0-beta", features = [] } tauri = { version = "1", features = ["shell-open"] }
tauri-plugin-shell = "2.0.0-beta"
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
serde_json = "1" 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"]

View File

@ -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"
]
}

View File

@ -1,6 +1,8 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!! // Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] #![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 // Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command] #[tauri::command]
fn greet(name: &str) -> String { fn greet(name: &str) -> String {
@ -9,8 +11,17 @@ fn greet(name: &str) -> String {
fn main() { fn main() {
tauri::Builder::default() tauri::Builder::default()
.plugin(tauri_plugin_shell::init())
.invoke_handler(tauri::generate_handler![greet]) .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!()) .run(tauri::generate_context!())
.expect("error while running tauri application"); .expect("error while running tauri application");
} }

View File

@ -1,12 +1,21 @@
{ {
"productName": "tauri",
"version": "0.0.0",
"identifier": "org.p4pillon.krys4lide",
"build": { "build": {
"frontendDist": "../webapp" "devPath": "../webapp",
"distDir": "../webapp",
"withGlobalTauri": true
},
"package": {
"productName": "tauri",
"version": "0.0.0"
},
"tauri": {
"allowlist": {
"all": false,
"shell": {
"all": false,
"open": true
}
}, },
"app": {
"withGlobalTauri": true,
"windows": [ "windows": [
{ {
"title": "tauri", "title": "tauri",
@ -16,11 +25,11 @@
], ],
"security": { "security": {
"csp": null "csp": null
}
}, },
"bundle": { "bundle": {
"active": true, "active": true,
"targets": "all", "targets": "all",
"identifier": "org.p4pillon.krys4lide",
"icon": [ "icon": [
"icons/32x32.png", "icons/32x32.png",
"icons/128x128.png", "icons/128x128.png",
@ -30,3 +39,4 @@
] ]
} }
} }
}

View File

@ -36,6 +36,9 @@
</form> </form>
<p id="greet-msg"></p> <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> </div>
</body> </body>
</html> </html>