initial recommit

This commit is contained in:
2025-04-22 11:30:05 +02:00
parent d37de6d304
commit 9e17369f11
49 changed files with 13964 additions and 3952 deletions

4
src-tauri/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
# Generated by Cargo
# will have compiled files and executables
/target/

4716
src-tauri/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

35
src-tauri/Cargo.toml Normal file
View File

@ -0,0 +1,35 @@
[package]
name = "desktop"
version = "0.0.0"
description = "A Tauri App"
authors = ["you"]
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = [] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tauri-plugin-shell = "2"
[features]
# this feature is used for production builds or when `devPath` points to the filesystem
# DO NOT REMOVE!!
custom-protocol = ["tauri/custom-protocol"]
[profile.release]
panic = "abort" # Strip expensive panic clean-up logic
codegen-units = 1 # Compile crates one after another so the compiler can optimize better
lto = true # Enables link to optimizations
opt-level = "s" # Optimize for binary size
# can also use this one if it's smaller
# opt-level = "z" # Optimize for binary size
strip = true # Automatically strip symbols from the binary.
[lib]
name = "app_lib"
crate-type = ["staticlib", "cdylib", "rlib"]

3
src-tauri/build.rs Normal file
View File

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

View File

@ -0,0 +1,13 @@
{
"identifier": "migrated",
"description": "permissions that were migrated from v1",
"local": true,
"windows": [
"main"
],
"permissions": [
"core:default",
"shell:allow-open",
"shell:default"
]
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
{"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["core:default","shell:allow-open","shell:default"]}}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

BIN
src-tauri/icons/128x128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

BIN
src-tauri/icons/32x32.png Normal file

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

BIN
src-tauri/icons/icon.icns Normal file

Binary file not shown.

BIN
src-tauri/icons/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

BIN
src-tauri/icons/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

4
src-tauri/src/lib.rs Normal file
View File

@ -0,0 +1,4 @@
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
// your code here
}

82
src-tauri/src/main.rs Normal file
View File

@ -0,0 +1,82 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use std::fs;
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello, {}! You've been greeted from Rust!", name)
}
#[derive(serde::Serialize)]
struct File {
filename: String,
}
#[derive(serde::Serialize)]
struct FileList {
path: String,
list: Vec<File>,
}
#[tauri::command]
fn list_files(path: &str) -> Result<FileList, String> {
let run = || -> Result<Vec<File>, ()> {
let paths = fs::read_dir(path).unwrap();
let mut final_string: String = String::new();
let mut arr = Vec::new();
for (idx, path) in paths.enumerate() {
if idx > 0 {
final_string.push(',');
}
arr.push(File {
filename: path.unwrap().path().display().to_string(),
});
// final_string.push_str(path.unwrap().path().display().to_string().as_str())
}
Ok(arr)
};
let list = run();
if list.is_err() {
Err("Error".to_owned())
} else {
Ok(FileList {
path: fs::canonicalize(path)
.unwrap()
.display()
.to_string()
.to_owned(),
list: list.unwrap(),
})
}
}
#[tauri::command]
fn get_file(path: &str) -> Result<String, String> {
let run = || -> Result<String, String> {
let content = fs::read(path);
if content.is_err() {
return Err("Error".to_owned());
}
Ok(String::from_utf8(content.unwrap())
.unwrap_or("error decoding file content :(".to_owned()))
};
let res = run();
if res.is_err() {
Err("Error".to_owned())
} else {
Ok(res.unwrap())
}
}
fn main() {
app_lib::run();
tauri::Builder::default()
.plugin(tauri_plugin_shell::init())
.invoke_handler(tauri::generate_handler![greet, list_files, get_file])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

38
src-tauri/tauri.conf.json Normal file
View File

@ -0,0 +1,38 @@
{
"$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/dev/tooling/cli/schema.json",
"build": {
"beforeDevCommand": "bun run front:dev",
"beforeBuildCommand": "bun run front:build",
"frontendDist": "../dist",
"devUrl": "http://localhost:3000"
},
"bundle": {
"active": true,
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
]
},
"productName": "astro-editor",
"mainBinaryName": "astro-editor",
"version": "0.0.0",
"identifier": "com.dzeio.desktop",
"plugins": {},
"app": {
"security": {
"csp": null
},
"windows": [
{
"title": "astro-editor",
"width": 800,
"height": 600,
"useHttpsScheme": true
}
]
}
}