소스 검색

Merge pull request #2155 from visuddhinanda/agile

支持搜索other_meaning
visuddhinanda 1 년 전
부모
커밋
f42f355a91
3개의 변경된 파일30개의 추가작업 그리고 21개의 파일을 삭제
  1. 28 21
      dashboard/src/components/term/GrammarBook.tsx
  2. 1 0
      dashboard/src/load.ts
  3. 1 0
      dashboard/src/reducers/term-vocabulary.ts

+ 28 - 21
dashboard/src/components/term/GrammarBook.tsx

@@ -62,6 +62,7 @@ const GrammarBookWidget = () => {
       }
       }
     });
     });
   }, []);
   }, []);
+
   useEffect(() => {
   useEffect(() => {
     console.debug("grammar book", searchWord);
     console.debug("grammar book", searchWord);
     if (searchWord && searchWord.length > 0) {
     if (searchWord && searchWord.length > 0) {
@@ -135,7 +136,7 @@ const GrammarBookWidget = () => {
                     item.word.length - keyWord.length - wordBegin;
                     item.word.length - keyWord.length - wordBegin;
                   weight += (1 / (wordRemain + 1)) * 100;
                   weight += (1 / (wordRemain + 1)) * 100;
                 }
                 }
-                const meaningBegin = item.meaning
+                const meaningBegin = (item.meaning + item.other_meaning)
                   .toLocaleLowerCase()
                   .toLocaleLowerCase()
                   .indexOf(keyWord);
                   .indexOf(keyWord);
                 if (meaningBegin >= 0) {
                 if (meaningBegin >= 0) {
@@ -213,26 +214,32 @@ const GrammarBookWidget = () => {
           <List
           <List
             size="small"
             size="small"
             dataSource={result}
             dataSource={result}
-            renderItem={(item) => (
-              <List.Item
-                key={item.term.guid}
-                style={{ cursor: "pointer" }}
-                onClick={() => {
-                  setTermId(item.term.guid);
-                  setTermSearch(undefined);
-                  pushRecent({
-                    title: item.term.word,
-                    description: item.term.meaning,
-                    wordId: item.term.guid,
-                  });
-                }}
-              >
-                <List.Item.Meta
-                  title={item.term.word}
-                  description={item.term.meaning}
-                />
-              </List.Item>
-            )}
+            renderItem={(item) => {
+              const description =
+                item.term.meaning +
+                (item.term.other_meaning ? "," + item.term.other_meaning : "");
+
+              return (
+                <List.Item
+                  key={item.term.guid}
+                  style={{ cursor: "pointer" }}
+                  onClick={() => {
+                    setTermId(item.term.guid);
+                    setTermSearch(undefined);
+                    pushRecent({
+                      title: item.term.word,
+                      description: description,
+                      wordId: item.term.guid,
+                    });
+                  }}
+                >
+                  <List.Item.Meta
+                    title={item.term.word}
+                    description={description}
+                  />
+                </List.Item>
+              );
+            }}
           />
           />
         )}
         )}
       </div>
       </div>

+ 1 - 0
dashboard/src/load.ts

@@ -63,6 +63,7 @@ export const grammarTermFetch = () => {
     }
     }
   );
   );
 };
 };
+
 const init = () => {
 const init = () => {
   get<ISiteInfoResponse | IErrorResponse>("/v2/siteinfo/en").then(
   get<ISiteInfoResponse | IErrorResponse>("/v2/siteinfo/en").then(
     (response) => {
     (response) => {

+ 1 - 0
dashboard/src/reducers/term-vocabulary.ts

@@ -10,6 +10,7 @@ export interface ITerm {
   word: string;
   word: string;
   tag?: string;
   tag?: string;
   meaning: string;
   meaning: string;
+  other_meaning?: string;
 }
 }
 
 
 interface IState {
 interface IState {