Added a function for making a new project
It doesn't get called anywhere in the frontend yet but I'll make it get called once lncvrt is done with his changes to the frontend. Also for now webserver and website both just have an index.php with one header. But lncvrt will make it so it gets templates from a git repo.
This commit is contained in:
1 parent
f7c159c66e
commit
8c1ff8d1fc
2 files changed
+22
-1
No files matched your search
@@ -16,6 +16,7 @@ tauri = { version = "2.7.0", features = [] }
|
|||||||
serde = { version = "1.0.219", features = ["derive"] }
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
serde_json = "1.0.142"
|
serde_json = "1.0.142"
|
||||||
tauri-plugin-dialog = "2.3.2"
|
tauri-plugin-dialog = "2.3.2"
|
||||||
|
tokio = "1.47.1"
|
||||||
|
|
||||||
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
||||||
tauri-plugin-single-instance = "2.3.2"
|
tauri-plugin-single-instance = "2.3.2"
|
||||||
|
|||||||
+21
-1
@@ -1,4 +1,24 @@
|
|||||||
use tauri::Manager;
|
use tauri::Manager;
|
||||||
|
use tokio::fs;
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
async fn create_project(project_type: String, project_folder: String, project_name: String) {
|
||||||
|
let project_root: String = format!("{}/{}", project_folder, project_name);
|
||||||
|
let _ = fs::create_dir(&project_root);
|
||||||
|
|
||||||
|
let project_type_str: &str = project_type.as_str();
|
||||||
|
match project_type_str {
|
||||||
|
"website" => {
|
||||||
|
let _ = fs::write(format!("{}/index.php", project_root), "<h1>this will be updated later</h1>").await;
|
||||||
|
}
|
||||||
|
|
||||||
|
"webserver" => {
|
||||||
|
let _ = fs::write(format!("{}/index.php", project_root), "<h1>this will be updated later</h1>").await;
|
||||||
|
}
|
||||||
|
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||||
pub fn run() {
|
pub fn run() {
|
||||||
@@ -10,7 +30,7 @@ pub fn run() {
|
|||||||
.expect("no main window")
|
.expect("no main window")
|
||||||
.set_focus();
|
.set_focus();
|
||||||
}))
|
}))
|
||||||
.invoke_handler(tauri::generate_handler![])
|
.invoke_handler(tauri::generate_handler![create_project])
|
||||||
.setup(|app| {
|
.setup(|app| {
|
||||||
tauri::webview::WebviewWindowBuilder::new(
|
tauri::webview::WebviewWindowBuilder::new(
|
||||||
app,
|
app,
|
||||||
|
|||||||
Reference in new issue
Block a user