1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
use crate::lxapp::tabbar::TabBar;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::BTreeMap;
/// LxApp basic information
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LxAppInfo {
/// LxApp name
pub app_name: String,
/// LxApp version
pub version: String,
/// LxApp release type (release|preview|developer)
pub release_type: String,
}
/// Plugin definition embedded in `lxapp.json`.
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub(crate) struct LxPlugin {
/// Plugin unique identifier - must match the plugin's lxPluginId.
#[serde(default, rename = "lxPluginId")]
pub lx_plugin_id: String,
/// Plugin version.
#[serde(default)]
pub version: String,
/// Plugin logic entry JS filename inside the plugin package directory.
///
/// If empty, defaults to `logic.js`.
#[serde(default)]
pub main: String,
/// Page alias mapping: { "alias": "internal/path" }
/// e.g., { "home": "pages/home/index" }
#[serde(default)]
pub pages: BTreeMap<String, String>,
}
/// App config from lxapp.json
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[allow(non_snake_case)]
pub(crate) struct LxAppConfig {
/// LingXia App ID
#[serde(default)]
pub appId: String,
/// LingXia App name
#[serde(default)]
pub appName: String,
/// LingXia App version
#[serde(default)]
pub version: String,
/// List of page paths (relative to app root)
pub(crate) pages: Vec<String>,
/// Tab bar configuration
pub(crate) tabBar: Option<TabBar>,
/// Plugin definitions.
#[serde(default)]
pub(crate) plugins: BTreeMap<String, LxPlugin>,
}
impl LxAppConfig {
/// Create AppConfig from serde_json::Value
pub fn from_value(value: Value) -> Result<Self, serde_json::Error> {
serde_json::from_value(value)
}
/// Get the initial route (first page in the pages array)
pub fn get_initial_route(&self) -> String {
self.pages
.first()
.cloned()
.unwrap_or("PagesEmpty".to_string())
}
/// Get LxApp basic information for FFI
pub fn get_lxapp_info(&self, release_type: &str) -> LxAppInfo {
LxAppInfo {
app_name: self.appName.clone(),
version: self.version.clone(),
release_type: release_type.to_string(),
}
}
}