initial recommit
4
src-tauri/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
/target/
|
||||
|
4716
src-tauri/Cargo.lock
generated
Normal file
35
src-tauri/Cargo.toml
Normal 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
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
tauri_build::build()
|
||||
}
|
13
src-tauri/capabilities/migrated.json
Normal 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"
|
||||
]
|
||||
}
|
1
src-tauri/gen/schemas/acl-manifests.json
Normal file
1
src-tauri/gen/schemas/capabilities.json
Normal 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"]}}
|
2492
src-tauri/gen/schemas/desktop-schema.json
Normal file
2492
src-tauri/gen/schemas/linux-schema.json
Normal file
BIN
src-tauri/icons/128x128.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
src-tauri/icons/128x128@2x.png
Normal file
After Width: | Height: | Size: 6.8 KiB |
BIN
src-tauri/icons/32x32.png
Normal file
After Width: | Height: | Size: 974 B |
BIN
src-tauri/icons/Square107x107Logo.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
src-tauri/icons/Square142x142Logo.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
src-tauri/icons/Square150x150Logo.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
src-tauri/icons/Square284x284Logo.png
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
src-tauri/icons/Square30x30Logo.png
Normal file
After Width: | Height: | Size: 903 B |
BIN
src-tauri/icons/Square310x310Logo.png
Normal file
After Width: | Height: | Size: 8.4 KiB |
BIN
src-tauri/icons/Square44x44Logo.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
src-tauri/icons/Square71x71Logo.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
src-tauri/icons/Square89x89Logo.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
src-tauri/icons/StoreLogo.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
src-tauri/icons/icon.icns
Normal file
BIN
src-tauri/icons/icon.ico
Normal file
After Width: | Height: | Size: 85 KiB |
BIN
src-tauri/icons/icon.png
Normal file
After Width: | Height: | Size: 14 KiB |
4
src-tauri/src/lib.rs
Normal 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
@ -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
@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|