Просмотр исходного кода

✨ (dashboard-v6): 字典的社区术语显示摘要(summary_text)而不是 note

摘要都很短,去掉了按字数过滤的门槛,全部列出。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
visuddhinanda 23 часов назад
Родитель
Сommit
ab1d5c8e33
1 измененных файлов с 24 добавлено и 23 удалено
  1. 24 23
      dashboard-v6/src/components/term/TermCommunity.tsx

+ 24 - 23
dashboard-v6/src/components/term/TermCommunity.tsx

@@ -22,7 +22,7 @@ interface IItem<R> {
 }
 }
 interface IWord {
 interface IWord {
   meaning: IItem<string>[];
   meaning: IItem<string>[];
-  note: IItem<string>[];
+  summary: IItem<string>[];
   editor: IItem<IUser>[];
   editor: IItem<IUser>[];
 }
 }
 
 
@@ -33,7 +33,6 @@ const TermCommunityWidget = ({ word }: IWidget) => {
   const intl = useIntl();
   const intl = useIntl();
   const [show, setShow] = useState(false);
   const [show, setShow] = useState(false);
   const [wordData, setWordData] = useState<IWord>();
   const [wordData, setWordData] = useState<IWord>();
-  const minScore = 100; //分数阈值。低于这个分数只显示在弹出菜单中
 
 
   useEffect(() => {
   useEffect(() => {
     if (typeof word === "undefined") {
     if (typeof word === "undefined") {
@@ -43,7 +42,7 @@ const TermCommunityWidget = ({ word }: IWidget) => {
     lookupTerms({ word, per_page: 200 })
     lookupTerms({ word, per_page: 200 })
       .then((json) => {
       .then((json) => {
         const meaning = new Map<string, number>();
         const meaning = new Map<string, number>();
-        const note = new Map<string, number>();
+        const summary = new Map<string, number>();
         const editorId = new Map<string, number>();
         const editorId = new Map<string, number>();
         const editor = new Map<string, IUser>();
         const editor = new Map<string, IUser>();
         for (const it of json.data ?? []) {
         for (const it of json.data ?? []) {
@@ -54,10 +53,14 @@ const TermCommunityWidget = ({ word }: IWidget) => {
             meaning.set(it.meaning, score ? score + currScore : currScore);
             meaning.set(it.meaning, score ? score + currScore : currScore);
           }
           }
 
 
-          if (it.note) {
-            score = note.get(it.note);
-            const noteScore = it.note.length;
-            note.set(it.note, score ? score + noteScore : noteScore);
+          // summary_text:有 summary 用它,没有取正文第一段(后端算好的纯文本)
+          if (it.summary_text) {
+            score = summary.get(it.summary_text);
+            const summaryScore = it.summary_text.length;
+            summary.set(
+              it.summary_text,
+              score ? score + summaryScore : summaryScore,
+            );
           }
           }
 
 
           if (it.editor?.id) {
           if (it.editor?.id) {
@@ -68,7 +71,7 @@ const TermCommunityWidget = ({ word }: IWidget) => {
         }
         }
         const _data: IWord = {
         const _data: IWord = {
           meaning: [],
           meaning: [],
-          note: [],
+          summary: [],
           editor: [],
           editor: [],
         };
         };
         meaning.forEach((value, key) => {
         meaning.forEach((value, key) => {
@@ -77,12 +80,12 @@ const TermCommunityWidget = ({ word }: IWidget) => {
           }
           }
         });
         });
         _data.meaning.sort((a, b) => b.score - a.score);
         _data.meaning.sort((a, b) => b.score - a.score);
-        note.forEach((value, key) => {
+        summary.forEach((value, key) => {
           if (key && key.length > 0) {
           if (key && key.length > 0) {
-            _data.note.push({ value: key, score: value });
+            _data.summary.push({ value: key, score: value });
           }
           }
         });
         });
-        _data.note.sort((a, b) => b.score - a.score);
+        _data.summary.sort((a, b) => b.score - a.score);
 
 
         editorId.forEach((value, key) => {
         editorId.forEach((value, key) => {
           const currEditor = editor.get(key);
           const currEditor = editor.get(key);
@@ -194,19 +197,17 @@ const TermCommunityWidget = ({ word }: IWidget) => {
           ) : undefined}
           ) : undefined}
         </Space>
         </Space>
       </div>
       </div>
-      <div key="note">
+      <div key="summary">
         <Space style={{ flexWrap: "wrap" }}>
         <Space style={{ flexWrap: "wrap" }}>
-          <Text strong>{"note:"}</Text>
-          {wordData?.note
-            .filter((value) => value.score >= minScore)
-            .map((item, id) => {
-              return (
-                <Space key={id}>
-                  {item.value}
-                  <Badge color="geekblue" size="small" count={item.score} />
-                </Space>
-              );
-            })}
+          <Text strong>{"摘要:"}</Text>
+          {wordData?.summary.map((item, id) => {
+            return (
+              <Space key={id}>
+                {item.value}
+                <Badge color="geekblue" size="small" count={item.score} />
+              </Space>
+            );
+          })}
         </Space>
         </Space>
       </div>
       </div>
       <div key="collaborator">
       <div key="collaborator">