MCPcopy Create free account
hub / github.com/GCWing/BitFun / load_startup_bootstrap_config

Method load_startup_bootstrap_config

src/apps/desktop/src/theme.rs:297–376  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

295 }
296
297 fn load_startup_bootstrap_config() -> StartupBootstrapConfig {
298 let default_theme = Self::default();
299 let default = StartupBootstrapConfig {
300 theme: default_theme.clone(),
301 locale: "zh-CN".to_string(),
302 keybindings: None,
303 };
304 let path_manager = match try_get_path_manager_arc() {
305 Ok(pm) => pm,
306 Err(e) => {
307 debug!("Failed to create PathManager, using default theme: {}", e);
308 return default;
309 }
310 };
311
312 let config_file = path_manager.app_config_file();
313 if !config_file.exists() {
314 return default;
315 }
316
317 let config_content = match std::fs::read_to_string(&config_file) {
318 Ok(content) => content,
319 Err(e) => {
320 debug!("Failed to read config file, using default theme: {}", e);
321 return default;
322 }
323 };
324
325 let config_value: serde_json::Value = match serde_json::from_str(&config_content) {
326 Ok(value) => value,
327 Err(e) => {
328 debug!("Failed to parse config file, using default theme: {}", e);
329 return default;
330 }
331 };
332
333 let locale = config_value
334 .pointer("/app/language")
335 .and_then(|value| value.as_str())
336 .or_else(|| {
337 config_value
338 .pointer("/i18n/currentLanguage")
339 .and_then(|value| value.as_str())
340 })
341 .unwrap_or("zh-CN")
342 .to_string();
343
344 let global_config: GlobalConfig = match serde_json::from_value(config_value) {
345 Ok(config) => config,
346 Err(e) => {
347 debug!("Failed to parse config file, using default theme: {}", e);
348 return StartupBootstrapConfig { locale, ..default };
349 }
350 };
351
352 let theme_id = global_config
353 .themes
354 .as_ref()

Callers

nothing calls this directly

Calls 5

try_get_path_manager_arcFunction · 0.85
app_config_fileMethod · 0.80
cloneMethod · 0.45
existsMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected