cloudreve_api/api/v4/models/
site.rs1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum SiteConfigSection {
8 Basic,
9 Login,
10 Explorer,
11 Emojis,
12 Vas,
13 App,
14 Thumb,
15}
16
17impl SiteConfigSection {
18 pub const fn as_str(self) -> &'static str {
19 match self {
20 Self::Basic => "basic",
21 Self::Login => "login",
22 Self::Explorer => "explorer",
23 Self::Emojis => "emojis",
24 Self::Vas => "vas",
25 Self::App => "app",
26 Self::Thumb => "thumb",
27 }
28 }
29}
30
31impl std::fmt::Display for SiteConfigSection {
32 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
33 f.write_str(self.as_str())
34 }
35}
36
37#[derive(Debug, Clone, Deserialize, Default)]
42#[serde(default)]
43pub struct SiteConfig {
44 pub instance_id: Option<String>,
45 pub title: Option<String>,
46 pub login_captcha: Option<bool>,
47 pub reg_captcha: Option<bool>,
48 pub forget_captcha: Option<bool>,
49 pub abuse_report_captcha: Option<bool>,
50 pub themes: Option<String>,
51 pub default_theme: Option<String>,
52 pub authn: Option<bool>,
53 pub user: Option<super::auth::NewUser>,
54 pub captcha_re_captcha_key: Option<String>,
55 pub captcha_cap_instance_url: Option<String>,
56 pub captcha_cap_site_key: Option<String>,
57 pub site_notice: Option<String>,
58 pub captcha_type: Option<String>,
59 pub turnstile_site_id: Option<String>,
60 pub register_enabled: Option<bool>,
61 pub qq_enabled: Option<bool>,
62 pub sso_enabled: Option<bool>,
63 pub sso_display_name: Option<String>,
64 pub sso_icon: Option<String>,
65 pub oidc_enabled: Option<bool>,
66 pub oidc_display_name: Option<String>,
67 pub oidc_icon: Option<String>,
68 pub logo: Option<String>,
69 pub logo_light: Option<String>,
70 pub tos_url: Option<String>,
71 pub privacy_policy_url: Option<String>,
72 pub icons: Option<String>,
73 pub emoji_preset: Option<String>,
74 pub point_enabled: Option<bool>,
75 pub share_point_gain_rate: Option<f64>,
76 pub map_provider: Option<String>,
77 pub google_map_tile_type: Option<String>,
78 pub file_viewers: Option<Vec<FileViewer>>,
79 pub max_batch_size: Option<f64>,
80 pub app_promotion: Option<bool>,
81 pub app_feedback: Option<String>,
82 pub app_forum: Option<String>,
83 pub payment: Option<PaymentSetting>,
84 pub anonymous_purchase: Option<bool>,
85 pub point_price: Option<f64>,
86 pub shop_nav_enabled: Option<bool>,
87 pub storage_products: Option<Vec<StorageProduct>>,
88 pub group_skus: Option<Vec<GroupSKU>>,
89 pub thumbnail_width: Option<f64>,
90 pub thumbnail_height: Option<f64>,
91 pub custom_props: Option<Vec<CustomProps>>,
92 pub custom_nav_items: Option<Vec<CustomNavItem>>,
93 pub custom_html: Option<CustomHTML>,
94 pub mapbox_ak: Option<String>,
95 pub thumb_exts: Option<Vec<String>>,
96}
97
98#[derive(Debug, Clone, Serialize, Deserialize, Default)]
100#[serde(default)]
101pub struct FileViewer {
102 #[serde(default)]
103 pub extensions: Vec<String>,
104 #[serde(default)]
105 pub handler: String,
106 #[serde(default)]
107 pub name: String,
108 #[serde(default)]
109 pub priority: i32,
110}
111
112#[derive(Debug, Clone, Serialize, Deserialize)]
114pub struct PaymentSetting {
115 pub providers: Vec<PaymentProvider>,
116}
117
118#[derive(Debug, Clone, Serialize, Deserialize)]
120pub struct PaymentProvider {
121 pub id: String,
122 pub name: String,
123 pub enabled: bool,
124}
125
126#[derive(Debug, Clone, Serialize, Deserialize)]
128pub struct StorageProduct {
129 pub id: String,
130 pub name: String,
131 pub price: f64,
132 pub storage: i64,
133}
134
135#[derive(Debug, Clone, Serialize, Deserialize)]
137pub struct GroupSKU {
138 pub id: String,
139 pub name: String,
140 pub price: f64,
141 pub group_id: String,
142}
143
144#[derive(Debug, Clone, Serialize, Deserialize, Default)]
146#[serde(default)]
147pub struct CustomProps {
148 #[serde(default)]
149 pub key: String,
150 #[serde(default)]
151 pub name: String,
152 #[serde(default)]
153 pub r#type: String,
154 #[serde(default)]
155 pub options: Option<Vec<String>>,
156}
157
158#[derive(Debug, Clone, Serialize, Deserialize)]
160pub struct CustomNavItem {
161 pub icon: String,
162 pub name: String,
163 pub url: String,
164}
165
166#[derive(Debug, Clone, Serialize, Deserialize)]
168pub struct CustomHTML {
169 pub head: Option<String>,
170 pub body: Option<String>,
171}