deno and tauri work and start

todo: fix deno that it displays page in /static
This commit is contained in:
2024-12-23 14:06:31 -04:00
parent b9fe6f8882
commit 56cc15fef5
11 changed files with 284 additions and 67 deletions

63
src-tauri/Cargo.lock generated
View File

@@ -255,26 +255,25 @@ dependencies = [
[[package]]
name = "borsh"
version = "1.3.0"
version = "1.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26d4d6dafc1a3bb54687538972158f07b2c948bc57d5890df22c0739098b3028"
checksum = "2506947f73ad44e344215ccd6403ac2ae18cd8e046e581a441bf8d199f257f03"
dependencies = [
"borsh-derive",
"cfg_aliases 0.1.1",
"cfg_aliases",
]
[[package]]
name = "borsh-derive"
version = "1.3.0"
version = "1.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf4918709cc4dd777ad2b6303ed03cb37f3ca0ccede8c1b0d28ac6db8f4710e0"
checksum = "c2593a3b8b938bd68373196c9832f516be11fa487ef4ae745eb282e6a56a7244"
dependencies = [
"once_cell",
"proc-macro-crate 2.0.0",
"proc-macro-crate 3.2.0",
"proc-macro2",
"quote",
"syn 2.0.91",
"syn_derive",
]
[[package]]
@@ -437,7 +436,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a969e13a7589e9e3e4207e153bae624ade2b5622fb4684a4923b23ec3d57719"
dependencies = [
"serde",
"toml 0.8.2",
"toml 0.8.19",
]
[[package]]
@@ -493,12 +492,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "cfg_aliases"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
[[package]]
name = "cfg_aliases"
version = "0.2.1"
@@ -956,7 +949,7 @@ dependencies = [
"cc",
"memchr",
"rustc_version",
"toml 0.8.2",
"toml 0.8.19",
"vswhom",
"winreg",
]
@@ -2478,7 +2471,7 @@ version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56"
dependencies = [
"proc-macro-crate 1.3.1",
"proc-macro-crate 3.2.0",
"proc-macro2",
"quote",
"syn 2.0.91",
@@ -3064,7 +3057,7 @@ version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8"
dependencies = [
"toml_edit 0.20.2",
"toml_edit 0.20.7",
]
[[package]]
@@ -3789,7 +3782,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18051cdd562e792cad055119e0cdb2cfc137e44e3987532e0f9659a77931bb08"
dependencies = [
"bytemuck",
"cfg_aliases 0.2.1",
"cfg_aliases",
"core-graphics",
"foreign-types 0.5.0",
"js-sys",
@@ -3917,18 +3910,6 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "syn_derive"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1329189c02ff984e9736652b1631330da25eaa6bc639089ed4915d25446cbe7b"
dependencies = [
"proc-macro-error",
"proc-macro2",
"quote",
"syn 2.0.91",
]
[[package]]
name = "sync_wrapper"
version = "1.0.2"
@@ -3958,7 +3939,7 @@ dependencies = [
"cfg-expr",
"heck 0.5.0",
"pkg-config",
"toml 0.8.2",
"toml 0.8.19",
"version-compare",
]
@@ -4092,7 +4073,7 @@ dependencies = [
"serde_json",
"tauri-utils",
"tauri-winres",
"toml 0.8.2",
"toml 0.8.19",
"walkdir",
]
@@ -4150,7 +4131,7 @@ dependencies = [
"serde",
"serde_json",
"tauri-utils",
"toml 0.8.2",
"toml 0.8.19",
"walkdir",
]
@@ -4251,7 +4232,7 @@ dependencies = [
"serde_with",
"swift-rs",
"thiserror 2.0.9",
"toml 0.8.2",
"toml 0.8.19",
"url",
"urlpattern",
"uuid",
@@ -4447,14 +4428,14 @@ dependencies = [
[[package]]
name = "toml"
version = "0.8.2"
version = "0.8.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d"
checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e"
dependencies = [
"serde",
"serde_spanned",
"toml_datetime",
"toml_edit 0.20.2",
"toml_edit 0.22.22",
]
[[package]]
@@ -4481,13 +4462,11 @@ dependencies = [
[[package]]
name = "toml_edit"
version = "0.20.2"
version = "0.20.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338"
checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81"
dependencies = [
"indexmap 2.7.0",
"serde",
"serde_spanned",
"toml_datetime",
"winnow 0.5.40",
]
@@ -4499,6 +4478,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5"
dependencies = [
"indexmap 2.7.0",
"serde",
"serde_spanned",
"toml_datetime",
"winnow 0.6.20",
]

View File

@@ -2,20 +2,43 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use mysql::*;
use mysql::prelude::*;
use tauri::generate_handler;
fn main() {
app_lib::run();
if let Err(e) = mySqlConnect() {
eprintln!("Error connecting to MySQL: {}", e);
}
tauri::Builder::default()
.invoke_handler(generate_handler![get_data, insert_data])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
fn mySqlConnect() -> Result<()> {
let url = "mysql://rust:rust@localhost:43158";
fn my_sql_connect() -> Result<PooledConn> {
let url: &str = "mysql://rust:rust@localhost:43158/Inventory";
let pool = Pool::new(url)?;
let conn = pool.get_conn()?;
Ok(conn)
}
let mut conn = pool.get_conn()?;
#[tauri::command]
fn get_data() -> Result<Vec<String>, String> {
let mut conn = my_sql_connect().map_err(|e| e.to_string())?;
let result: Vec<String> = conn
.query("SELECT name FROM users")
.map_err(|e| e.to_string())?;
Ok(result)
}
#[tauri::command]
fn insert_data(name: String) -> Result<(), String> {
println!("Inserting data: {}", name); // Debug print
let mut conn = my_sql_connect().map_err(|e| {
eprintln!("Connection error: {}", e); // Print connection error
e.to_string()
})?;
conn.exec_drop("INSERT INTO users (name) VALUES (:name)", params! {"name" => name})
.map_err(|e| {
eprintln!("Insert error: {}", e); // Print insert error
e.to_string()
})?;
println!("Data inserted successfully"); // Debug print
Ok(())
}

View File

@@ -4,9 +4,11 @@
"version": "0.1.0",
"identifier": "com.tauri.dev",
"build": {
"frontendDist": "../frontend"
"beforeDevCommand": "cd frontend && deno task dev",
"devUrl": "http://localhost:3000"
},
"app": {
"windows": [
{
"title": "Inventory",
@@ -14,6 +16,7 @@
"height": 600,
"resizable": true,
"fullscreen": false
}
],
"security": {