Mountain/Binary/Build/
WindowBuild.rs

1//! # Window Build Module
2//!
3//! Creates and configures the main application window.
4
5use tauri::{App, WebviewUrl, WebviewWindowBuilder, Wry};
6
7/// Creates and configures the main application window.
8///
9/// # Arguments
10///
11/// * `Application` - The Tauri application instance
12/// * `LocalhostUrl` - The localhost URL for the webview content
13///
14/// # Returns
15///
16/// A configured `WebviewWindow<Wry>` instance.
17///
18/// # Platform-Specific Behavior
19///
20/// - Windows/macOS/Linux: Sets title, maximized state, no decorations, and
21///   shadow effect
22/// - Debug builds: Automatically opens DevTools
23pub fn WindowBuild(Application:&mut App, LocalhostUrl:String) -> tauri::WebviewWindow<Wry> {
24	// Create the window URL pointing to the application
25	let WindowUrl = WebviewUrl::External(
26	        format!("{}/index.html", LocalhostUrl)
27	        .parse()
28	        .expect("FATAL: Failed to parse localhost URL"),
29	);
30
31	// Configure window builder with base settings
32	let mut WindowBuilder = WebviewWindowBuilder::new(Application, "main", WindowUrl)
33		.use_https_scheme(false)
34		.initialization_script("")
35		.zoom_hotkeys_enabled(true)
36		.browser_extensions_enabled(false);
37
38	// Apply platform-specific window configurations
39	#[cfg(any(target_os = "windows", target_os = "macos", target_os = "linux"))]
40	{
41		WindowBuilder = WindowBuilder.title("Mountain").maximized(true).decorations(false).shadow(true);
42	}
43
44	// Build the main window
45	let MainWindow = WindowBuilder.build().expect("FATAL: Main window build failed");
46
47	// Open DevTools in debug builds
48	#[cfg(debug_assertions)]
49	{
50		MainWindow.open_devtools();
51	}
52
53	MainWindow
54}