refactor(utils): comment_storage 从 hooks/ 迁至 utils/
该文件全是普通函数(save_author / load_pending_comments 等),没有任何 use_ 开头的 Hook,放在 hooks/ 下名不副实。内部只剩结构体与 localStorage 读写(时间/HTML 工具已在上一 commit 拆出),迁到 utils/ 后文件名与内容 自洽,hooks/ 目录回归只放真正的渲染期 Hook。 机械替换 4 个组件文件的 use 路径(hooks::comment_storage → utils::comment_storage)。
This commit is contained in:
parent
dcdd72a8c2
commit
759bbab7ee
@ -7,7 +7,7 @@ use dioxus::prelude::*;
|
||||
use crate::api::comments::create_comment;
|
||||
use crate::components::comments::section::CommentContext;
|
||||
use crate::components::forms::{AlertBox, INPUT_CLASS};
|
||||
use crate::hooks::comment_storage::{self, PendingComment};
|
||||
use crate::utils::comment_storage::{self, PendingComment};
|
||||
|
||||
/// 评论提交按钮样式:去掉全宽,改为内联宽度并右对齐。
|
||||
///
|
||||
|
||||
@ -6,7 +6,7 @@ use dioxus::prelude::*;
|
||||
|
||||
use crate::components::comments::item::CommentItem;
|
||||
use crate::components::comments::pending_item::PendingCommentItem;
|
||||
use crate::hooks::comment_storage::PendingComment;
|
||||
use crate::utils::comment_storage::PendingComment;
|
||||
use crate::models::comment::PublicComment;
|
||||
|
||||
/// 合并后的评论节点,可能是已审核或待审核评论。
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
|
||||
use dioxus::prelude::*;
|
||||
|
||||
use crate::hooks::comment_storage::{render_pending_content, PendingComment};
|
||||
use crate::utils::comment_storage::{render_pending_content, PendingComment};
|
||||
use crate::utils::time::format_relative_time_iso;
|
||||
|
||||
/// 待审核评论项组件。
|
||||
|
||||
@ -9,7 +9,7 @@ use crate::api::comments::{check_pending_status, get_comments, CommentTreeRespon
|
||||
use crate::components::comments::form::CommentForm;
|
||||
use crate::components::comments::list::CommentList;
|
||||
use crate::components::skeletons::comment_skeleton::CommentListSkeleton;
|
||||
use crate::hooks::comment_storage::{self, PendingComment};
|
||||
use crate::utils::comment_storage::{self, PendingComment};
|
||||
|
||||
/// 评论上下文,供评论相关组件共享状态。
|
||||
///
|
||||
|
||||
@ -1,12 +1,11 @@
|
||||
//! 共享的 Dioxus Hooks 模块。
|
||||
//!
|
||||
//! 该模块集中管理可在组件树中复用的自定义 Hook,包括:
|
||||
//! - 评论草稿在浏览器 localStorage 中的持久化(WASM 端)
|
||||
//! - 骨架屏延迟加载状态
|
||||
//! - 通用 DOM 事件监听(注册 + 自动卸载清理)
|
||||
|
||||
/// 评论草稿持久化 Hook,基于浏览器的 localStorage(仅在 WASM 端有效)。
|
||||
pub mod comment_storage;
|
||||
//!
|
||||
//! 评论草稿持久化(localStorage 读写)已迁至 `crate::utils::comment_storage`,
|
||||
//! 因为它是纯工具函数而非渲染期 Hook。
|
||||
|
||||
/// 延迟加载状态 Hook。
|
||||
pub mod delayed_loading;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
//! HTML 转义工具(零依赖纯函数,前端后端通用)。
|
||||
//!
|
||||
//! 仓库内原先存在两份 `escape_html` 实现:
|
||||
//! - `hooks::comment_storage::escape_html`(`'` → `'`)
|
||||
//! - `utils::html::escape_html`(`'` → `'`)
|
||||
//! - `api::comments::helpers::escape_html`(`'` → `'`,server-only)
|
||||
//! 现统一到本模块,单引号采用 HTML5 标准的 `'`。
|
||||
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
//! 通用工具函数子模块。
|
||||
//!
|
||||
//! - `comment_storage`:评论草稿 localStorage 持久化(WASM 端)。
|
||||
//! - `html`:HTML 转义(两端通用)。
|
||||
//! - `text`:Markdown / 纯文本处理(仅 `server` feature)。
|
||||
//! - `time`:跨平台时间/睡眠工具(WASM 与原生异步版本)。
|
||||
|
||||
/// 评论草稿 localStorage 持久化(仅在 WASM 端实际读写)。
|
||||
pub mod comment_storage;
|
||||
/// HTML 转义工具(前端后端通用)。
|
||||
pub mod html;
|
||||
/// Markdown / 纯文本处理工具。
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user