add file browser component and widget
This commit is contained in:
0
examples/website/build.sh
Normal file → Executable file
0
examples/website/build.sh
Normal file → Executable file
@@ -6,7 +6,8 @@ use crate::router::{Route, switch};
|
||||
use crate::console::{expose_to_console, log_console_examples};
|
||||
|
||||
pub struct App {
|
||||
ws_manager: WsManager,
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
ws_manager: WsManager,
|
||||
}
|
||||
|
||||
pub enum AppMsg {
|
||||
@@ -18,25 +19,36 @@ impl Component for App {
|
||||
type Properties = ();
|
||||
|
||||
fn create(_ctx: &Context<Self>) -> Self {
|
||||
let ws_manager = WsManager::builder()
|
||||
.add_server_url("ws://localhost:8080".to_string())
|
||||
.add_server_url("ws://localhost:8081".to_string())
|
||||
.add_server_url("ws://localhost:8443/ws".to_string())
|
||||
.build();
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
let ws_manager = WsManager::builder()
|
||||
.add_server_url("ws://localhost:8080".to_string())
|
||||
.add_server_url("ws://localhost:8081".to_string())
|
||||
.add_server_url("ws://localhost:8443/ws".to_string())
|
||||
.build();
|
||||
|
||||
// Expose WebSocket manager to browser console
|
||||
expose_to_console(ws_manager.clone());
|
||||
log_console_examples();
|
||||
// Expose WebSocket manager to browser console
|
||||
expose_to_console(ws_manager.clone());
|
||||
log_console_examples();
|
||||
|
||||
// Clone the manager to move it into the async block
|
||||
let manager_clone = ws_manager.clone();
|
||||
spawn_local(async move {
|
||||
if let Err(e) = manager_clone.connect().await {
|
||||
log::error!("Failed to connect WebSocket manager: {:?}", e);
|
||||
}
|
||||
});
|
||||
// Clone the manager to move it into the async block
|
||||
let manager_clone = ws_manager.clone();
|
||||
spawn_local(async move {
|
||||
if let Err(e) = manager_clone.connect().await {
|
||||
log::error!("Failed to connect WebSocket manager: {:?}", e);
|
||||
}
|
||||
});
|
||||
|
||||
Self { ws_manager }
|
||||
Self { ws_manager }
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
{
|
||||
// For WASM builds, just log console examples
|
||||
log_console_examples();
|
||||
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
fn update(&mut self, _ctx: &Context<Self>, _msg: Self::Message) -> bool {
|
||||
@@ -44,9 +56,17 @@ impl Component for App {
|
||||
}
|
||||
|
||||
fn view(&self, _ctx: &Context<Self>) -> Html {
|
||||
let ws_manager_for_switch = self.ws_manager.clone();
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let switch_render = {
|
||||
let ws_manager_for_switch = self.ws_manager.clone();
|
||||
Callback::from(move |route: Route| {
|
||||
switch(route, ws_manager_for_switch.clone())
|
||||
})
|
||||
};
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let switch_render = Callback::from(move |route: Route| {
|
||||
switch(route, ws_manager_for_switch.clone())
|
||||
switch(route)
|
||||
});
|
||||
|
||||
html! {
|
||||
|
Reference in New Issue
Block a user