shell.rs
1 use crate::api::DEFAULT_DEVICE_URL; 2 use crate::components::terminal::Terminal; 3 use dioxus::prelude::*; 4 5 #[component] 6 pub fn Shell() -> Element { 7 let device_url = use_signal(|| { 8 #[cfg(target_arch = "wasm32")] 9 { 10 web_sys::window() 11 .and_then(|w| w.local_storage().ok().flatten()) 12 .and_then(|s| s.get_item("device_url").ok().flatten()) 13 .unwrap_or_else(|| DEFAULT_DEVICE_URL.to_string()) 14 } 15 #[cfg(not(target_arch = "wasm32"))] 16 DEFAULT_DEVICE_URL.to_string() 17 }); 18 19 let ws_url = { 20 let url = device_url.read().clone(); 21 url.replace("http://", "ws://").replace("https://", "wss://") + "/ws/shell" 22 }; 23 24 rsx! { 25 document::Title { "Apidae Shell" } 26 div { class: "fixed inset-0 bg-[#0a0a0c]", 27 Terminal { 28 id: "shell-fullscreen".to_string(), 29 ws_url, 30 font_size: 14, 31 height_class: "h-full".to_string(), 32 } 33 } 34 } 35 }