mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-08-20 13:06:58 +08:00
- 将用户可见品牌升级为 TraceMemo(迹忆) - 增加最早期 userData/sessionData 兼容路径选择 - 保留 WechatExplorer runtime identity 以兼容 safeStorage - 继续使用旧 Knowledge、Settings、API Token 和 Provider 配置 - 新日志写入 TraceMemo 目录并保留历史日志 - 保留旧 API、Skill、环境变量和导出目录兼容标识 - 更新相关文档、界面文案与自动化测试
59 lines
1.6 KiB
TypeScript
59 lines
1.6 KiB
TypeScript
import { useMemo, useState, type ReactElement } from 'react'
|
|
|
|
export function SkillPreviewDialog({
|
|
content,
|
|
version,
|
|
onClose
|
|
}: {
|
|
content: string
|
|
version?: string
|
|
onClose: () => void
|
|
}): ReactElement {
|
|
const [raw, setRaw] = useState(false)
|
|
const lines = useMemo(() => content.split('\n'), [content])
|
|
return (
|
|
<div
|
|
className="api-markdown-overlay"
|
|
role="dialog"
|
|
aria-modal="true"
|
|
aria-label="TraceMemo Reader Skill 预览"
|
|
>
|
|
<div>
|
|
<header>
|
|
<div>
|
|
<strong>TraceMemo Reader</strong>
|
|
<span>{version || 'v1.0'}</span>
|
|
</div>
|
|
<div>
|
|
<button type="button" onClick={() => setRaw((current) => !current)}>
|
|
{raw ? '渲染预览' : '原始文本'}
|
|
</button>
|
|
<button type="button" onClick={onClose}>
|
|
关闭
|
|
</button>
|
|
</div>
|
|
</header>
|
|
{raw ? (
|
|
<pre>{content}</pre>
|
|
) : (
|
|
<article className="skill-markdown-preview">
|
|
{lines.map((line, index) =>
|
|
line.startsWith('# ') ? (
|
|
<h1 key={index}>{line.slice(2)}</h1>
|
|
) : line.startsWith('## ') ? (
|
|
<h2 key={index}>{line.slice(3)}</h2>
|
|
) : line.startsWith('- ') ? (
|
|
<li key={index}>{line.slice(2)}</li>
|
|
) : line.startsWith('```') ? null : line ? (
|
|
<p key={index}>{line}</p>
|
|
) : (
|
|
<br key={index} />
|
|
)
|
|
)}
|
|
</article>
|
|
)}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|