This commit is contained in:
Lars Behrends
2026-05-23 15:14:29 +02:00
parent d61472f069
commit 15fe7670c8
34 changed files with 6098 additions and 13 deletions
+4
View File
@@ -0,0 +1,4 @@
# Generated by Cargo
# will have compiled files and executables
/target/
/gen/schemas
+5145
View File
File diff suppressed because it is too large Load Diff
+26
View File
@@ -0,0 +1,26 @@
[package]
name = "app"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
license = ""
repository = ""
edition = "2021"
rust-version = "1.77.2"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "app_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
tauri-build = { version = "2.6.2", features = [] }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
log = "0.4"
tauri = { version = "2.11.2", features = [] }
tauri-plugin-log = "2"
tauri-plugin-shell = "2"
+3
View File
@@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}
+12
View File
@@ -0,0 +1,12 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "enables the default permissions",
"windows": ["main"],
"permissions": [
"core:default",
"shell:allow-execute",
"shell:allow-spawn",
"shell:default"
]
}
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

+111
View File
@@ -0,0 +1,111 @@
use std::process::{Command, Stdio};
use std::io::Read;
use std::thread;
use std::time::Duration;
use tauri::Manager;
fn find_backend() -> Result<std::path::PathBuf, String> {
let exe = std::env::current_exe().map_err(|e| format!("current_exe: {}", e))?;
let exe_dir = exe.parent().ok_or("no parent dir")?;
let target_name = "omnyx-backend";
let triple_name = format!("{}-x86_64-pc-windows-msvc.exe", target_name);
let short_name = format!("{}.exe", target_name);
// Try paths relative to the executable
let candidates = [
// Dev: app.exe is in src-tauri/target/debug/, binary in src-tauri/binaries/
exe_dir.parent().and_then(|p| p.parent()).and_then(|p| p.parent()).map(|p| p.join("binaries").join(&triple_name)),
// Dev: via src-tauri/target/
exe_dir.parent().and_then(|p| p.parent()).map(|p| p.join("binaries").join(&triple_name)),
// Production: binary renamed by Tauri (no triple)
Some(exe_dir.join(&short_name)),
// Production: binary with triple in same dir
Some(exe_dir.join(&triple_name)),
// Production: binary in ./binaries/ relative to app.exe
Some(exe_dir.join("binaries").join(&triple_name)),
Some(exe_dir.join("binaries").join(&short_name)),
];
for path in candidates.iter().flatten() {
if path.exists() {
return Ok(path.clone());
}
}
Err(format!("Backend binary not found (searched from {:?})", exe))
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(
tauri_plugin_log::Builder::default()
.level(log::LevelFilter::Info)
.build(),
)
.setup(|app| {
let exe_dir = app.path().resource_dir().unwrap_or_else(|_| std::env::current_exe().map(|p| p.parent().unwrap().to_path_buf()).unwrap_or_default());
let exe_path_str = exe_dir.to_string_lossy().to_lowercase();
// Portable mode: nur wenn auf Laufwerk C: UND in Program Files → APPDATA
// Alles andere (D:, E:, USB, etc.) → portable (data neben der Exe)
let on_c_drive = exe_path_str.starts_with("c:");
let in_program_files = exe_path_str.contains("program files") || exe_path_str.contains("programme");
let data_dir = if on_c_drive && in_program_files {
std::env::var("APPDATA")
.map(|a| format!("{}\\Omnyx", a))
.unwrap_or_else(|_| format!("{}\\data", exe_dir.to_string_lossy()))
} else {
format!("{}\\data", exe_dir.to_string_lossy())
};
match find_backend() {
Ok(bin_path) => {
log::info!("Starting backend: {:?}", bin_path);
log::info!("Data dir: {}", data_dir);
match Command::new(&bin_path)
.env("DATA_DIR", &data_dir)
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
{
Ok(child) => {
log::info!("Backend started (PID: {})", child.id());
let mut stdout = child.stdout.unwrap();
let mut stderr = child.stderr.unwrap();
thread::spawn(move || {
let mut buf = [0u8; 4096];
while let Ok(n) = stdout.read(&mut buf) {
if n == 0 { break; }
log::info!("[backend] {}", String::from_utf8_lossy(&buf[..n]).trim_end());
}
});
thread::spawn(move || {
let mut buf = [0u8; 4096];
while let Ok(n) = stderr.read(&mut buf) {
if n == 0 { break; }
log::warn!("[backend:err] {}", String::from_utf8_lossy(&buf[..n]).trim_end());
}
});
}
Err(e) => {
log::error!("Failed to spawn {:?}: {}", bin_path, e);
}
}
}
Err(e) => {
log::error!("{}", e);
}
}
thread::sleep(Duration::from_secs(1));
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
+6
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() {
app_lib::run();
}
+43
View File
@@ -0,0 +1,43 @@
{
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
"productName": "Omnyx",
"version": "0.1.0",
"identifier": "com.omnyx.desktop",
"build": {
"frontendDist": "../dist",
"devUrl": "http://localhost:3000",
"beforeDevCommand": "npm run dev -- --mode tauri",
"beforeBuildCommand": "npm run build -- --mode tauri"
},
"app": {
"windows": [
{
"title": "Omnyx - Media Discovery",
"width": 1280,
"height": 800,
"minWidth": 900,
"minHeight": 600,
"resizable": true,
"fullscreen": false,
"center": true
}
],
"security": {
"csp": null
}
},
"bundle": {
"active": true,
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
],
"externalBin": [
"binaries/omnyx-backend"
]
}
}