This commit is contained in:
cast1e
2024-10-14 22:08:46 +08:00
parent ba2cd4d5a3
commit 21d4c33460
20 changed files with 209 additions and 103 deletions
+4 -6
View File
@@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
use serde_json::{self, json};
use std::ffi::CString;
use std::path::Path;
use std::{fs, path};
use std::{fs};
use tauri::ipc::Response;
#[cfg_attr(mobile, tauri::mobile_entry_point)]
@@ -44,11 +44,9 @@ async fn read_resource_dir() -> String {
#[tauri::command]
async fn get_file(path: String) -> Response {
let p = Path::new(&path);
if p.starts_with(".\\") {
if let Ok(true) = fs::exists(p) {
let data: Vec<u8> = fs::read(p).unwrap();
return tauri::ipc::Response::new(data);
}
if let Ok(true) = fs::exists(p) {
let data: Vec<u8> = fs::read(p).unwrap();
return tauri::ipc::Response::new(data);
}
tauri::ipc::Response::new(String::from(""))
}