chore: 前端代码优化 - ESLint 配置、Prettier 格式化、加载骨架屏、React 组件规范

- 更新 ESLint 配置添加 react-hooks 规则
- 运行 Prettier 格式化所有前端文件
- 为 users、apps、audit、quotas 页面添加 Skeleton 加载骨架屏
- 修复动态组件渲染问题(CategoryIcon/TypeIcon 使用 React.createElement)
- 修复 useRef 渲染期间访问问题(改用 useMemo)
- 修复 effect 中 setState 同步调用问题
- 新增 global-not-found.tsx 404 页面
- 修复 knowledge 页面引号转义问题
This commit is contained in:
selfrelease
2026-06-23 14:43:04 +08:00
parent 6ca1c27162
commit 96b944ac8d
68 changed files with 2182 additions and 1969 deletions
+19 -27
View File
@@ -25,12 +25,8 @@ const mdComponents: Components = {
{children}
</h3>
),
p: ({ children }) => (
<p className="text-sm leading-7 text-foreground/90 my-2">{children}</p>
),
ul: ({ children }) => (
<ul className="my-2 ml-1 space-y-1">{children}</ul>
),
p: ({ children }) => <p className="text-sm leading-7 text-foreground/90 my-2">{children}</p>,
ul: ({ children }) => <ul className="my-2 ml-1 space-y-1">{children}</ul>,
ol: ({ children }) => (
<ol className="my-2 ml-1 space-y-1 list-decimal list-inside">{children}</ol>
),
@@ -50,26 +46,16 @@ const mdComponents: Components = {
<table className="w-full text-sm">{children}</table>
</div>
),
thead: ({ children }) => (
<thead className="bg-primary/5 border-b">{children}</thead>
),
thead: ({ children }) => <thead className="bg-primary/5 border-b">{children}</thead>,
th: ({ children }) => (
<th className="px-3 py-2 text-left text-xs font-semibold text-primary/80 uppercase tracking-wider">
{children}
</th>
),
td: ({ children }) => (
<td className="px-3 py-2 text-sm border-b border-muted">{children}</td>
),
hr: () => (
<hr className="my-4 border-t-2 border-dashed border-primary/10" />
),
strong: ({ children }) => (
<strong className="font-semibold text-foreground">{children}</strong>
),
em: ({ children }) => (
<em className="text-primary/80 not-italic font-medium">{children}</em>
),
td: ({ children }) => <td className="px-3 py-2 text-sm border-b border-muted">{children}</td>,
hr: () => <hr className="my-4 border-t-2 border-dashed border-primary/10" />,
strong: ({ children }) => <strong className="font-semibold text-foreground">{children}</strong>,
em: ({ children }) => <em className="text-primary/80 not-italic font-medium">{children}</em>,
a: ({ href, children }) => {
if (href === "#cite-kb") {
const label = String(children).replace(/^知识库:/, "");
@@ -92,12 +78,15 @@ const mdComponents: Components = {
if (href?.startsWith("#cite-app:")) {
const slug = href.replace("#cite-app:", "");
const appName = String(children);
return (
<AppLinkBadge slug={slug} name={appName} />
);
return <AppLinkBadge slug={slug} name={appName} />;
}
return (
<a href={href} target="_blank" rel="noopener noreferrer" className="text-primary underline underline-offset-2 hover:text-primary/80">
<a
href={href}
target="_blank"
rel="noopener noreferrer"
className="text-primary underline underline-offset-2 hover:text-primary/80"
>
{children}
</a>
);
@@ -204,7 +193,10 @@ function preprocessCitations(content: string, chunks?: Chunk[]): string {
result = result.replace(/^(\s*\>?\s*)AI建议[:]\s*$/gm, "$1[AI建议](#cite-ai)");
// 推荐应用:[[推荐应用:应用名称:slug]] → 可点击跳转链接
result = result.replace(/\[\[推荐应用:([^:]+):([^\]]+)\]\]/g, (_, name, slug) => `[${name}](#cite-app:${slug})`);
result = result.replace(
/\[\[推荐应用:([^:]+):([^\]]+)\]\]/g,
(_, name, slug) => `[${name}](#cite-app:${slug})`,
);
return result;
}
@@ -228,4 +220,4 @@ const GovMarkdown = memo(function GovMarkdown({ content, className, chunks }: Go
);
});
export default GovMarkdown;
export default GovMarkdown;