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:
xfy 2026-07-02 16:18:52 +08:00
parent dcdd72a8c2
commit 759bbab7ee
8 changed files with 11 additions and 9 deletions

View File

@ -7,7 +7,7 @@ use dioxus::prelude::*;
use crate::api::comments::create_comment; use crate::api::comments::create_comment;
use crate::components::comments::section::CommentContext; use crate::components::comments::section::CommentContext;
use crate::components::forms::{AlertBox, INPUT_CLASS}; use crate::components::forms::{AlertBox, INPUT_CLASS};
use crate::hooks::comment_storage::{self, PendingComment}; use crate::utils::comment_storage::{self, PendingComment};
/// 评论提交按钮样式:去掉全宽,改为内联宽度并右对齐。 /// 评论提交按钮样式:去掉全宽,改为内联宽度并右对齐。
/// ///

View File

@ -6,7 +6,7 @@ use dioxus::prelude::*;
use crate::components::comments::item::CommentItem; use crate::components::comments::item::CommentItem;
use crate::components::comments::pending_item::PendingCommentItem; use crate::components::comments::pending_item::PendingCommentItem;
use crate::hooks::comment_storage::PendingComment; use crate::utils::comment_storage::PendingComment;
use crate::models::comment::PublicComment; use crate::models::comment::PublicComment;
/// 合并后的评论节点,可能是已审核或待审核评论。 /// 合并后的评论节点,可能是已审核或待审核评论。

View File

@ -5,7 +5,7 @@
use dioxus::prelude::*; 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; use crate::utils::time::format_relative_time_iso;
/// 待审核评论项组件。 /// 待审核评论项组件。

View File

@ -9,7 +9,7 @@ use crate::api::comments::{check_pending_status, get_comments, CommentTreeRespon
use crate::components::comments::form::CommentForm; use crate::components::comments::form::CommentForm;
use crate::components::comments::list::CommentList; use crate::components::comments::list::CommentList;
use crate::components::skeletons::comment_skeleton::CommentListSkeleton; use crate::components::skeletons::comment_skeleton::CommentListSkeleton;
use crate::hooks::comment_storage::{self, PendingComment}; use crate::utils::comment_storage::{self, PendingComment};
/// 评论上下文,供评论相关组件共享状态。 /// 评论上下文,供评论相关组件共享状态。
/// ///

View File

@ -1,12 +1,11 @@
//! 共享的 Dioxus Hooks 模块。 //! 共享的 Dioxus Hooks 模块。
//! //!
//! 该模块集中管理可在组件树中复用的自定义 Hook包括 //! 该模块集中管理可在组件树中复用的自定义 Hook包括
//! - 评论草稿在浏览器 localStorage 中的持久化WASM 端)
//! - 骨架屏延迟加载状态 //! - 骨架屏延迟加载状态
//! - 通用 DOM 事件监听(注册 + 自动卸载清理) //! - 通用 DOM 事件监听(注册 + 自动卸载清理)
//!
/// 评论草稿持久化 Hook基于浏览器的 localStorage仅在 WASM 端有效)。 //! 评论草稿持久化localStorage 读写)已迁至 `crate::utils::comment_storage`
pub mod comment_storage; //! 因为它是纯工具函数而非渲染期 Hook。
/// 延迟加载状态 Hook。 /// 延迟加载状态 Hook。
pub mod delayed_loading; pub mod delayed_loading;

View File

@ -1,7 +1,7 @@
//! HTML 转义工具(零依赖纯函数,前端后端通用)。 //! HTML 转义工具(零依赖纯函数,前端后端通用)。
//! //!
//! 仓库内原先存在两份 `escape_html` 实现: //! 仓库内原先存在两份 `escape_html` 实现:
//! - `hooks::comment_storage::escape_html``'` → `'` //! - `utils::html::escape_html``'` → `'`
//! - `api::comments::helpers::escape_html``'` → `'`server-only //! - `api::comments::helpers::escape_html``'` → `'`server-only
//! 现统一到本模块,单引号采用 HTML5 标准的 `'`。 //! 现统一到本模块,单引号采用 HTML5 标准的 `'`。

View File

@ -1,9 +1,12 @@
//! 通用工具函数子模块。 //! 通用工具函数子模块。
//! //!
//! - `comment_storage`:评论草稿 localStorage 持久化WASM 端)。
//! - `html`HTML 转义(两端通用)。 //! - `html`HTML 转义(两端通用)。
//! - `text`Markdown / 纯文本处理(仅 `server` feature //! - `text`Markdown / 纯文本处理(仅 `server` feature
//! - `time`:跨平台时间/睡眠工具WASM 与原生异步版本)。 //! - `time`:跨平台时间/睡眠工具WASM 与原生异步版本)。
/// 评论草稿 localStorage 持久化(仅在 WASM 端实际读写)。
pub mod comment_storage;
/// HTML 转义工具(前端后端通用)。 /// HTML 转义工具(前端后端通用)。
pub mod html; pub mod html;
/// Markdown / 纯文本处理工具。 /// Markdown / 纯文本处理工具。