feat(hololake): project registered modules into marketplace
This commit is contained in:
parent
97b378b60c
commit
03e4338ab8
7 changed files with 120 additions and 7 deletions
|
|
@ -14,6 +14,14 @@ use tauri_plugin_dialog::DialogExt;
|
|||
const UPDATE_ENDPOINT: &str = "https://guanghulab.com/hololake/releases/latest.json";
|
||||
const PUBLIC_STATE: &str = "SIGNED_UPDATE_FEED_READY_NO_RELEASE";
|
||||
|
||||
fn bundled_modules() -> Result<Vec<ModuleRecord>, String> {
|
||||
let registry: serde_json::Value =
|
||||
serde_json::from_str(include_str!("../../registries/module-registry.json"))
|
||||
.map_err(|error| format!("MODULE_REGISTRY_INVALID: {error}"))?;
|
||||
serde_json::from_value(registry["modules"].clone())
|
||||
.map_err(|error| format!("MODULE_REGISTRY_INVALID: {error}"))
|
||||
}
|
||||
|
||||
fn receipt(
|
||||
app: &AppHandle,
|
||||
state: &str,
|
||||
|
|
@ -42,6 +50,7 @@ fn system_snapshot(app: AppHandle) -> Result<SystemSnapshot, String> {
|
|||
public_update_endpoint: UPDATE_ENDPOINT.into(),
|
||||
public_distribution_state: PUBLIC_STATE.into(),
|
||||
external_ai_bridges: storage::bridges(&app)?,
|
||||
modules: bundled_modules()?,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,6 +74,18 @@ pub struct SystemSnapshot {
|
|||
pub public_update_endpoint: String,
|
||||
pub public_distribution_state: String,
|
||||
pub external_ai_bridges: Vec<ExternalAiBridge>,
|
||||
pub modules: Vec<ModuleRecord>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ModuleRecord {
|
||||
pub module_id: String,
|
||||
pub name_zh: String,
|
||||
pub kind: String,
|
||||
pub audience: String,
|
||||
pub summary_zh: String,
|
||||
pub state: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
|
|
|
|||
Loading…
Reference in a new issue