fix: resolve TypeScript errors in redesigned pages

- knowledge-bases: add missing fields to KnowledgeBaseFormValues type
- knowledge-bases: fix null safety for tags array
- knowledge-bases/legal-articles: fix renderStatusTag param types
- legal-articles: add non-null assertion for source_id

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-06-01 18:24:48 +08:00
parent fdbce39019
commit f8dd1e4524
2 changed files with 15 additions and 7 deletions
+11 -4
View File
@@ -58,6 +58,12 @@ const { Title, Text, Paragraph } = Typography;
type KnowledgeBaseFormValues = {
name: string;
description?: string;
note?: string;
source_type?: string;
authority?: string;
effective_date?: string;
region?: string;
tags?: string;
};
type KnowledgeBaseRollbackFormValues = {
@@ -843,9 +849,9 @@ export default function KnowledgeBasesPage() {
) : document.failure_reason ? (
<Text type="danger" style={{ fontSize: 12 }}>{document.failure_reason}</Text>
) : null}
{document.tags?.length > 0 && (
{(document.tags?.length ?? 0) > 0 && (
<Space wrap size={[4, 4]} style={{ marginTop: 4 }}>
{document.tags.slice(0, 5).map((tag) => <Tag key={tag} style={{ fontSize: 11 }}>{tag}</Tag>)}
{(document.tags ?? []).slice(0, 5).map((tag) => <Tag key={tag} style={{ fontSize: 11 }}>{tag}</Tag>)}
</Space>
)}
</div>
@@ -1035,7 +1041,8 @@ export default function KnowledgeBasesPage() {
}
// Helper function for rendering status tags inline
function renderStatusTag(value: string, metaMap: Record<string, { color: string; label: string }>) {
const meta = metaMap[value] ?? { color: "default", label: value || "未知" };
function renderStatusTag(value: string | null | undefined, metaMap: Record<string, { color: string; label: string }>) {
if (!value) return <Tag color="default">未知</Tag>;
const meta = metaMap[value] ?? { color: "default", label: value };
return <Tag color={meta.color}>{meta.label}</Tag>;
}
+4 -3
View File
@@ -92,8 +92,9 @@ function formatHash(value: string | null | undefined) {
return value ? `${value.slice(0, 12)}...` : "-";
}
function renderStatusTag(value: string, metaMap: Record<string, { color: string; label: string }>) {
const meta = metaMap[value] ?? { color: "default", label: value || "未知" };
function renderStatusTag(value: string | null | undefined, metaMap: Record<string, { color: string; label: string }>) {
if (!value) return <Tag color="default">未知</Tag>;
const meta = metaMap[value] ?? { color: "default", label: value };
return <Tag color={meta.color}>{meta.label}</Tag>;
}
@@ -407,7 +408,7 @@ export default function LegalArticlesPage() {
description={item.content ? <Paragraph ellipsis={{ rows: 2 }}>{item.content}</Paragraph> : null}
/>
{item.source_id && (
<Button disabled={!item.source_id} icon={<EyeOutlined />} size="small" onClick={() => void openArticleDetail(item.source_id)}>
<Button disabled={!item.source_id} icon={<EyeOutlined />} size="small" onClick={() => void openArticleDetail(item.source_id!)}>
查看
</Button>
)}