fix: change project naming, create dummy sesame-vitale project

This commit is contained in:
theo
2024-07-24 21:59:24 +02:00
parent ff2c84fb33
commit 7d41fbb519
37 changed files with 56 additions and 31 deletions

7
crates/desktop/.gitignore vendored Normal file
View 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
crates/desktop/Cargo.toml Normal file
View File

@ -0,0 +1,22 @@
[package]
name = "desktop"
version = "0.1.0"
description = "Un logiciel de pharmacie libre et open-source."
authors = ["p4pillon"]
edition = "2021"
[lib]
name = "pharmacie_desktop_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 = [] }
tower = "0.4.13"
tokio = "1.39.1"
app = { path = "../app" }

3
crates/desktop/build.rs Normal file
View File

@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 974 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 903 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

70
crates/desktop/src/lib.rs Normal file
View File

@ -0,0 +1,70 @@
use core::panic;
use std::sync::Arc;
use tauri::{path::BaseDirectory, Manager};
use tokio::sync::{Mutex, MutexGuard};
use tower::{Service, ServiceExt};
async fn process_tauri_request(
request: tauri::http::Request<Vec<u8>>,
mut router: MutexGuard<'_, axum::Router>,
) -> tauri::http::Response<Vec<u8>> {
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);
response
}
#[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(
app::get_router(resource_path_buf.as_path()).clone(),
));
// Adds the router to the application state
// This makes it so we can retrieve it from any app instance (see bellow)
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 router = router.lock().await;
let response = process_tauri_request(request, router).await;
responder.respond(response);
});
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

View 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() {
pharmacie_desktop_lib::run()
}

View File

@ -0,0 +1,41 @@
{
"productName": "Logiciel Pharma",
"version": "0.0.1",
"identifier": "p4pillon.pharma.desktop",
"build": {
"beforeDevCommand": {
"script": "cargo run",
"cwd": "../clego"
},
"devUrl": "http://localhost:3000",
"frontendDist": "axum://place.holder/"
},
"app": {
"withGlobalTauri": true,
"windows": [
{
"title": "Logiciel Pharma",
"width": 800,
"height": 600
}
],
"security": {
"csp": null
}
},
"bundle": {
"active": true,
"resources": {
"../app/assets/": "./assets/"
},
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
]
}
}