support config

This commit is contained in:
Julian Freeman
2026-04-04 13:22:40 -04:00
parent 9aa6f9cd1d
commit 04e4a510e5
6 changed files with 236 additions and 10 deletions

View File

@@ -1,9 +1,36 @@
use serde::{Deserialize, Serialize};
use std::process::Command;
use std::os::windows::process::CommandExt;
use std::collections::HashMap;
use tauri::AppHandle;
use crate::emit_log;
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct RegistryValue {
pub v_type: String, // "String", "Dword", "Qword", "MultiString", "ExpandString"
pub data: serde_json::Value,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(tag = "type")]
pub enum PostInstallStep {
#[serde(rename = "registry_batch")]
RegistryBatch {
root: String, // "HKCU", "HKLM"
base_path: String,
values: HashMap<String, RegistryValue>,
},
#[serde(rename = "file_replace")]
FileReplace {
url: String,
target: String, // 支持 %AppData% 等环境变量占位符
},
#[serde(rename = "command")]
Command {
run: String,
},
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Software {
pub id: String,
@@ -13,12 +40,14 @@ pub struct Software {
pub available_version: Option<String>,
pub icon_url: Option<String>,
#[serde(default = "default_status")]
pub status: String, // "idle", "pending", "installing", "success", "error"
pub status: String, // "idle", "pending", "installing", "configuring", "success", "error"
#[serde(default = "default_progress")]
pub progress: f32,
#[serde(default = "default_false")]
pub use_manifest: bool,
pub manifest_url: Option<String>,
pub post_install: Option<Vec<PostInstallStep>>,
pub post_install_url: Option<String>,
}
fn default_status() -> String { "idle".to_string() }
@@ -283,5 +312,7 @@ fn map_package(p: WingetPackage) -> Software {
progress: 0.0,
use_manifest: false,
manifest_url: None,
post_install: None,
post_install_url: None,
}
}