Просмотр исходного кода

改用querySelectorAll获取句子列表

visuddhinanda 3 лет назад
Родитель
Сommit
d576d36eef

+ 18 - 11
dashboard/src/components/channel/ChannelPickerTable.tsx

@@ -21,7 +21,6 @@ import CopyToModal from "./CopyToModal";
 
 import { useAppSelector } from "../../hooks";
 import { currentUser as _currentUser } from "../../reducers/current-user";
-import { sentenceList } from "../../reducers/sentence";
 
 const { Link } = Typography;
 
@@ -64,7 +63,6 @@ const Widget = ({
   const [showCheckBox, setShowCheckBox] = useState<boolean>(false);
   const user = useAppSelector(_currentUser);
   const ref = useRef<ActionType>();
-  const sentences = useAppSelector(sentenceList);
 
   useEffect(() => {
     if (reload) {
@@ -150,19 +148,21 @@ const Widget = ({
         request={async (params = {}, sorter, filter) => {
           // TODO
           console.log(params, sorter, filter);
-          let url: string = "";
-          if (typeof articleId !== "undefined") {
-            const id = articleId.split("_");
-            const [book, para] = id[0].split("-");
-            url = `/v2/channel-progress?view=user-in-chapter&book=${book}&para=${para}&progress=sent`;
+          const sentElement = document.querySelectorAll(".pcd_sent");
+          let sentList: string[] = [];
+          for (let index = 0; index < sentElement.length; index++) {
+            const element = sentElement[index];
+            const id = element.id.split("_")[1];
+            sentList.push(id);
           }
+          console.log("sentList", sentList);
           const res = await post<IProgressRequest, IApiResponseChannelList>(
-            url,
+            `/v2/channel-progress`,
             {
-              sentence: sentences,
+              sentence: sentList,
             }
           );
-          console.log("data", res.data.rows);
+          console.log("progress data", res.data.rows);
           const items: IItem[] = res.data.rows.map((item, id) => {
             const date = new Date(item.created_at);
             let all: number = 0;
@@ -208,10 +208,17 @@ const Widget = ({
           );
           console.log("user:", user);
           setSelectedRowKeys(selectedRowKeys);
+          const channelData = [
+            ...currChannel,
+            ...progressing,
+            ...myChannel,
+            ...others,
+          ];
+          console.log("channel list ", channelData);
           return {
             total: res.data.count,
             succcess: true,
-            data: [...currChannel, ...progressing, ...myChannel, ...others],
+            data: channelData,
           };
         }}
         rowKey="uid"

+ 15 - 14
dashboard/src/components/channel/ChannelSentDiff.tsx

@@ -187,20 +187,21 @@ const Widget = ({
           开始复制
         </Button>
       </div>
-      <List
-        header={<div>Header</div>}
-        footer={<div>Footer</div>}
-        bordered
-        dataSource={diffData}
-        renderItem={(item) => (
-          <List.Item>
-            <Row style={{ width: "100%" }}>
-              <Col span={12}>{item.srcContent}</Col>
-              <Col span={12}>{item.destContent}</Col>
-            </Row>
-          </List.Item>
-        )}
-      />
+      <div style={{ height: 400, overflowY: "scroll" }}>
+        <List
+          footer={<div style={{ textAlign: "center" }}>到底了</div>}
+          bordered
+          dataSource={diffData}
+          renderItem={(item) => (
+            <List.Item>
+              <Row style={{ width: "100%" }}>
+                <Col span={12}>{item.srcContent}</Col>
+                <Col span={12}>{item.destContent}</Col>
+              </Row>
+            </List.Item>
+          )}
+        />
+      </div>
     </div>
   );
 };