Răsfoiți Sursa

Merge pull request #1396 from visuddhinanda/agile

#1389 无社区数据不显示社区词典
visuddhinanda 2 ani în urmă
părinte
comite
48f3978eb7

+ 12 - 2
dashboard/src/components/dict/Community.tsx

@@ -34,6 +34,7 @@ interface IWidget {
 }
 const CommunityWidget = ({ word }: IWidget) => {
   const intl = useIntl();
+  const [loaded, setLoaded] = useState(false);
   const [wordData, setWordData] = useState<IWord>();
   const minScore = 100; //分数阈值。低于这个分数只显示在弹出菜单中
 
@@ -44,7 +45,13 @@ const CommunityWidget = ({ word }: IWidget) => {
     const url = `/v2/userdict?view=community&word=${word}`;
     get<IApiResponseDictList>(url)
       .then((json) => {
-        console.log("community", json.data.rows);
+        if (json.ok === false) {
+          console.log("dict community", json.message);
+          return;
+        }
+        if (json.data.count > 0) {
+          setLoaded(true);
+        }
         let meaning = new Map<string, number>();
         let grammar = new Map<string, number>();
         let parent = new Map<string, number>();
@@ -170,7 +177,8 @@ const CommunityWidget = ({ word }: IWidget) => {
       </Dropdown>
     ) : undefined
   ) : undefined;
-  return (
+
+  return loaded ? (
     <Card>
       <Title level={5} id={`community`}>
         {"社区字典"}
@@ -267,6 +275,8 @@ const CommunityWidget = ({ word }: IWidget) => {
         </Space>
       </div>
     </Card>
+  ) : (
+    <></>
   );
 };
 

+ 1 - 1
dashboard/src/components/template/SentEdit/EditInfo.tsx

@@ -44,7 +44,7 @@ interface IWidget {
   compact?: boolean;
 }
 const EditInfoWidget = ({ data, isPr = false, compact = false }: IWidget) => {
-  console.log("data.createdAt", data.createdAt, data.updateAt);
+  //console.log("data.createdAt", data.createdAt, data.updateAt);
   return (
     <div style={{ fontSize: "80%" }}>
       <Text type="secondary">