Premier commit

Cette révision appartient à :
Théo Gastinel a révisé 2026-10-11 01:56:32 +02:00
révision 79ced37e37
26 fichiers modifiés
+11525

Aucun fichier ne correspond à votre recherche

+5127
Voir le fichier
Diff désactivé car ce fichier est trop long. Voir la Diff
+23
Voir le fichier
@@ -0,0 +1,23 @@
[package]
name = "vercors-validateur"
version = "0.1.0"
edition = "2021"
[lib]
name = "vercors_validateur"
path = "src/lib.rs"
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = [] }
tauri-plugin-dialog = "2"
tauri-plugin-opener = "2"
serde_json = "1"
[profile.release]
codegen-units = 1
lto = true
opt-level = "s"
strip = true
+1
Voir le fichier
@@ -0,0 +1 @@
fn main() { tauri_build::build() }
+1
Voir le fichier
@@ -0,0 +1 @@
{ "identifier": "default", "windows": ["main"], "permissions": ["core:default", "dialog:allow-open", "dialog:allow-save"] }
+1
Voir le fichier
@@ -0,0 +1 @@
{"core":{"default_permission":{"identifier":"default","description":"Default core plugins set.","permissions":["core:path:default","core:event:default","core:window:default","core:webview:default","core:app:default","core:image:default","core:resources:default","core:menu:default","core:tray:default"]},"permissions":{},"permission_sets":{},"global_scope_schema":null},"core:app":{"default_permission":{"identifier":"default","description":"Default permissions for the plugin.","permissions":["allow-version","allow-name","allow-tauri-version","allow-identifier","allow-bundle-type","allow-register-listener","allow-remove-listener","allow-supports-multiple-windows"]},"permissions":{"allow-app-hide":{"identifier":"allow-app-hide","description":"Enables the app_hide command without any pre-configured scope.","commands":{"allow":["app_hide"],"deny":[]}},"allow-app-show":{"identifier":"allow-app-show","description":"Enables the app_show command without any pre-configured scope.","commands":{"allow":["app_show"],"deny":[]}},"allow-bundle-type":{"identifier":"allow-bundle-type","description":"Enables the bundle_type command without any pre-configured scope.","commands":{"allow":["bundle_type"],"deny":[]}},"allow-default-window-icon":{"identifier":"allow-default-window-icon","description":"Enables the default_window_icon command without any pre-configured scope.","commands":{"allow":["default_window_icon"],"deny":[]}},"allow-exit":{"identifier":"allow-exit","description":"Enables the exit command without any pre-configured scope.","commands":{"allow":["exit"],"deny":[]}},"allow-fetch-data-store-identifiers":{"identifier":"allow-fetch-data-store-identifiers","description":"Enables the fetch_data_store_identifiers command without any pre-configured scope.","commands":{"allow":["fetch_data_store_identifiers"],"deny":[]}},"allow-identifier":{"identifier":"allow-identifier","description":"Enables the identifier command without any pre-configured scope.","commands":{"allow":["identifier"],"deny":[]}},"allow-name":{"identifier":"allow-name","description":"Enables the name command without any pre-configured scope.","commands":{"allow":["name"],"deny":[]}},"allow-register-listener":{"identifier":"allow-register-listener","description":"Enables the register_listener command without any pre-configured scope.","commands":{"allow":["register_listener"],"deny":[]}},"allow-remove-data-store":{"identifier":"allow-remove-data-store","description":"Enables the remove_data_store command without any pre-configured scope.","commands":{"allow":["remove_data_store"],"deny":[]}},"allow-remove-listener":{"identifier":"allow-remove-listener","description":"Enables the remove_listener command without any pre-configured scope.","commands":{"allow":["remove_listener"],"deny":[]}},"allow-set-app-theme":{"identifier":"allow-set-app-theme","description":"Enables the set_app_theme command without any pre-configured scope.","commands":{"allow":["set_app_theme"],"deny":[]}},"allow-set-dock-visibility":{"identifier":"allow-set-dock-visibility","description":"Enables the set_dock_visibility command without any pre-configured scope.","commands":{"allow":["set_dock_visibility"],"deny":[]}},"allow-supports-multiple-windows":{"identifier":"allow-supports-multiple-windows","description":"Enables the supports_multiple_windows command without any pre-configured scope.","commands":{"allow":["supports_multiple_windows"],"deny":[]}},"allow-tauri-version":{"identifier":"allow-tauri-version","description":"Enables the tauri_version command without any pre-configured scope.","commands":{"allow":["tauri_version"],"deny":[]}},"allow-version":{"identifier":"allow-version","description":"Enables the version command without any pre-configured scope.","commands":{"allow":["version"],"deny":[]}},"deny-app-hide":{"identifier":"deny-app-hide","description":"Denies the app_hide command without any pre-configured scope.","commands":{"allow":[],"deny":["app_hide"]}},"deny-app-show":{"identifier":"deny-app-show","description":"Denies the app_show command without any pre-configured scope.","commands":{"allow":[],"deny":["app_show"]}},"deny-bundle-type":{"identifier":"deny-bundle-type","description":"Denies the bundle_type command without any pre-configured scope.","commands":{"allow":[],"deny":["bundle_type"]}},"deny-default-window-icon":{"identifier":"deny-default-window-icon","description":"Denies the default_window_icon command without any pre-configured scope.","commands":{"allow":[],"deny":["default_window_icon"]}},"deny-exit":{"identifier":"deny-exit","description":"Denies the exit command without any pre-configured scope.","commands":{"allow":[],"deny":["exit"]}},"deny-fetch-data-store-identifiers":{"identifier":"deny-fetch-data-store-identifiers","description":"Denies the fetch_data_store_identifiers command without any pre-configured scope.","commands":{"allow":[],"deny":["fetch_data_store_identifiers"]}},"deny-identifier":{"identifier":"deny-identifier","description":"DenLigne tronquée
+1
Voir le fichier
@@ -0,0 +1 @@
{"default":{"identifier":"default","description":"","local":true,"windows":["main"],"permissions":["core:default","dialog:allow-open","dialog:allow-save"]}}
Diff désactivé car ce fichier est trop long. Voir la Diff
Diff désactivé car ce fichier est trop long. Voir la Diff
BIN
Voir le fichier
Fichier binaire non affiché.

Après

Largeur:  |  Hauteur:  |  Taille: 4.1 KiB

Fichier binaire non affiché.

Après

Largeur:  |  Hauteur:  |  Taille: 7.6 KiB

BIN
Voir le fichier
Fichier binaire non affiché.

Après

Largeur:  |  Hauteur:  |  Taille: 1.0 KiB

BIN
Voir le fichier
Fichier binaire non affiché.

Après

Largeur:  |  Hauteur:  |  Taille: 18 KiB

+80
Voir le fichier
@@ -0,0 +1,80 @@
use std::fs;
use std::path::{Path, PathBuf};
/// Chemin par défaut, résolu à l'exécution depuis le profil utilisateur
/// (aucun chemin en dur). Renvoie None si la variable n'existe pas.
#[tauri::command]
fn chemin_par_defaut() -> Option<String> {
let home = std::env::var_os("USERPROFILE").or_else(|| std::env::var_os("HOME"))?;
let p = PathBuf::from(home)
.join("Documents").join("_CODE").join("_VercorsInventaire").join("vercors_points.json");
Some(p.to_string_lossy().into_owned())
}
/// Lecture seule du fichier source.
#[tauri::command]
fn lire_points(chemin: String) -> Result<serde_json::Value, String> {
let txt = fs::read_to_string(&chemin).map_err(|e| format!("Lecture {chemin} : {e}"))?;
serde_json::from_str(&txt).map_err(|e| format!("JSON invalide : {e}"))
}
fn chemin_validation(source: &str) -> PathBuf {
Path::new(source).with_file_name("vercors_validation.json")
}
#[tauri::command]
fn lire_validation(source: String) -> Result<Option<serde_json::Value>, String> {
let p = chemin_validation(&source);
if !p.exists() { return Ok(None); }
let txt = fs::read_to_string(&p).map_err(|e| e.to_string())?;
serde_json::from_str(&txt).map(Some).map_err(|e| format!("{} : JSON invalide : {e}", p.display()))
}
/// Écriture atomique : .tmp puis renommage ; l'ancienne version devient .bak.
fn ecrire_atomique(cible: &Path, contenu: &str) -> Result<(), String> {
let tmp = cible.with_extension("json.tmp");
fs::write(&tmp, contenu).map_err(|e| format!("Écriture {} : {e}", tmp.display()))?;
if cible.exists() {
let bak = cible.with_extension("json.bak");
fs::copy(cible, &bak).map_err(|e| format!("Sauvegarde .bak : {e}"))?;
}
fs::rename(&tmp, cible).map_err(|e| format!("Renommage : {e}"))
}
#[tauri::command]
fn sauver_validation(source: String, donnees: serde_json::Value) -> Result<String, String> {
if Path::new(&source).file_name().map(|n| n == "vercors_validation.json").unwrap_or(false) {
return Err("chemin source incohérent".into());
}
let p = chemin_validation(&source);
let txt = serde_json::to_string_pretty(&donnees).map_err(|e| e.to_string())?;
ecrire_atomique(&p, &txt)?;
Ok(p.to_string_lossy().into_owned())
}
#[tauri::command]
fn exporter(chemin: String, donnees: serde_json::Value) -> Result<(), String> {
let txt = serde_json::to_string_pretty(&donnees).map_err(|e| e.to_string())?;
ecrire_atomique(Path::new(&chemin), &txt)
}
/// Ouvre un lien http(s) dans le navigateur par défaut.
#[tauri::command]
fn ouvrir_lien(app: tauri::AppHandle, url: String) -> Result<(), String> {
use tauri_plugin_opener::OpenerExt;
if !(url.starts_with("https://") || url.starts_with("http://")) {
return Err("seuls les liens http(s) sont ouverts".into());
}
app.opener().open_url(url, None::<&str>).map_err(|e| e.to_string())
}
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_opener::init())
.invoke_handler(tauri::generate_handler![
chemin_par_defaut, lire_points, lire_validation, sauver_validation, exporter, ouvrir_lien
])
.run(tauri::generate_context!())
.expect("erreur au démarrage de Tauri");
}
+2
Voir le fichier
@@ -0,0 +1,2 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
fn main() { vercors_validateur::run() }
+15
Voir le fichier
@@ -0,0 +1,15 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "Vercors Validateur",
"version": "0.1.0",
"identifier": "fr.gastinel.vercorsvalidateur",
"build": { "frontendDist": "../src" },
"app": {
"withGlobalTauri": true,
"windows": [{ "label": "main", "title": "Vercors Validateur", "width": 1400, "height": 900, "minWidth": 900, "minHeight": 600, "center": true }],
"security": {
"csp": "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: https://data.geopf.fr https://*.tile.opentopomap.org; connect-src 'self' ipc: http://ipc.localhost"
}
},
"bundle": { "active": true, "targets": ["nsis"], "icon": ["icons/32x32.png","icons/128x128.png","icons/128x128@2x.png","icons/icon.ico"] }
}