From c8c3c88d99a0c6d7291d563a3218f6ad9b96389c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=9B=A8=E9=9C=96=E9=93=83?= <2712495353@qq.com>
Date: Mon, 6 Jul 2026 20:05:52 +0800
Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=20PageSkeleton?=
=?UTF-8?q?=20=E7=BB=84=E4=BB=B6=E5=8F=8A=E7=9B=B8=E5=85=B3=E6=B5=8B?=
=?UTF-8?q?=E8=AF=95=EF=BC=8C=E6=9B=B4=E6=96=B0=20RouterContainer=20?=
=?UTF-8?q?=E4=BB=A5=E7=AE=80=E5=8C=96=E5=8A=A0=E8=BD=BD=E9=80=BB=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/PageSkeleton.tsx | 41 -------------------
src/components/README.md | 25 ++++++-----
src/components/RouterContainer.tsx | 3 +-
.../__tests__/PageSkeleton.test.tsx | 32 ---------------
tailwind.shell.config.js | 1 -
5 files changed, 13 insertions(+), 89 deletions(-)
delete mode 100644 src/components/PageSkeleton.tsx
delete mode 100644 src/components/__tests__/PageSkeleton.test.tsx
diff --git a/src/components/PageSkeleton.tsx b/src/components/PageSkeleton.tsx
deleted file mode 100644
index 35c5bdb..0000000
--- a/src/components/PageSkeleton.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * PageSkeleton 组件 - 页面加载骨架屏
- *
- * 用于 Suspense fallback 和初始加载状态,提供平滑的视觉过渡
- * 避免白屏闪烁,减少布局偏移
- */
-
-/**
- * 工具页面骨架屏
- */
-function ToolPageSkeleton() {
- return (
-
- {/* 标题区域 */}
-
-
- {/* 输入区域 */}
-
-
- {/* 控制栏 */}
-
-
- {/* 结果区域 */}
-
-
- );
-}
-
-/**
- * 页面加载骨架屏
- */
-export default function PageSkeleton() {
- return ;
-}
-
-PageSkeleton.displayName = 'PageSkeleton';
diff --git a/src/components/README.md b/src/components/README.md
index f08076a..ebcda16 100644
--- a/src/components/README.md
+++ b/src/components/README.md
@@ -4,20 +4,19 @@
## 组件列表
-| 组件 | 用途 |
-| ----------------------- | ------------------------------------------------------------------------------ |
-| `RouterContainer.tsx` | 路由容器,根据当前路由动态渲染对应页面组件,集成错误边界和骨架屏 |
-| `SwitchButtonGroup.tsx` | 通用切换按钮组,支持 `small/medium/large` 三种尺寸,用于页面子模式切换 |
-| `EmptyPlaceholder.tsx` | 虚线边框空状态占位,统一工具页「暂无结果」提示样式 |
-| `TextInputArea.tsx` | 增强文本输入区域,支持校验规则、工具栏操作、字符计数、清空 |
+| 组件 | 用途 |
+| ----------------------- | ------------------------------------------------------------------------------------------------------ |
+| `RouterContainer.tsx` | 路由容器,根据当前路由动态渲染对应页面组件,集成错误边界 |
+| `SwitchButtonGroup.tsx` | 通用切换按钮组,支持 `small/medium/large` 三种尺寸,用于页面子模式切换 |
+| `EmptyPlaceholder.tsx` | 虚线边框空状态占位,统一工具页「暂无结果」提示样式 |
+| `TextInputArea.tsx` | 增强文本输入区域,支持校验规则、工具栏操作、字符计数、清空 |
| `CopyButton.tsx` | 一键复制按钮:复制成功后 1.5s 内切换为 Check 图标并应用 `text-emerald-500`;空内容/失败时 `toast` 提示 |
-| `ImageUploader.tsx` | 图片上传组件,支持拖拽上传、文件选择和预览 |
-| `QrCodePreview.tsx` | 二维码预览组件,展示生成的二维码图片,提供复制和下载操作 |
-| `DecodeResultPaper.tsx` | Base64 解码结果展示面板,显示 MIME 类型、文件大小、文件名输入和下载按钮 |
-| `GlobalSnackbar.tsx` | 全局消息提示组件 + Context Provider,支持受控/Hook/全局单例三种使用方式 |
-| `ErrorBoundary.tsx` | 全局错误边界(类组件),捕获子组件树 JS 错误并展示友好错误页面 |
-| `PageErrorBoundary.tsx` | 页面级错误边界,适配 shadcn 暗黑模式,支持 `resetKey` 自动恢复 |
-| `PageSkeleton.tsx` | 页面骨架屏,提供 `dashboard` 和 `tool` 两种变体,用于 Suspense fallback |
+| `ImageUploader.tsx` | 图片上传组件,支持拖拽上传、文件选择和预览 |
+| `QrCodePreview.tsx` | 二维码预览组件,展示生成的二维码图片,提供复制和下载操作 |
+| `DecodeResultPaper.tsx` | Base64 解码结果展示面板,显示 MIME 类型、文件大小、文件名输入和下载按钮 |
+| `GlobalSnackbar.tsx` | 全局消息提示组件 + Context Provider,支持受控/Hook/全局单例三种使用方式 |
+| `ErrorBoundary.tsx` | 全局错误边界(类组件),捕获子组件树 JS 错误并展示友好错误页面 |
+| `PageErrorBoundary.tsx` | 页面级错误边界,适配 shadcn 暗黑模式,支持 `resetKey` 自动恢复 |
## 使用约定
diff --git a/src/components/RouterContainer.tsx b/src/components/RouterContainer.tsx
index 86186ab..6a68ea6 100644
--- a/src/components/RouterContainer.tsx
+++ b/src/components/RouterContainer.tsx
@@ -4,7 +4,6 @@ import { useRouter } from '@/providers/RouterProvider';
import type { PageType } from '@/types/storage';
import { type ComponentType, useEffect, useState } from 'react';
import PageErrorBoundary from '@/components/PageErrorBoundary';
-import PageSkeleton from '@/components/PageSkeleton';
import { cn } from '@/lib/utils';
import { AlertTriangle } from 'lucide-react';
@@ -30,7 +29,7 @@ function LoadedPage({ pageKey }: { pageKey: PageType }) {
}, [pageKey]);
if (!Page) {
- return ;
+ return ;
}
return ;
diff --git a/src/components/__tests__/PageSkeleton.test.tsx b/src/components/__tests__/PageSkeleton.test.tsx
deleted file mode 100644
index 3839723..0000000
--- a/src/components/__tests__/PageSkeleton.test.tsx
+++ /dev/null
@@ -1,32 +0,0 @@
-import { describe, expect, it } from 'vitest';
-import { render } from '@testing-library/react';
-import PageSkeleton from '@/components/PageSkeleton';
-
-describe('PageSkeleton 组件', () => {
- describe('渲染测试', () => {
- it('应渲染工具页面骨架', () => {
- const { container } = render();
-
- const skeletons = container.querySelectorAll('.animate-pulse');
- expect(skeletons.length).toBeGreaterThan(0);
- });
- });
-
- describe('布局结构测试', () => {
- it('工具骨架屏应有内边距', () => {
- const { container } = render();
- const toolContainer = container.firstChild as HTMLElement;
-
- expect(toolContainer).toHaveClass('p-5');
- });
- });
-
- describe('骨架屏元素测试', () => {
- it('工具骨架屏应包含动画脉冲效果', () => {
- const { container } = render();
-
- const skeletons = container.querySelectorAll('.animate-pulse');
- expect(skeletons.length).toBeGreaterThan(0);
- });
- });
-});
diff --git a/tailwind.shell.config.js b/tailwind.shell.config.js
index 9acb3f0..cf2ea5b 100644
--- a/tailwind.shell.config.js
+++ b/tailwind.shell.config.js
@@ -11,7 +11,6 @@ export default {
'./src/components/ErrorBoundary.tsx',
'./src/components/ErrorFallback.tsx',
'./src/components/PageErrorBoundary.tsx',
- './src/components/PageSkeleton.tsx',
'./src/components/ui/button.tsx',
'./src/components/ui/input.tsx',
'./src/components/ui/sonner.tsx',