change some defaults

This commit is contained in:
2025-04-22 13:43:33 +02:00
parent de3a4fb281
commit ac0977b84b
28 changed files with 1465 additions and 8922 deletions

22
src-tauri/Cargo.lock generated
View File

@ -540,17 +540,6 @@ dependencies = [
"syn 2.0.100",
]
[[package]]
name = "desktop"
version = "0.0.0"
dependencies = [
"serde",
"serde_json",
"tauri",
"tauri-build",
"tauri-plugin-shell",
]
[[package]]
name = "digest"
version = "0.10.7"
@ -1172,6 +1161,17 @@ dependencies = [
"syn 2.0.100",
]
[[package]]
name = "gwaleen-desktop"
version = "0.0.0"
dependencies = [
"serde",
"serde_json",
"tauri",
"tauri-build",
"tauri-plugin-shell",
]
[[package]]
name = "hashbrown"
version = "0.12.3"

View File

@ -1,5 +1,5 @@
[package]
name = "desktop"
name = "gwaleen-desktop"
version = "0.0.0"
description = "A Tauri App"
authors = ["you"]
@ -7,20 +7,22 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
# The `_lib` suffix may seem redundant but it is necessary
# to make the lib name unique and wouldn't conflict with the bin name.
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
name = "gwaleen_desktop_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = [] }
tauri = { version = "2", features = ["macos-private-api"] }
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
@ -29,7 +31,3 @@ 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"]

View File

@ -0,0 +1,12 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "Capability for the main window",
"local": true,
"windows": [
"main"
],
"permissions": [
"core:default"
]
}

View File

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

View File

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

View File

@ -1,4 +1,14 @@
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello, {}! You've been greeted from Rust!", name)
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
// your code here
tauri::Builder::default()
// .plugin(tauri_plugin_opener::init())
.invoke_handler(tauri::generate_handler![greet])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

View File

@ -1,82 +1,6 @@
// 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");
gwaleen_desktop_lib::run()
}

View File

@ -1,10 +1,39 @@
{
"$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/dev/tooling/cli/schema.json",
"$schema": "https://schema.tauri.app/config/2",
"productName": "gwaleen-desktop",
"version": "0.0.0",
"identifier": "com.gwaleen.desktop",
"build": {
"beforeDevCommand": "bun run front:dev",
"devUrl": "http://localhost:3000",
"beforeBuildCommand": "bun run front:build",
"frontendDist": "../dist",
"devUrl": "http://localhost:3000"
"frontendDist": "../dist"
},
"app": {
"security": {
"csp": null
},
"enableGTKAppId": true,
"macOSPrivateApi": true,
"windows": [
{
"title": "gwaleen-desktop",
"width": 100,
"height": 100,
"resizable": true,
"fullscreen": false,
"decorations": false,
"transparent": true,
"visible": true,
"alwaysOnTop": true,
"skipTaskbar": false,
"center": true,
"minimizable": true,
"maximizable": true,
"closable": true,
"titleBarStyle": "Visible"
}
]
},
"bundle": {
"active": true,
@ -16,23 +45,5 @@
"icons/icon.icns",
"icons/icon.ico"
]
},
"productName": "gwaleen-desktop",
"mainBinaryName": "gwaleen-desktop",
"version": "0.0.0",
"identifier": "com.gwaleen.desktop",
"plugins": {},
"app": {
"security": {
"csp": null
},
"windows": [
{
"title": "gwaleen-desktop",
"width": 800,
"height": 600,
"useHttpsScheme": true
}
]
}
}