feat: move packages to root and remove unused dependencies
7
tauri/.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
/target/
|
||||
|
||||
# Generated by Tauri
|
||||
# will have schema files for capabilities auto-completion
|
||||
/gen/schemas
|
22
tauri/Cargo.toml
Normal file
@ -0,0 +1,22 @@
|
||||
[package]
|
||||
name = "tauri-clego"
|
||||
version = "0.1.0"
|
||||
description = "Un logiciel de pharmacie libre et open-source."
|
||||
authors = ["p4pillon"]
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
name = "clego_lib"
|
||||
crate-type = ["lib", "cdylib", "staticlib"]
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2.0.0-beta", features = [] }
|
||||
|
||||
[dependencies]
|
||||
axum = "0.7.5"
|
||||
tauri = { version = "2.0.0-beta", features = ["devtools"] }
|
||||
tower = "0.4.13"
|
||||
|
||||
clego = { path = "../clego" }
|
||||
tokio = "1.39.1"
|
||||
|
3
tauri/build.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
tauri_build::build()
|
||||
}
|
BIN
tauri/icons/128x128.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
tauri/icons/128x128@2x.png
Normal file
After Width: | Height: | Size: 6.8 KiB |
BIN
tauri/icons/32x32.png
Normal file
After Width: | Height: | Size: 974 B |
BIN
tauri/icons/Square107x107Logo.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
tauri/icons/Square142x142Logo.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
tauri/icons/Square150x150Logo.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
tauri/icons/Square284x284Logo.png
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
tauri/icons/Square30x30Logo.png
Normal file
After Width: | Height: | Size: 903 B |
BIN
tauri/icons/Square310x310Logo.png
Normal file
After Width: | Height: | Size: 8.4 KiB |
BIN
tauri/icons/Square44x44Logo.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
tauri/icons/Square71x71Logo.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
tauri/icons/Square89x89Logo.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
tauri/icons/StoreLogo.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
tauri/icons/icon.icns
Normal file
BIN
tauri/icons/icon.ico
Normal file
After Width: | Height: | Size: 85 KiB |
BIN
tauri/icons/icon.png
Normal file
After Width: | Height: | Size: 14 KiB |
59
tauri/src/lib.rs
Normal file
@ -0,0 +1,59 @@
|
||||
use core::panic;
|
||||
use std::sync::Arc;
|
||||
|
||||
use tauri::{path::BaseDirectory, Manager};
|
||||
use tokio::sync::Mutex;
|
||||
use tower::{Service, ServiceExt};
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.setup(|app| {
|
||||
let resource_path_buf = app
|
||||
.path()
|
||||
.resolve("assets", BaseDirectory::Resource)
|
||||
.expect("Path should be resolvable");
|
||||
|
||||
let router = Arc::new(Mutex::new(
|
||||
clego::get_router(resource_path_buf.as_path()).clone(),
|
||||
));
|
||||
|
||||
app.manage(router);
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.register_asynchronous_uri_scheme_protocol("axum", move |app, request, responder| {
|
||||
let router = Arc::clone(&app.state::<Arc<Mutex<axum::Router>>>());
|
||||
|
||||
tauri::async_runtime::spawn(async move {
|
||||
let mut router = router.lock().await;
|
||||
|
||||
let (parts, body) = request.into_parts();
|
||||
let body = axum::body::Body::from(body);
|
||||
|
||||
let request = axum::extract::Request::from_parts(parts, body);
|
||||
|
||||
let response = match router.as_service().ready().await {
|
||||
Ok(ready_service) => ready_service.call(request).await,
|
||||
Err(_error) => panic!("Failed to get ready service"),
|
||||
};
|
||||
|
||||
let response = match response {
|
||||
Ok(response) => response,
|
||||
Err(_error) => panic!("Problem getting response from request."),
|
||||
};
|
||||
|
||||
let (parts, body) = response.into_parts();
|
||||
let body = match axum::body::to_bytes(body, usize::MAX).await {
|
||||
Ok(bytes) => bytes.to_vec(),
|
||||
Err(_error) => panic!("Problem converting response body to bytes."),
|
||||
};
|
||||
|
||||
let response = tauri::http::Response::from_parts(parts, body);
|
||||
|
||||
responder.respond(response);
|
||||
});
|
||||
})
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
6
tauri/src/main.rs
Normal file
@ -0,0 +1,6 @@
|
||||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
fn main() {
|
||||
clego_lib::run()
|
||||
}
|
41
tauri/tauri.conf.json
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
"productName": "clego-clean",
|
||||
"version": "0.0.1",
|
||||
"identifier": "clego.pharma.libre",
|
||||
"build": {
|
||||
"beforeDevCommand": {
|
||||
"script": "cargo run",
|
||||
"cwd": "../clego"
|
||||
},
|
||||
"devUrl": "http://localhost:3000",
|
||||
"frontendDist": "axum://place.holder/"
|
||||
},
|
||||
"app": {
|
||||
"withGlobalTauri": true,
|
||||
"windows": [
|
||||
{
|
||||
"title": "clego-clean",
|
||||
"width": 800,
|
||||
"height": 600
|
||||
}
|
||||
],
|
||||
"security": {
|
||||
"csp": null
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"resources": {
|
||||
"../clego/assets/": "./assets/"
|
||||
},
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
"icons/128x128@2x.png",
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
]
|
||||
}
|
||||
|
||||
}
|