Răsfoiți Sursa

Merge pull request #1514 from visuddhinanda/agile

添加搜索title支持
visuddhinanda 2 ani în urmă
părinte
comite
76796e37c4

+ 14 - 4
dashboard/src/components/fts/FullSearchInput.tsx

@@ -33,6 +33,7 @@ interface IWidget {
   size?: SizeType;
   width?: string | number;
   searchPage?: boolean;
+  view?: string;
   onSearch?: Function;
   onSplit?: Function;
   onPageTypeChange?: Function;
@@ -44,6 +45,7 @@ const FullSearchInputWidget = ({
   size = "middle",
   width,
   onSearch,
+  view = "pali",
   searchPage = false,
   onPageTypeChange,
 }: IWidget) => {
@@ -71,10 +73,18 @@ const FullSearchInputWidget = ({
     if (value === "") {
       return;
     }
-
-    get<IWordIndexListResponse>(
-      `/v2/pali-word-index?view=key&key=${value}`
-    ).then((json) => {
+    let url: string = "";
+    switch (view) {
+      case "pali":
+        url = `/v2/pali-word-index?view=key&key=${value}`;
+        break;
+      case "title":
+        url = `/v2/search-title-index?&key=${value}`;
+        break;
+      default:
+        break;
+    }
+    get<IWordIndexListResponse>(url).then((json) => {
       const words: ValueType[] = json.data.rows.map((item) => {
         return renderItem(item.word, item.count, item.bold);
       });

+ 2 - 0
dashboard/src/components/fts/FullTextSearchResult.tsx

@@ -4,6 +4,7 @@ import { Link } from "react-router-dom";
 
 import { get } from "../../request";
 import TocPath, { ITocPathNode } from "../corpus/TocPath";
+import { TContentType } from "../discussion/DiscussionCreate";
 import Marked from "../general/Marked";
 import PaliText from "../template/Wbw/PaliText";
 import "./search.css";
@@ -16,6 +17,7 @@ interface IFtsData {
   book: number;
   paragraph: number;
   content?: string;
+  content_type?: TContentType;
   title?: string;
   paliTitle?: string;
   path?: ITocPathNode[];

+ 1 - 0
dashboard/src/pages/library/search/search.tsx

@@ -59,6 +59,7 @@ const Widget = () => {
                     width={"500px"}
                     value={key}
                     searchPage={searchPage}
+                    view={view}
                     tags={searchParams.get("tags")?.split(",")}
                     onSearch={(value: string) => {
                       navigate(`/search/key/${value}`);