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

Function create_main_window

src/apps/desktop/src/theme.rs:533–651  ·  view source on GitHub ↗
(
    app_handle: &tauri::AppHandle,
    startup_trace_id: &str,
    startup_trace: &DesktopStartupTrace,
    workspace_startup_state: Option<serde_json::Value>,
)

Source from the content-addressed store, hash-verified

531}
532
533pub fn create_main_window(
534 app_handle: &tauri::AppHandle,
535 startup_trace_id: &str,
536 startup_trace: &DesktopStartupTrace,
537 workspace_startup_state: Option<serde_json::Value>,
538) {
539 let total_started_at = Instant::now();
540 let bootstrap_config = ThemeConfig::load_startup_bootstrap_config();
541 let theme = bootstrap_config.theme.clone();
542 let bg_color = theme.to_tauri_color();
543 let init_script = theme.generate_init_script(
544 startup_trace_id,
545 &bootstrap_config,
546 workspace_startup_state.as_ref(),
547 );
548 startup_trace.record_step(
549 "native_step_end",
550 "native_window",
551 "prepare_theme",
552 total_started_at.elapsed().as_millis(),
553 );
554 debug!(
555 "Main window creation step completed: step=prepare_theme duration_ms={}",
556 total_started_at.elapsed().as_millis()
557 );
558
559 let main_url = if cfg!(debug_assertions) {
560 match "http://localhost:1422".parse() {
561 Ok(url) => WebviewUrl::External(url),
562 Err(e) => {
563 error!("Invalid dev URL, fallback to app URL: {}", e);
564 WebviewUrl::App("index.html".into())
565 }
566 }
567 } else {
568 WebviewUrl::App("index.html".into())
569 };
570 let main_url_kind = match &main_url {
571 WebviewUrl::External(_) => "external",
572 WebviewUrl::App(_) => "app",
573 _ => "other",
574 };
575
576 #[allow(unused_mut)]
577 let mut builder = tauri::WebviewWindowBuilder::new(app_handle, "main", main_url)
578 .title("BitFun")
579 .inner_size(1200.0, 800.0)
580 .resizable(true)
581 .fullscreen(false)
582 .visible(false)
583 .background_color(bg_color)
584 .accept_first_mouse(true)
585 .initialization_script(&init_script)
586 .on_page_load({
587 let startup_trace_id = startup_trace_id.to_string();
588 let total_started_at = total_started_at;
589 move |_window, payload| {
590 let event = match payload.event() {

Callers 1

runFunction · 0.85

Calls 10

to_tauri_colorMethod · 0.80
generate_init_scriptMethod · 0.80
record_stepMethod · 0.80
titleMethod · 0.80
record_elapsed_stepMethod · 0.80
AppFunction · 0.50
cloneMethod · 0.45
parseMethod · 0.45
buildMethod · 0.45

Tested by

no test coverage detected