Migrate updater LAN and devkit features from old repo
This commit is contained in:
47
src-tauri/src/commands/devkit.rs
Normal file
47
src-tauri/src/commands/devkit.rs
Normal file
@@ -0,0 +1,47 @@
|
||||
//! DevKit Tauri 命令
|
||||
//!
|
||||
//! 仅在 `devkit` feature 启用时编译。
|
||||
|
||||
use tauri::State;
|
||||
|
||||
use crate::devkit::{DevKitConfig, DevKitState, DevKitStatusSnapshot, ExportProcessResult};
|
||||
|
||||
#[tauri::command]
|
||||
pub fn devkit_status(state: State<'_, DevKitState>) -> DevKitStatusSnapshot {
|
||||
state.status()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn devkit_start(state: State<'_, DevKitState>, port: Option<u16>) -> Result<DevKitStatusSnapshot, String> {
|
||||
let target_port = port.unwrap_or(50051);
|
||||
state.start(target_port).await?;
|
||||
Ok(state.status())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn devkit_stop(state: State<'_, DevKitState>) -> Result<DevKitStatusSnapshot, String> {
|
||||
state.stop().await?;
|
||||
Ok(state.status())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn devkit_get_config(state: State<'_, DevKitState>) -> DevKitConfig {
|
||||
state.get_config()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn devkit_set_config(state: State<'_, DevKitState>, config: DevKitConfig) -> Result<DevKitConfig, String> {
|
||||
state.set_config(config)?;
|
||||
Ok(state.get_config())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn devkit_process_export(
|
||||
state: State<'_, DevKitState>,
|
||||
csv_path: String,
|
||||
save_as_xlsx: Option<bool>,
|
||||
) -> Result<ExportProcessResult, String> {
|
||||
let config = state.get_config();
|
||||
let use_xlsx = save_as_xlsx.unwrap_or(config.save_as_xlsx);
|
||||
state.process_export(&csv_path, use_xlsx).await
|
||||
}
|
||||
Reference in New Issue
Block a user