propagated use of config home path to other systems. file loading now works using rust instead of js
This commit is contained in:
parent
62918416ee
commit
11bd003298
11 changed files with 1007 additions and 1000 deletions
1460
src-tauri/Cargo.lock
generated
1460
src-tauri/Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -21,6 +21,7 @@ tauri-build = { version = "2", features = [] }
|
|||
|
||||
[dependencies]
|
||||
tauri = { version = "2", features = ["protocol-asset", "unstable"] }
|
||||
|
||||
tauri-plugin-shell = "2"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
|
|
|
|||
|
|
@ -6,13 +6,17 @@ use std::{
|
|||
|
||||
use sqlx::{migrate::MigrateDatabase, Sqlite, SqlitePool};
|
||||
use tauri::{ipc::RuntimeCapability, App, AssetResolver, Manager, Url};
|
||||
use crate::get_basepath;
|
||||
async fn populate_file_db(db: &SqlitePool) {}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn initialize_database(
|
||||
app_handle: tauri::AppHandle,
|
||||
basepath: String,
|
||||
pathtemplate: String,
|
||||
) {
|
||||
|
||||
if let Some(basepath) = get_basepath(app_handle.clone()) {
|
||||
let db_path = Path::new("Documents")
|
||||
.join(Path::new("Knowledgebase"))
|
||||
.join("db.sqlite");
|
||||
|
|
@ -61,7 +65,10 @@ pub async fn initialize_database(
|
|||
.execute(&db)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn store_diff(diff: String) {}
|
||||
async fn store_diff(diff: String) {
|
||||
|
||||
}
|
||||
|
|
|
|||
19
src-tauri/src/file_handler.rs
Normal file
19
src-tauri/src/file_handler.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
use tauri::{ipc::RuntimeCapability, App, AssetResolver, Manager, Url};
|
||||
use std::fs::{read_to_string};
|
||||
use std::path::Path;
|
||||
use crate::get_basepath;
|
||||
#[tauri::command]
|
||||
pub async fn save(
|
||||
app_handle: tauri::AppHandle,
|
||||
|
||||
path: String, content: String) {}
|
||||
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn load(
|
||||
path: String) -> Result<String, String> {
|
||||
println!("loading file");
|
||||
|
||||
read_to_string(path).map_err(|e| e.to_string())
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
use crate::get_basepath;
|
||||
use html_tag::HtmlTag;
|
||||
use shellexpand;
|
||||
use std::{
|
||||
|
|
@ -5,11 +6,11 @@ use std::{
|
|||
path::Path,
|
||||
};
|
||||
#[tauri::command]
|
||||
pub fn dir_tree_html(basepath: &str, filter: Vec<String>) -> String {
|
||||
match shellexpand::full(basepath) {
|
||||
Ok(path) => add_dir_tree_node(&Path::new(&path.into_owned()), &filter).to_html(),
|
||||
|
||||
Err(_) => String::new(),
|
||||
pub fn dir_tree_html(app_handle: tauri::AppHandle, filter: Vec<String>) -> String {
|
||||
if let Some(basepath) = get_basepath(app_handle) {
|
||||
add_dir_tree_node(&Path::new(&basepath), &filter).to_html()
|
||||
} else {
|
||||
String::new()
|
||||
}
|
||||
}
|
||||
fn add_dir_tree_node(path: &Path, filter: &Vec<String>) -> HtmlTag {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
mod config;
|
||||
mod database;
|
||||
mod file_access;
|
||||
mod file_handler;
|
||||
mod file_tree;
|
||||
mod markdown_parser;
|
||||
mod search;
|
||||
|
|
@ -14,7 +15,7 @@ use std::env;
|
|||
use std::sync::Mutex;
|
||||
use tauri::Manager;
|
||||
use tauri_plugin_fs::FsExt;
|
||||
|
||||
use file_handler::load;
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
|
|
@ -40,6 +41,7 @@ pub fn run() {
|
|||
search_files,
|
||||
get_basepath,
|
||||
set_basepath,
|
||||
load
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
#[tauri::command]
|
||||
pub async fn save(path: String, content: String) {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue