From c924b1e643b95600de9ee19c9c72fc94ca4b0c77 Mon Sep 17 00:00:00 2001 From: xfy Date: Wed, 27 May 2026 13:29:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=AF=91=E5=99=A8?= =?UTF-8?q?=E8=AD=A6=E5=91=8A=E5=B9=B6=E6=94=B9=E8=BF=9B=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=B4=A8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/footer.rs | 25 +++++++++++++++++-------- src/pages/admin/write.rs | 8 ++------ src/tasks/session_cleanup.rs | 4 ++-- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/components/footer.rs b/src/components/footer.rs index 061a16e..cf19de8 100644 --- a/src/components/footer.rs +++ b/src/components/footer.rs @@ -1,8 +1,9 @@ use dioxus::prelude::*; #[component] +#[allow(unused_mut)] pub fn Footer() -> Element { - let visible = use_signal(|| false); + let mut visible = use_signal(|| false); use_effect(move || { #[cfg(target_arch = "wasm32")] @@ -10,18 +11,26 @@ pub fn Footer() -> Element { if let Some(window) = web_sys::window() { let closure = wasm_bindgen::prelude::Closure::wrap(Box::new(move || { if let Some(w) = web_sys::window() { - let threshold = w.inner_height().ok() + let threshold = w + .inner_height() + .ok() .and_then(|h| h.as_f64()) .unwrap_or(0.0); let scroll_y = w.scroll_y().unwrap_or(0.0); let new_visible = scroll_y > threshold; visible.set(new_visible); } - }) as Box); + }) + as Box); - let _ = window.add_event_listener_with_callback("scroll", wasm_bindgen::JsCast::unchecked_ref(closure.as_ref())); + let _ = window.add_event_listener_with_callback( + "scroll", + wasm_bindgen::JsCast::unchecked_ref(closure.as_ref()), + ); - let threshold = window.inner_height().ok() + let threshold = window + .inner_height() + .ok() .and_then(|h| h.as_f64()) .unwrap_or(0.0); let scroll_y = window.scroll_y().unwrap_or(0.0); @@ -75,9 +84,9 @@ fn scroll_to_top() { #[cfg(target_arch = "wasm32")] { if let Some(window) = web_sys::window() { - let mut options = web_sys::ScrollToOptions::new(); - options.top(0.0); - options.behavior(web_sys::ScrollBehavior::Smooth); + let options = web_sys::ScrollToOptions::new(); + options.set_top(0.0); + options.set_behavior(web_sys::ScrollBehavior::Smooth); let _ = window.scroll_to_with_scroll_to_options(&options); if let Ok(history) = window.history() { diff --git a/src/pages/admin/write.rs b/src/pages/admin/write.rs index a4a4b72..75758c2 100644 --- a/src/pages/admin/write.rs +++ b/src/pages/admin/write.rs @@ -6,9 +6,10 @@ use wasm_bindgen::JsCast; use crate::components::write_skeleton::WriteSkeleton; #[component] +#[allow(unused_mut, unused_variables)] pub fn Write() -> Element { let mut title = use_signal(|| "".to_string()); - let content = use_signal(|| "".to_string()); + let mut content = use_signal(|| "".to_string()); let mut loading = use_signal(|| true); // 初始化 Tiptap 编辑器 @@ -105,11 +106,6 @@ pub fn Write() -> Element { })() "#).ok().and_then(|v| v.as_string()).unwrap_or_default(); content.set(md.clone()); - println!("保存文章: title={}, content_len={}", title(), md.len()); - } - #[cfg(not(target_arch = "wasm32"))] - { - println!("保存文章: title={}, content_len={}", title(), content().len()); } }, "保存草稿" diff --git a/src/tasks/session_cleanup.rs b/src/tasks/session_cleanup.rs index 379d708..1969fbe 100644 --- a/src/tasks/session_cleanup.rs +++ b/src/tasks/session_cleanup.rs @@ -14,11 +14,11 @@ pub async fn run_cleanup() { .execute("DELETE FROM sessions WHERE expires_at < NOW()", &[]) .await { - eprintln!("Session cleanup error: {}", e); + tracing::error!("Session cleanup error: {}", e); } } Err(e) => { - eprintln!("Failed to get DB connection for cleanup: {}", e); + tracing::error!("Failed to get DB connection for cleanup: {}", e); } } }