use crate::error_template::{AppError, ErrorTemplate};
use leptos::ev::{keypress, KeyboardEvent};
use leptos::*;
use leptos_meta::*;
use leptos_router::*;
use leptos_use::storage::use_local_storage;
use leptos_use::{
use_debounce_fn, use_event_listener, use_intl_number_format, UseIntlNumberFormatOptions,
};
#[component]
pub fn App(cx: Scope) -> impl IntoView {
// Provides context that manages stylesheets, titles, meta tags, etc.
provide_meta_context(cx);
view! {
cx,
}
.into_view(cx)
}>
}/>
}
}
/// Renders the home page of your application.
#[component]
fn HomePage(cx: Scope) -> impl IntoView {
// Creates a reactive value to update the button
let (count, set_count, _) = use_local_storage(cx, "count-state", 0);
let on_click = move |_| set_count.update(|count| *count += 1);
let nf = use_intl_number_format(
UseIntlNumberFormatOptions::default().locale("zh-Hans-CN-u-nu-hanidec"),
);
let zh_count = nf.format::(cx, count);
let (key, set_key) = create_signal(cx, "".to_string());
create_effect(cx, move |_| {
// window() doesn't work on the server
let _ = use_event_listener(cx, window(), keypress, move |evt: KeyboardEvent| {
set_key(evt.key())
});
});
let (debounce_value, set_debounce_value) = create_signal(cx, "not called");
let debounced_fn = use_debounce_fn(
move || {
set_debounce_value("called");
},
2000.0,
);
debounced_fn();
view! { cx,