mirror of
https://github.com/patarapolw/cjdic2.git
synced 2026-11-09 17:39:35 +00:00
framework agnostic core cargo
This commit is contained in:
1 parent
afc8bc60e0
commit
876b879a65
16 files changed
+5569
-31
No files matched your search
+22
@@ -22,3 +22,25 @@ dist-ssr
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
debug
|
||||
target
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||
*.pdb
|
||||
|
||||
# Generated by cargo mutants
|
||||
# Contains mutation testing data
|
||||
**/mutants.out*/
|
||||
|
||||
# RustRover
|
||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
Generated
+5401
File diff suppressed because it is too large.
Load diff
+11
@@ -0,0 +1,11 @@
|
||||
[workspace]
|
||||
members = [
|
||||
"src-core",
|
||||
"src-tauri"
|
||||
]
|
||||
resolver = "3"
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
codegen-units = 1
|
||||
strip = true
|
||||
@@ -3,6 +3,9 @@
|
||||
{
|
||||
"path": ".",
|
||||
},
|
||||
{
|
||||
"path": "src-core",
|
||||
},
|
||||
{
|
||||
"path": "src-react",
|
||||
},
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
debug
|
||||
target
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||
*.pdb
|
||||
|
||||
# Generated by cargo mutants
|
||||
# Contains mutation testing data
|
||||
**/mutants.out*/
|
||||
|
||||
# RustRover
|
||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"editor.tabSize": 2,
|
||||
"[vue]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[typescript]": {
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[javascript]": {
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[jsonc]": {
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[rust]": {
|
||||
"editor.tabSize": 4,
|
||||
"editor.formatOnSave": true
|
||||
}
|
||||
}
|
||||
Generated
+7
@@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "src-core"
|
||||
version = "0.1.0"
|
||||
@@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "cjdic2-core"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
rusqlite = { version = "0.38.0", features = ["bundled", "unlock_notify"] }
|
||||
@@ -0,0 +1,16 @@
|
||||
pub mod models;
|
||||
|
||||
pub fn add(left: u64, right: u64) -> u64 {
|
||||
left + right
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Entry {
|
||||
pub id: i64,
|
||||
pub word: String,
|
||||
pub definition: String,
|
||||
}
|
||||
@@ -13,7 +13,7 @@ dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
# .vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"editor.tabSize": 2,
|
||||
"[vue]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[typescript]": {
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[javascript]": {
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[jsonc]": {
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[typescriptreact]": {
|
||||
"editor.formatOnSave": true
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "src-react",
|
||||
"name": "cjdic2-react",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"editor.tabSize": 2,
|
||||
"[vue]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[typescript]": {
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[javascript]": {
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[jsonc]": {
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[rust]": {
|
||||
"editor.tabSize": 4,
|
||||
"editor.formatOnSave": true
|
||||
}
|
||||
}
|
||||
@@ -23,8 +23,4 @@ tauri-plugin-opener = "2"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
rusqlite = { version = "0.38.0", features = ["bundled", "unlock_notify"] }
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
codegen-units = 1
|
||||
strip = true
|
||||
cjdic2-core = { path = "../src-core" }
|
||||
+5
-24
@@ -24,7 +24,8 @@ pub fn run() {
|
||||
|
||||
let db_path = app_dir.join("cjdic.db");
|
||||
let is_new = !db_path.exists();
|
||||
println!("{:?}", db_path);
|
||||
|
||||
println!("{}", cjdic2_core::add(1, 2));
|
||||
|
||||
let conn = Connection::open(&db_path)?;
|
||||
|
||||
@@ -44,29 +45,9 @@ pub fn run() {
|
||||
.build(tauri::generate_context!())
|
||||
.expect("error while running tauri application")
|
||||
.run(|_app_handle, event| match event {
|
||||
tauri::RunEvent::ExitRequested { .. } => {
|
||||
// api.prevent_exit();
|
||||
// let handle = app_handle.clone();
|
||||
|
||||
// if let Some(state) = app_handle.try_state::<state::AppState>() {
|
||||
// if let Ok(conn) = state.conn.lock() {
|
||||
// if let Err(e) = (|| -> Result<(), rusqlite::Error> {
|
||||
// conn.execute_batch("PRAGMA optimize;")?;
|
||||
// conn.execute("PRAGMA wal_checkpoint(FULL);", [])?;
|
||||
|
||||
// let (_busy, _log, _checkpointed): (i32, i32, i32) =
|
||||
// conn.query_row("PRAGMA wal_checkpoint(FULL);", [], |row| {
|
||||
// Ok((row.get(0)?, row.get(1)?, row.get(2)?))
|
||||
// })?;
|
||||
// Ok(())
|
||||
// })() {
|
||||
// eprintln!("Shutdown SQL failed: {e}");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// handle.exit(0);
|
||||
}
|
||||
// On exit handler should be avoided for mobile
|
||||
// and rusqlite already closes gracefully by default
|
||||
tauri::RunEvent::ExitRequested { .. } => {}
|
||||
_ => {}
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user