|
@@ -1,3 +1,4 @@
|
|
|
|
|
+import { message } from "antd";
|
|
|
import { useEffect, useState } from "react";
|
|
import { useEffect, useState } from "react";
|
|
|
|
|
|
|
|
import { get } from "../../../request";
|
|
import { get } from "../../../request";
|
|
@@ -11,37 +12,66 @@ interface IWidget {
|
|
|
wordStart: number;
|
|
wordStart: number;
|
|
|
wordEnd: number;
|
|
wordEnd: number;
|
|
|
channel: IChannel;
|
|
channel: IChannel;
|
|
|
|
|
+ reload?: boolean;
|
|
|
|
|
+ onReload?: Function;
|
|
|
}
|
|
}
|
|
|
-const Widget = ({ book, para, wordStart, wordEnd, channel }: IWidget) => {
|
|
|
|
|
|
|
+const Widget = ({
|
|
|
|
|
+ book,
|
|
|
|
|
+ para,
|
|
|
|
|
+ wordStart,
|
|
|
|
|
+ wordEnd,
|
|
|
|
|
+ channel,
|
|
|
|
|
+ reload = false,
|
|
|
|
|
+ onReload,
|
|
|
|
|
+}: IWidget) => {
|
|
|
const [sentData, setSentData] = useState<ISentence[]>([]);
|
|
const [sentData, setSentData] = useState<ISentence[]>([]);
|
|
|
|
|
|
|
|
- useEffect(() => {
|
|
|
|
|
|
|
+ const load = () => {
|
|
|
get<ISuggestionListResponse>(
|
|
get<ISuggestionListResponse>(
|
|
|
`/v2/sentpr?view=sent-info&book=${book}¶=${para}&start=${wordStart}&end=${wordEnd}&channel=${channel.id}`
|
|
`/v2/sentpr?view=sent-info&book=${book}¶=${para}&start=${wordStart}&end=${wordEnd}&channel=${channel.id}`
|
|
|
- ).then((json) => {
|
|
|
|
|
- const newData: ISentence[] = json.data.rows.map((item) => {
|
|
|
|
|
- return {
|
|
|
|
|
- id: item.id,
|
|
|
|
|
- content: item.content,
|
|
|
|
|
- html: item.html,
|
|
|
|
|
- book: item.book,
|
|
|
|
|
- para: item.paragraph,
|
|
|
|
|
- wordStart: item.word_start,
|
|
|
|
|
- wordEnd: item.word_end,
|
|
|
|
|
- editor: item.editor,
|
|
|
|
|
- channel: { name: item.channel.name, id: item.channel.id },
|
|
|
|
|
- updateAt: item.updated_at,
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ )
|
|
|
|
|
+ .then((json) => {
|
|
|
|
|
+ if (json.ok) {
|
|
|
|
|
+ console.log("pr load", json.data.rows);
|
|
|
|
|
+ const newData: ISentence[] = json.data.rows.map((item) => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ id: item.id,
|
|
|
|
|
+ content: item.content,
|
|
|
|
|
+ html: item.html,
|
|
|
|
|
+ book: item.book,
|
|
|
|
|
+ para: item.paragraph,
|
|
|
|
|
+ wordStart: item.word_start,
|
|
|
|
|
+ wordEnd: item.word_end,
|
|
|
|
|
+ editor: item.editor,
|
|
|
|
|
+ channel: { name: item.channel.name, id: item.channel.id },
|
|
|
|
|
+ updateAt: item.updated_at,
|
|
|
|
|
+ };
|
|
|
|
|
+ });
|
|
|
|
|
+ setSentData(newData);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ message.error(json.message);
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .finally(() => {
|
|
|
|
|
+ if (reload && typeof onReload !== "undefined") {
|
|
|
|
|
+ onReload();
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
- setSentData(newData);
|
|
|
|
|
- });
|
|
|
|
|
- }, [book, para, wordStart, wordEnd, channel]);
|
|
|
|
|
|
|
+ };
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ load();
|
|
|
|
|
+ }, []);
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ if (reload) {
|
|
|
|
|
+ load();
|
|
|
|
|
+ }
|
|
|
|
|
+ }, [reload]);
|
|
|
return (
|
|
return (
|
|
|
- <div>
|
|
|
|
|
|
|
+ <>
|
|
|
{sentData.map((item, id) => {
|
|
{sentData.map((item, id) => {
|
|
|
return <SentCell data={item} key={id} isPr={true} />;
|
|
return <SentCell data={item} key={id} isPr={true} />;
|
|
|
})}
|
|
})}
|
|
|
- </div>
|
|
|
|
|
|
|
+ </>
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
|
|
|