|
@@ -12,7 +12,7 @@ import AiTranslate from "../ai/AiTranslate";
|
|
|
|
|
|
|
|
const { Title, Text } = Typography;
|
|
const { Title, Text } = Typography;
|
|
|
|
|
|
|
|
-interface IFtsData {
|
|
|
|
|
|
|
+export interface IFtsData {
|
|
|
rank?: number;
|
|
rank?: number;
|
|
|
highlight?: string;
|
|
highlight?: string;
|
|
|
book: number;
|
|
book: number;
|
|
@@ -23,7 +23,7 @@ interface IFtsData {
|
|
|
paliTitle?: string;
|
|
paliTitle?: string;
|
|
|
path?: ITocPathNode[];
|
|
path?: ITocPathNode[];
|
|
|
}
|
|
}
|
|
|
-interface IFtsResponse {
|
|
|
|
|
|
|
+export interface IFtsResponse {
|
|
|
ok: boolean;
|
|
ok: boolean;
|
|
|
message: string;
|
|
message: string;
|
|
|
data: {
|
|
data: {
|
|
@@ -31,7 +31,7 @@ interface IFtsResponse {
|
|
|
count: number;
|
|
count: number;
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
-interface IFtsItem {
|
|
|
|
|
|
|
+export interface IFtsItem {
|
|
|
book: number;
|
|
book: number;
|
|
|
paragraph: number;
|
|
paragraph: number;
|
|
|
title?: string;
|
|
title?: string;
|
|
@@ -43,51 +43,29 @@ interface IFtsItem {
|
|
|
|
|
|
|
|
export type ISearchView = "pali" | "title" | "page" | "number";
|
|
export type ISearchView = "pali" | "title" | "page" | "number";
|
|
|
interface IWidget {
|
|
interface IWidget {
|
|
|
- keyWord?: string;
|
|
|
|
|
- keyWords?: string[];
|
|
|
|
|
- engin?: "wbw" | "tulip";
|
|
|
|
|
- tags?: string[];
|
|
|
|
|
- bookId?: string | null;
|
|
|
|
|
- book?: number;
|
|
|
|
|
- para?: number;
|
|
|
|
|
- bold?: string | null;
|
|
|
|
|
- orderBy?: string | null;
|
|
|
|
|
- match?: string | null;
|
|
|
|
|
- keyWord2?: string;
|
|
|
|
|
view?: ISearchView;
|
|
view?: ISearchView;
|
|
|
- pageType?: string;
|
|
|
|
|
|
|
+ ftsData?: IFtsItem[];
|
|
|
|
|
+ total?: number;
|
|
|
|
|
+ loading: boolean;
|
|
|
|
|
+ currPage: number;
|
|
|
|
|
+ onChange?: (page: number, pageSize: number) => void;
|
|
|
}
|
|
}
|
|
|
const FullTxtSearchResultWidget = ({
|
|
const FullTxtSearchResultWidget = ({
|
|
|
- keyWord,
|
|
|
|
|
- keyWords,
|
|
|
|
|
- engin = "wbw",
|
|
|
|
|
- tags,
|
|
|
|
|
- bookId,
|
|
|
|
|
- book,
|
|
|
|
|
- para,
|
|
|
|
|
- orderBy,
|
|
|
|
|
- match,
|
|
|
|
|
- bold,
|
|
|
|
|
- keyWord2,
|
|
|
|
|
- view = "pali",
|
|
|
|
|
- pageType,
|
|
|
|
|
|
|
+ view,
|
|
|
|
|
+ ftsData,
|
|
|
|
|
+ total,
|
|
|
|
|
+ loading = false,
|
|
|
|
|
+ currPage = 1,
|
|
|
|
|
+ onChange,
|
|
|
}: IWidget) => {
|
|
}: IWidget) => {
|
|
|
- const [ftsData, setFtsData] = useState<IFtsItem[]>();
|
|
|
|
|
- const [total, setTotal] = useState<number>();
|
|
|
|
|
- const [loading, setLoading] = useState(false);
|
|
|
|
|
- const [currPage, setCurrPage] = useState<number>(1);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ /*
|
|
|
useEffect(
|
|
useEffect(
|
|
|
() => setCurrPage(1),
|
|
() => setCurrPage(1),
|
|
|
[view, keyWord, keyWords, tags, bookId, match, pageType, bold]
|
|
[view, keyWord, keyWords, tags, bookId, match, pageType, bold]
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
- /**
|
|
|
|
|
- * 搜索引擎选择逻辑
|
|
|
|
|
- * 如果 keyWord 包涵空格 使用 tulip
|
|
|
|
|
- * 如果 keyWord 不包涵空格 使用 wbw
|
|
|
|
|
- */
|
|
|
|
|
|
|
+
|
|
|
let words;
|
|
let words;
|
|
|
let api = "";
|
|
let api = "";
|
|
|
if (keyWord?.trim().includes(" ")) {
|
|
if (keyWord?.trim().includes(" ")) {
|
|
@@ -140,6 +118,7 @@ const FullTxtSearchResultWidget = ({
|
|
|
});
|
|
});
|
|
|
setFtsData(result);
|
|
setFtsData(result);
|
|
|
setTotal(json.data.count);
|
|
setTotal(json.data.count);
|
|
|
|
|
+ onFound && onFound(result);
|
|
|
} else {
|
|
} else {
|
|
|
console.error(json.message);
|
|
console.error(json.message);
|
|
|
}
|
|
}
|
|
@@ -157,6 +136,7 @@ const FullTxtSearchResultWidget = ({
|
|
|
view,
|
|
view,
|
|
|
bold,
|
|
bold,
|
|
|
]);
|
|
]);
|
|
|
|
|
+ */
|
|
|
return (
|
|
return (
|
|
|
<List
|
|
<List
|
|
|
style={{ width: "100%" }}
|
|
style={{ width: "100%" }}
|
|
@@ -164,12 +144,10 @@ const FullTxtSearchResultWidget = ({
|
|
|
size="small"
|
|
size="small"
|
|
|
dataSource={ftsData}
|
|
dataSource={ftsData}
|
|
|
pagination={{
|
|
pagination={{
|
|
|
- onChange: (page) => {
|
|
|
|
|
- console.log(page);
|
|
|
|
|
- setCurrPage(page);
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ onChange: onChange,
|
|
|
showQuickJumper: true,
|
|
showQuickJumper: true,
|
|
|
showSizeChanger: false,
|
|
showSizeChanger: false,
|
|
|
|
|
+ current: currPage,
|
|
|
pageSize: 10,
|
|
pageSize: 10,
|
|
|
total: total,
|
|
total: total,
|
|
|
position: "both",
|
|
position: "both",
|