From 9601afdd4939f7d8607d48ecf48cfe1cb188d57c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=A8=E9=9C=96=E9=93=83?= Date: Fri, 22 May 2026 22:06:34 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=20HtmlToMarkdown?= =?UTF-8?q?=20=E5=92=8C=20MarkdownToHtml=20=E9=A1=B5=E9=9D=A2=EF=BC=8C?= =?UTF-8?q?=E7=BB=9F=E4=B8=80=20shadcn=20=E6=A0=B7=E5=BC=8F=E5=B9=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=89=93=E5=8D=B0=E4=B8=8E=E6=9A=97=E8=89=B2?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/HtmlToMarkdown/index.tsx | 106 ++++++++++------ pages/MarkdownToHtml/index.tsx | 213 ++++++++++++++++++--------------- utils/markdownToHtml.ts | 16 ++- 3 files changed, 200 insertions(+), 135 deletions(-) diff --git a/pages/HtmlToMarkdown/index.tsx b/pages/HtmlToMarkdown/index.tsx index 6070675..a2d2001 100644 --- a/pages/HtmlToMarkdown/index.tsx +++ b/pages/HtmlToMarkdown/index.tsx @@ -4,9 +4,11 @@ import { useLazyTranslation } from '@/utils/useLazyTranslation'; import PageHeader from '@/components/PageHeader'; import CopyButton from '@/components/CopyButton'; import SwitchButtonGroup from '@/components/SwitchButtonGroup'; +import { Button } from '@/components/ui/button'; // 💡 1. 全面回归规范:引入原生的 shadcn 原子 Button import { useStorageState } from '@/utils/useStorageState'; import type { HtmlToMarkdownPreviewMode } from '@/types/storage'; -import { htmlToMarkdown, downloadMarkdownFile, SAMPLE_HTML } from '@/utils/htmlToMarkdown'; +import { downloadMarkdownFile, htmlToMarkdown, SAMPLE_HTML } from '@/utils/htmlToMarkdown'; +import { cn } from '@/lib/utils'; const isValidPreviewMode = (val: unknown): val is HtmlToMarkdownPreviewMode => typeof val === 'string' && ['split', 'preview', 'markdown'].includes(val); @@ -44,12 +46,20 @@ export default function HtmlToMarkdownPage() { const showOutput = previewMode !== 'markdown'; return ( -
- } /> + /* 💡 统一间距尺寸: + - 彻底清除多余的 container max-w-7xl 这种网页大边距, + - 统一收拢为我们先前在 Dashboard 页、JSON 工具箱制定的 p-4 space-y-4 标准极客桌面规格。 + */ +
+ } + />
- {/* 工具栏 */} -
+ {/* 工具栏集成区 */} +
-
- - +
- {/* 错误提示 */} + {/* 错误提示: + - 💡 核心修复点:将硬编码的 bg-red-50 实色,完美超进化为系统的全自适应透明色变体 + */} {error && ( -
+
{error}
)} - {/* 主内容区 */} + {/* 双翼/单栏联动面板展示区 */}
- {/* HTML 输入区 */} + {/* HTML 输入端卡片面板 */} {showInput && ( -
-
- {t('inputLabel')} - + /* 3. 智能聚焦框联动(Focus Ring Clamping): + - 外层容器追加 focus-within 变量追踪大闸。 + - 只要用户用鼠标点击了内部的 textarea,外层整块精巧的圆角大边框会一帧内亮起 primary 系统的深色呼吸发光环, + - 这种“全外包裹层框聚焦”的体验极大模仿了本地原生 IDE 的硬核专业体验! + */ +
+ {/* 卡片头部:改用标准的灰色 bg-muted/50 */} +
+ + {t('inputLabel')} + + {t('charCount', { count: html.length })}
@@ -106,25 +135,28 @@ export default function HtmlToMarkdownPage() { value={html} onChange={(e) => setHtml(e.target.value)} placeholder={t('inputPlaceholder')} - className="flex-1 min-h-[400px] p-4 font-mono text-[0.85rem] leading-relaxed resize-none focus:outline-none" + className="flex-1 min-h-[380px] p-4 bg-transparent font-mono text-xs leading-relaxed resize-none focus:outline-none text-foreground/90 select-text" />
)} - {/* Markdown 输出区 */} + {/* Markdown 输出端卡片面板 */} {showOutput && ( -
-
- +
+
+ {(previewMode as string) === 'markdown' ? t('markdownOutputLabel') : t('previewLabel')} -
- +
+ {t('charCount', { count: result.markdownLength })} - +
@@ -132,12 +164,14 @@ export default function HtmlToMarkdownPage() {