Przeglądaj źródła

兼容长文解构信息

luojunhui 4 dni temu
rodzic
commit
a3fbba27f9
3 zmienionych plików z 36 dodań i 82 usunięć
  1. 5 3
      src/api/recall.ts
  2. 12 12
      src/api/types.ts
  3. 19 67
      src/components/RecallResultTable.tsx

+ 5 - 3
src/api/recall.ts

@@ -26,9 +26,11 @@ const EMPTY_RESULT: RecallResultVO = {
  */
 function normalizeRecallResult(data: RecallResultVO | null | undefined): RecallResultVO {
   if (!data) return EMPTY_RESULT
-  const items = data.items.map((it) =>
-    it.id == null && it.materialId ? { ...it, id: it.materialId } : it,
-  )
+  const items = data.items.map((it) => {
+    if (it.id == null && it.materialId) return { ...it, id: it.materialId }
+    if (it.id == null && it.articleId) return { ...it, id: it.articleId }
+    return it
+  })
   return { ...data, items }
 }
 

+ 12 - 12
src/api/types.ts

@@ -80,10 +80,13 @@ export interface VideoDetailDeconstruct {
 
 export interface VideoMatchEnrichedVO {
   /** 内容 ID — 字符串型(可能为长整型/md5 截取等,前端不参与数字运算)
-   *  modality=MATERIAL 时后端 id 为 null,前端在 API 层用 materialId 回填 */
+   *  modality=MATERIAL 时后端 id 为 null,前端在 API 层用 materialId 回填
+   *  modality=ARTICLE 时后端 id 为 null,前端在 API 层用 articleId 回填 */
   id: string
   /** 素材 md5 — modality=MATERIAL 时由后端下发,其余 modality 为 null */
   materialId?: string | null
+  /** 长文 ID — modality=ARTICLE 时由后端下发,其余 modality 为 null */
+  articleId?: string | null
   modality: Modality
   configCode: string | null
   score: number | null
@@ -118,17 +121,14 @@ export interface MaterialDetail {
 
 /** 长文详情 - modality=ARTICLE 专用 */
 export interface ArticleDetail {
-  title?: string
-  summary?: string
-  wordCount?: number
-  channelName?: string
-  channelAccountId?: string
-  channelAccountName?: string
-  readCount?: string
-  likeCount?: string
-  lookingCount?: string
-  htmlUrl?: string
-  publishTime?: string
+  title?: string | null
+  content?: string | null
+  summary?: string | null
+  tags?: string | null
+  cover?: string | null
+  url?: string | null
+  images?: string | null
+  source?: string | null
   deconstruct?: VideoDetailDeconstruct
 }
 

+ 19 - 67
src/components/RecallResultTable.tsx

@@ -467,68 +467,26 @@ export default function RecallResultTable({
   const articleOnlyCols: ColumnsType<RowItem> = [
     {
       title: '来源',
-      key: 'article.channelName',
-      width: 140,
-      render: (_v, item) => textOrDash(item.articleDetail?.channelName),
-    },
-    {
-      title: '作者',
-      key: 'article.channelAccountName',
-      width: 140,
-      render: (_v, item) => textOrDash(item.articleDetail?.channelAccountName),
+      key: 'article.source',
+      width: 120,
+      render: (_v, item) => textOrDash(item.articleDetail?.source ?? undefined),
     },
     {
-      title: '阅读量',
-      key: 'article.readCount',
-      width: 110,
-      align: 'right',
-      onHeaderCell: () => ({ style: METRIC_HEADER_STYLE }),
-      onCell: () => ({ style: METRIC_CELL_STYLE }),
-      sorter: (a, b) => {
-        const av = parseNum(a.articleDetail?.readCount)
-        const bv = parseNum(b.articleDetail?.readCount)
-        if (av == null && bv == null) return 0
-        if (av == null) return 1
-        if (bv == null) return -1
-        return av - bv
-      },
-      sortDirections: ['descend', 'ascend'],
-      render: (_v, item) => (
-        <span style={{ fontVariantNumeric: 'tabular-nums', fontSize: 12 }}>
-          {formatNumber(item.articleDetail?.readCount)}
-        </span>
-      ),
-    },
-    {
-      title: '点赞',
-      key: 'article.likeCount',
-      width: 100,
-      align: 'right',
-      render: (_v, item) => (
-        <span style={{ fontVariantNumeric: 'tabular-nums', fontSize: 12 }}>
-          {formatNumber(item.articleDetail?.likeCount)}
-        </span>
-      ),
-    },
-    {
-      title: '在看',
-      key: 'article.lookingCount',
-      width: 100,
-      align: 'right',
-      render: (_v, item) => (
-        <span style={{ fontVariantNumeric: 'tabular-nums', fontSize: 12 }}>
-          {formatNumber(item.articleDetail?.lookingCount)}
-        </span>
-      ),
-    },
-    {
-      title: '字数',
-      key: 'article.wordCount',
-      width: 90,
-      align: 'right',
+      title: '标签',
+      key: 'article.tags',
+      width: 200,
       render: (_v, item) => {
-        const n = item.articleDetail?.wordCount
-        return <span style={{ fontVariantNumeric: 'tabular-nums', fontSize: 12 }}>{n ?? '--'}</span>
+        const tags = item.articleDetail?.tags
+        if (!tags) return <Text type="secondary">--</Text>
+        return (
+          <Space size={[4, 4]} wrap>
+            {tags.split(',').map((t, i) => (
+              <Tag key={i} color="geekblue" style={{ margin: 0, fontSize: 11 }}>
+                {t.trim()}
+              </Tag>
+            ))}
+          </Space>
+        )
       },
     },
     {
@@ -548,19 +506,13 @@ export default function RecallResultTable({
         )
       },
     },
-    {
-      title: '发布时间',
-      key: 'article.publishTime',
-      width: 150,
-      render: (_v, item) => textOrDash(item.articleDetail?.publishTime),
-    },
     {
       title: '原文',
-      key: 'article.htmlUrl',
+      key: 'article.url',
       width: 80,
       align: 'center',
       render: (_v, item) => {
-        const url = item.articleDetail?.htmlUrl
+        const url = item.articleDetail?.url
         if (!url) return <Text type="secondary">--</Text>
         return (
           <a href={toHttps(url)} target="_blank" rel="noopener noreferrer">