补充项目启动器的web接口
This commit is contained in:
@@ -9,4 +9,5 @@ pub mod version_control;
|
||||
pub mod folder_commands;
|
||||
pub mod mcp;
|
||||
pub mod git;
|
||||
pub mod project_boot;
|
||||
pub mod web_server;
|
||||
|
||||
49
src-tauri/src/web/handlers/project_boot.rs
Normal file
49
src-tauri/src/web/handlers/project_boot.rs
Normal file
@@ -0,0 +1,49 @@
|
||||
use axum::Json;
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::app_error::AppCommandError;
|
||||
use crate::commands::project_boot as pb_commands;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Param structs
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct DetectPackageManagerParams {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CreateShadcnProjectParams {
|
||||
pub project_name: String,
|
||||
pub template: String,
|
||||
pub preset_code: String,
|
||||
pub package_manager: String,
|
||||
pub target_dir: String,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Handlers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
pub async fn detect_package_manager(
|
||||
Json(params): Json<DetectPackageManagerParams>,
|
||||
) -> Json<pb_commands::PackageManagerInfo> {
|
||||
let info = pb_commands::detect_package_manager(params.name).await;
|
||||
Json(info)
|
||||
}
|
||||
|
||||
pub async fn create_shadcn_project(
|
||||
Json(params): Json<CreateShadcnProjectParams>,
|
||||
) -> Result<Json<String>, AppCommandError> {
|
||||
let result = pb_commands::create_shadcn_project(
|
||||
params.project_name,
|
||||
params.template,
|
||||
params.preset_code,
|
||||
params.package_manager,
|
||||
params.target_dir,
|
||||
)
|
||||
.await?;
|
||||
Ok(Json(result))
|
||||
}
|
||||
@@ -167,6 +167,9 @@ pub fn build_router(app: tauri::AppHandle, token: String, static_dir: std::path:
|
||||
.route("/acp_read_agent_skill", post(handlers::acp::acp_read_agent_skill))
|
||||
.route("/acp_save_agent_skill", post(handlers::acp::acp_save_agent_skill))
|
||||
.route("/acp_delete_agent_skill", post(handlers::acp::acp_delete_agent_skill))
|
||||
// ─── Project boot ───
|
||||
.route("/detect_package_manager", post(handlers::project_boot::detect_package_manager))
|
||||
.route("/create_shadcn_project", post(handlers::project_boot::create_shadcn_project))
|
||||
// ─── Web Server ───
|
||||
.route("/get_web_server_status", post(handlers::web_server::get_web_server_status))
|
||||
.route("/start_web_server", post(handlers::web_server::start_web_server))
|
||||
|
||||
Reference in New Issue
Block a user