refactor: 删除死代码 (delayed_loading.rs / ui.rs EmptyState / 未用 re-export)

- 删除 src/hooks/delayed_loading.rs:未在 hooks/mod.rs 注册,已被
  DelayedSkeleton 组件取代(mod.rs 注释已说明)
- 删除 src/components/ui.rs 的 EmptyState:零调用者,所有实际用法
  都走功能更全的 components/empty_state.rs::EmptyState
- 删除 api/posts/mod.rs 末尾的 render_markdown_enhanced / slug 工具
  re-export:调用方均使用完整路径 crate::api::{markdown,slug}::*,
  这两个跨模块短路径无引用
- 删除 api/comments/mod.rs 的 render_comment_markdown re-export:
  调用方用完整路径 crate::api::comments::markdown::render_comment_markdown

保留 auth.rs::invalidate_user_sessions:有完整文档说明的预留基础设施
(角色变更/封禁场景),非遗留垃圾。
This commit is contained in:
xfy 2026-07-14 14:27:31 +08:00
parent 0e4109358f
commit b39afbb616
4 changed files with 0 additions and 74 deletions

View File

@ -36,8 +36,3 @@ pub use update::batch_update_comment_status;
pub use update::spam_comment;
/// 将指定评论移入回收站。
pub use update::trash_comment;
#[cfg(feature = "server")]
/// 将评论 Markdown 渲染为安全的 HTML。
#[allow(unused_imports)]
pub use markdown::render_comment_markdown;

View File

@ -54,12 +54,3 @@ pub use types::*;
#[allow(unused_imports)]
pub use update::update_post;
/// 将 Markdown 渲染为增强 HTML含目录
#[cfg(feature = "server")]
#[allow(unused_imports)]
pub use crate::api::markdown::render_markdown_enhanced;
/// slug 生成与唯一性校验工具函数。
#[cfg(feature = "server")]
#[allow(unused_imports)]
pub use crate::api::slug::{ensure_unique_slug, is_valid_slug, slugify};

View File

@ -202,24 +202,6 @@ pub fn StatusBadge(color_class: &'static str, label: String) -> Element {
}
}
/// 空状态 / 错误状态组件。
///
/// 用于列表页无数据或加载失败时的居中占位提示。
///
/// Props
/// - `message`:提示文本
/// - `variant``"default"`(灰色,空状态)或 `"error"`(红色,加载失败)
#[component]
pub fn EmptyState(message: &'static str, variant: &'static str) -> Element {
let class = match variant {
"error" => "text-center text-red-500 dark:text-red-400 py-20",
_ => "text-center py-20 text-paper-secondary",
};
rsx! {
div { class: "{class}", "{message}" }
}
}
/// Tooltip 定位样式胶囊黑底白字hover 显现)。
const TOOLTIP_STYLE: &str =
"pointer-events-none absolute left-1/2 -translate-x-1/2 px-3 py-1.5 text-xs font-medium whitespace-nowrap rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-200 bg-paper-primary text-paper-theme shadow-lg z-50";

View File

@ -1,42 +0,0 @@
//! 骨架屏延迟加载状态 Hook。
//!
//! 通过延迟显示骨架屏,避免数据加载很快时出现闪烁。
use crate::utils::time::sleep_ms;
use dioxus::prelude::*;
/// 骨架屏最小显示延迟(毫秒)。加载时间低于此值时不会显示骨架屏,避免闪烁。
pub const MIN_SKELETON_DELAY_MS: u32 = 200;
/// 延迟加载状态 Hook。
///
/// 当 `is_loading` 返回 true 时,延迟 `MIN_SKELETON_DELAY_MS` 毫秒后才返回 true
/// 当 `is_loading` 返回 false 时,立即返回 false。
///
/// 用于骨架屏:避免数据加载很快时出现骨架屏一闪而过的问题。
pub fn use_delayed_loading<F>(is_loading: F) -> Signal<bool>
where
F: Fn() -> bool + Clone + 'static,
{
let mut should_show = use_signal(|| false);
use_effect(move || {
let loading = is_loading();
if loading {
if !should_show() {
let is_loading_clone = is_loading.clone();
spawn(async move {
sleep_ms(MIN_SKELETON_DELAY_MS).await;
if is_loading_clone() {
should_show.set(true);
}
});
}
} else {
should_show.set(false);
}
});
should_show
}