refactor: 删除死代码 CommentActions 组件
components/comments/actions.rs (CommentActions) 零引用——评论管理 操作(通过/垃圾/删除)已在 pages/admin/comments.rs 用 BTN_SOLID_* 常量实现,actions.rs 是遗留的重复实现。 原计划将它的内联按钮样式提取为 BTN_PILL_* 常量统一,但确认零引用后 直接删除整个文件更干净。trash_comment re-export 补 allow(unused_imports) (wasm-only import 在 server 构建触发的已知模式)。
This commit is contained in:
parent
9e57247a2d
commit
fade4e180f
@ -35,4 +35,5 @@ pub use update::batch_update_comment_status;
|
||||
/// 将指定评论标记为垃圾评论。
|
||||
pub use update::spam_comment;
|
||||
/// 将指定评论移入回收站。
|
||||
#[allow(unused_imports)]
|
||||
pub use update::trash_comment;
|
||||
|
||||
@ -1,73 +0,0 @@
|
||||
//! 评论管理操作组件
|
||||
//!
|
||||
//! 在后台管理文章评论时,提供通过、标记垃圾、删除(移入回收站)三种操作按钮。
|
||||
|
||||
use dioxus::prelude::*;
|
||||
|
||||
use crate::api::comments::{approve_comment, spam_comment, trash_comment};
|
||||
use crate::components::comments::section::CommentContext;
|
||||
|
||||
/// 评论管理操作按钮组件。
|
||||
///
|
||||
/// Props:
|
||||
/// - `comment_id`:目标评论 ID
|
||||
/// - `post_id`:所属文章 ID(当前未使用,保留用于未来扩展)
|
||||
///
|
||||
/// 关键事件:
|
||||
/// - 点击"通过"/"垃圾"/"删除"按钮后调用对应 API,操作完成后触发评论列表刷新
|
||||
/// - 操作期间禁用按钮,防止重复提交
|
||||
#[component]
|
||||
pub fn CommentActions(comment_id: i64, post_id: i32) -> Element {
|
||||
let ctx: CommentContext = use_context();
|
||||
let refresh_trigger = ctx.refresh_trigger;
|
||||
let mut busy = use_signal(|| false);
|
||||
|
||||
let _ = post_id;
|
||||
|
||||
rsx! {
|
||||
div { class: "flex items-center gap-1.5",
|
||||
button {
|
||||
class: "text-xs px-2 py-0.5 rounded-full text-green-700 dark:text-green-400 bg-green-50 dark:bg-green-900/20 hover:bg-green-100 dark:hover:bg-green-900/40 transition-colors cursor-pointer",
|
||||
disabled: busy(),
|
||||
onclick: move |_| {
|
||||
busy.set(true);
|
||||
let mut refresh_trigger = refresh_trigger;
|
||||
spawn(async move {
|
||||
let _ = approve_comment(comment_id).await;
|
||||
refresh_trigger.set(!refresh_trigger());
|
||||
busy.set(false);
|
||||
});
|
||||
},
|
||||
"通过"
|
||||
}
|
||||
button {
|
||||
class: "text-xs px-2 py-0.5 rounded-full text-amber-700 dark:text-amber-400 bg-amber-50 dark:bg-amber-900/20 hover:bg-amber-100 dark:hover:bg-amber-900/40 transition-colors cursor-pointer",
|
||||
disabled: busy(),
|
||||
onclick: move |_| {
|
||||
busy.set(true);
|
||||
let mut refresh_trigger = refresh_trigger;
|
||||
spawn(async move {
|
||||
let _ = spam_comment(comment_id).await;
|
||||
refresh_trigger.set(!refresh_trigger());
|
||||
busy.set(false);
|
||||
});
|
||||
},
|
||||
"垃圾"
|
||||
}
|
||||
button {
|
||||
class: "text-xs px-2 py-0.5 rounded-full text-red-700 dark:text-red-400 bg-red-50 dark:bg-red-900/20 hover:bg-red-100 dark:hover:bg-red-900/40 transition-colors cursor-pointer",
|
||||
disabled: busy(),
|
||||
onclick: move |_| {
|
||||
busy.set(true);
|
||||
let mut refresh_trigger = refresh_trigger;
|
||||
spawn(async move {
|
||||
let _ = trash_comment(comment_id).await;
|
||||
refresh_trigger.set(!refresh_trigger());
|
||||
busy.set(false);
|
||||
});
|
||||
},
|
||||
"删除"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,7 @@
|
||||
//! 评论组件模块
|
||||
//!
|
||||
//! 提供评论相关组件:评论列表、单条评论、待审核评论、评论表单、评论区段与管理操作。
|
||||
//! 提供评论相关组件:评论列表、单条评论、待审核评论、评论表单与评论区段。
|
||||
|
||||
/// 评论操作按钮组件。
|
||||
pub mod actions;
|
||||
/// 评论表单组件。
|
||||
pub mod form;
|
||||
/// 单条评论组件。
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user