Migrate updater LAN and devkit features from old repo

This commit is contained in:
lenn
2026-04-27 16:37:40 +08:00
parent b33c952eb6
commit 26533f6916
29 changed files with 5207 additions and 55 deletions

View 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
}