Przeglądaj źródła

:fire: 无用的导入 & add uesEffect dependency

visuddhinanda 3 lat temu
rodzic
commit
26cc3317a6
34 zmienionych plików z 54 dodań i 95 usunięć
  1. 0 1
      dashboard/src/components/anthology/AnthologyTocTree.tsx
  2. 1 6
      dashboard/src/components/anthology/EditableTocTree.tsx
  3. 0 1
      dashboard/src/components/article/AnthologyInfoEdit.tsx
  4. 2 7
      dashboard/src/components/auth/setting/SettingItem.tsx
  5. 1 1
      dashboard/src/components/channel/ChannelPickerTable.tsx
  6. 1 0
      dashboard/src/components/channel/CopyToStep.tsx
  7. 0 2
      dashboard/src/components/comment/CommentEdit.tsx
  8. 1 1
      dashboard/src/components/comment/CommentItem.tsx
  9. 1 1
      dashboard/src/components/comment/CommentList.tsx
  10. 3 3
      dashboard/src/components/comment/CommentListCard.tsx
  11. 1 1
      dashboard/src/components/comment/CommentTopicChildren.tsx
  12. 1 1
      dashboard/src/components/course/CourseList.tsx
  13. 2 2
      dashboard/src/components/course/SelectChannel.tsx
  14. 1 1
      dashboard/src/components/dict/CaseList.tsx
  15. 1 1
      dashboard/src/components/dict/Compound.tsx
  16. 0 2
      dashboard/src/components/dict/Dictionary.tsx
  17. 1 1
      dashboard/src/components/exp/ExpStatisticCard.tsx
  18. 19 18
      dashboard/src/components/general/UiLangSelect.tsx
  19. 2 2
      dashboard/src/components/library/HeadBar.tsx
  20. 1 1
      dashboard/src/components/studio/HeadBar.tsx
  21. 1 5
      dashboard/src/components/template/SentEdit/SentTabButton.tsx
  22. 4 2
      dashboard/src/components/template/SentEdit/SuggestionAdd.tsx
  23. 1 1
      dashboard/src/components/template/Wbw/PaliText.tsx
  24. 1 1
      dashboard/src/components/template/Wbw/WbwCase.tsx
  25. 0 17
      dashboard/src/components/template/Wbw/WbwDetailAttachment.tsx
  26. 1 7
      dashboard/src/components/template/Wbw/WbwDetailBasic.tsx
  27. 1 1
      dashboard/src/components/template/Wbw/WbwFactorMeaning.tsx
  28. 1 1
      dashboard/src/components/template/Wbw/WbwFactors.tsx
  29. 1 1
      dashboard/src/components/template/Wbw/WbwMeaningSelect.tsx
  30. 0 1
      dashboard/src/components/template/Wbw/WbwPali.tsx
  31. 2 2
      dashboard/src/layouts/anonymous/index.tsx
  32. 0 1
      dashboard/src/pages/admin/nissaya-ending/index.tsx
  33. 1 1
      dashboard/src/pages/studio/analysis/list.tsx
  34. 1 1
      dashboard/src/pages/studio/dict/list.tsx

+ 0 - 1
dashboard/src/components/anthology/AnthologyTocTree.tsx

@@ -1,4 +1,3 @@
-import { Key } from "antd/lib/table/interface";
 import { useEffect, useState } from "react";
 import { useNavigate } from "react-router-dom";
 

+ 1 - 6
dashboard/src/components/anthology/EditableTocTree.tsx

@@ -1,8 +1,7 @@
 import { message } from "antd";
-import { Key } from "antd/lib/table/interface";
 import { useEffect, useState } from "react";
 
-import { get, post, put } from "../../request";
+import { get, put } from "../../request";
 import {
   IArticleMapAddResponse,
   IArticleMapListResponse,
@@ -16,7 +15,6 @@ interface IWidget {
 }
 const Widget = ({ anthologyId, onSelect }: IWidget) => {
   const [tocData, setTocData] = useState<ListNodeData[]>([]);
-  const [keys, setKeys] = useState<Key[]>();
 
   useEffect(() => {
     get<IArticleMapListResponse>(
@@ -73,9 +71,6 @@ const Widget = ({ anthologyId, onSelect }: IWidget) => {
             })
             .catch((e) => console.error(e));
         }}
-        onSelect={(selectedKeys: Key[]) => {
-          setKeys(selectedKeys);
-        }}
       />
     </div>
   );

+ 0 - 1
dashboard/src/components/article/AnthologyInfoEdit.tsx

@@ -1,5 +1,4 @@
 import { Form, message } from "antd";
-import { useState } from "react";
 import { useIntl } from "react-intl";
 import { ProForm, ProFormText } from "@ant-design/pro-components";
 import MDEditor from "@uiw/react-md-editor";

+ 2 - 7
dashboard/src/components/auth/setting/SettingItem.tsx

@@ -11,7 +11,7 @@ import { useAppSelector } from "../../../hooks";
 import store from "../../../store";
 import { ISetting } from "./default";
 
-const { Title, Text } = Typography;
+const { Text } = Typography;
 
 interface IWidgetSettingItem {
   data?: ISetting;
@@ -21,12 +21,7 @@ const Widget = ({ data, onChange }: IWidgetSettingItem) => {
   const intl = useIntl();
   const settings: ISettingItem[] | undefined = useAppSelector(settingInfo);
   const [value, setValue] = useState(data?.defaultValue);
-  const title = (
-    <Title level={5}>
-      {data?.label ? intl.formatMessage({ id: data.label }) : ""}
-    </Title>
-  );
-  console.log(data);
+
   useEffect(() => {
     const currSetting = settings?.find((element) => element.key === data?.key);
     if (typeof currSetting !== "undefined") {

+ 1 - 1
dashboard/src/components/channel/ChannelPickerTable.tsx

@@ -11,7 +11,7 @@ import {
 } from "@ant-design/icons";
 
 import { IApiResponseChannelList, IFinal, TChannelType } from "../api/Channel";
-import { get, post } from "../../request";
+import { post } from "../../request";
 import { LockIcon } from "../../assets/icon";
 import StudioName, { IStudio } from "../auth/StudioName";
 import ProgressSvg from "./ProgressSvg";

+ 1 - 0
dashboard/src/components/channel/CopyToStep.tsx

@@ -55,6 +55,7 @@ const Widget = ({
           onSelect={(e: IChannel) => {
             console.log(e);
             setDestChannel(e);
+            setCopyPercent(100);
             next();
           }}
         />

+ 0 - 2
dashboard/src/components/comment/CommentEdit.tsx

@@ -1,14 +1,12 @@
 import { useIntl } from "react-intl";
 import { Button, Card } from "antd";
 import { message } from "antd";
-
 import { ProForm, ProFormTextArea } from "@ant-design/pro-components";
 import { Col, Row, Space } from "antd";
 
 import { IComment } from "./CommentItem";
 import { put } from "../../request";
 import { ICommentRequest, ICommentResponse } from "../api/Comment";
-import Editor from "@uiw/react-md-editor/lib/Editor";
 
 interface IWidget {
   data: IComment;

+ 1 - 1
dashboard/src/components/comment/CommentItem.tsx

@@ -1,4 +1,4 @@
-import { Avatar, Col, Row } from "antd";
+import { Avatar } from "antd";
 import { useState } from "react";
 import { IUser } from "../auth/User";
 import CommentShow from "./CommentShow";

+ 1 - 1
dashboard/src/components/comment/CommentList.tsx

@@ -1,4 +1,4 @@
-import { List, Avatar, Space } from "antd";
+import { List, Space } from "antd";
 import { MessageOutlined } from "@ant-design/icons";
 
 import { IComment } from "./CommentItem";

+ 3 - 3
dashboard/src/components/comment/CommentListCard.tsx

@@ -38,7 +38,7 @@ const Widget = ({
       return newItem;
     });
     setData(newData);
-  }, [changedAnswerCount]);
+  }, [changedAnswerCount, data]);
 
   useEffect(() => {
     let url: string = "";
@@ -77,7 +77,7 @@ const Widget = ({
       .catch((e) => {
         message.error(e.message);
       });
-  }, [resId, topicId]);
+  }, [intl, resId, topicId]);
 
   if (typeof resId === "undefined" && typeof topicId === "undefined") {
     return <div>该资源尚未创建,不能发表讨论。</div>;
@@ -85,7 +85,7 @@ const Widget = ({
 
   return (
     <div>
-      <Card title="讨论" extra={<a href="#">More</a>}>
+      <Card title="讨论" extra={"More"}>
         {data.length > 0 ? (
           <CommentList
             onSelect={(

+ 1 - 1
dashboard/src/components/comment/CommentTopicChildren.tsx

@@ -43,7 +43,7 @@ const Widget = ({ topicId, onItemCountChange }: IWidget) => {
       .catch((e) => {
         message.error(e.message);
       });
-  }, [topicId]);
+  }, [intl, topicId]);
   return (
     <div>
       <List

+ 1 - 1
dashboard/src/components/course/CourseList.tsx

@@ -34,7 +34,7 @@ const Widget = ({ type }: IWidget) => {
         message.error(json.message);
       }
     });
-  }, []);
+  }, [type]);
 
   return (
     <List

+ 2 - 2
dashboard/src/components/course/SelectChannel.tsx

@@ -27,9 +27,9 @@ const Widget = ({
   onOpenChange,
 }: IWidget) => {
   const user = useAppSelector(_currentUser);
-  const { type, id } = useParams(); //url 参数
+  const { id } = useParams(); //url 参数
   const navigate = useNavigate();
-
+  //TODO 从哪里拿到courseId?
   return (
     <ModalForm<{
       channel: string;

+ 1 - 1
dashboard/src/components/dict/CaseList.tsx

@@ -1,4 +1,4 @@
-import { List, Card, Tag, Typography } from "antd";
+import { List, Tag, Typography } from "antd";
 import { useEffect, useState } from "react";
 import { get } from "../../request";
 import { ICaseListResponse } from "../api/Dict";

+ 1 - 1
dashboard/src/components/dict/Compound.tsx

@@ -1,4 +1,4 @@
-import { List, Select, Space, Typography } from "antd";
+import { List, Select, Typography } from "antd";
 import { useEffect, useState } from "react";
 import { get } from "../../request";
 import {

+ 0 - 2
dashboard/src/components/dict/Dictionary.tsx

@@ -1,5 +1,4 @@
 import { useEffect, useState } from "react";
-import { useNavigate } from "react-router-dom";
 import { Layout, Affix, Col, Row } from "antd";
 
 import DictSearch from "./DictSearch";
@@ -14,7 +13,6 @@ interface IWidget {
   onSearch?: Function;
 }
 const Widget = ({ word, compact = false, onSearch }: IWidget) => {
-  const navigate = useNavigate();
   const [split, setSplit] = useState<string>();
   const [wordSearch, setWordSearch] = useState<string>();
   const [container, setContainer] = useState<HTMLDivElement | null>(null);

+ 1 - 1
dashboard/src/components/exp/ExpStatisticCard.tsx

@@ -83,7 +83,7 @@ const Widget = ({ studioName }: IWidget) => {
       <StatisticCard
         statistic={{
           title: "译文",
-          value: translationCount,
+          value: translationPubCount + "/" + translationCount,
           suffix: "句",
         }}
         chart={<ExpPie data={translationPieData} />}

+ 19 - 18
dashboard/src/components/general/UiLangSelect.tsx

@@ -4,28 +4,29 @@ import { useEffect, useState } from "react";
 import { set, get } from "../../locales";
 import { GlobalOutlined } from "@ant-design/icons";
 
+interface IUiLang {
+  key: string;
+  label: string;
+}
+const uiLang: IUiLang[] = [
+  {
+    key: "en-US",
+    label: "English",
+  },
+  {
+    key: "zh-Hans",
+    label: "简体中文",
+  },
+  {
+    key: "zh-Hant",
+    label: "繁体中文",
+  },
+];
+
 const Widget = () => {
   // TODO
   const [curr, setCurr] = useState<string>();
 
-  interface IUiLang {
-    key: string;
-    label: string;
-  }
-  const uiLang: IUiLang[] = [
-    {
-      key: "en-US",
-      label: "English",
-    },
-    {
-      key: "zh-Hans",
-      label: "简体中文",
-    },
-    {
-      key: "zh-Hant",
-      label: "繁体中文",
-    },
-  ];
   const items: MenuProps["items"] = uiLang;
 
   const onClick: MenuProps["onClick"] = ({ key }) => {

+ 2 - 2
dashboard/src/components/library/HeadBar.tsx

@@ -1,6 +1,6 @@
 import { Link } from "react-router-dom";
-import { Layout, Col, Row, Space } from "antd";
-import { FormattedMessage, useIntl } from "react-intl";
+import { Layout, Space } from "antd";
+import { FormattedMessage } from "react-intl";
 import type { MenuProps } from "antd";
 import { Menu } from "antd";
 

+ 1 - 1
dashboard/src/components/studio/HeadBar.tsx

@@ -1,5 +1,5 @@
 import { Link } from "react-router-dom";
-import { Col, Row, Input, Layout, Space } from "antd";
+import { Input, Layout, Space } from "antd";
 
 import img_banner from "../../assets/studio/images/wikipali_banner.svg";
 import UiLangSelect from "../general/UiLangSelect";

+ 1 - 5
dashboard/src/components/template/SentEdit/SentTabButton.tsx

@@ -1,11 +1,7 @@
 import { useIntl } from "react-intl";
 import { Badge, Dropdown } from "antd";
 import type { MenuProps } from "antd";
-import {
-  OneToOneOutlined,
-  LinkOutlined,
-  CalendarOutlined,
-} from "@ant-design/icons";
+import { LinkOutlined, CalendarOutlined } from "@ant-design/icons";
 
 import store from "../../../store";
 import {

+ 4 - 2
dashboard/src/components/template/SentEdit/SuggestionAdd.tsx

@@ -1,5 +1,5 @@
 import { Button } from "antd";
-import { useState } from "react";
+import { useEffect, useState } from "react";
 import { PlusOutlined } from "@ant-design/icons";
 
 import { ISentence } from "../SentEdit";
@@ -12,7 +12,9 @@ interface IWidget {
 const Widget = ({ data, onCreate }: IWidget) => {
   const [isEditMode, setIsEditMode] = useState(false);
   const [sentData, setSentData] = useState<ISentence>(data);
-
+  useEffect(() => {
+    setSentData(data);
+  }, [data]);
   return (
     <>
       <div style={{ display: isEditMode ? "none" : "block" }}>

+ 1 - 1
dashboard/src/components/template/Wbw/PaliText.tsx

@@ -49,7 +49,7 @@ const Widget = ({ text, code = "roman", primary = true }: IWidget) => {
           break;
       }
     }
-  }, [text, settings]);
+  }, [text, settings, code]);
   return text ? <span>{paliText}</span> : <></>;
 };
 

+ 1 - 1
dashboard/src/components/template/Wbw/WbwCase.tsx

@@ -65,7 +65,7 @@ const Widget = ({ data, display, onSplit, onChange }: IWidget) => {
       });
       setItems(menu);
     }
-  }, [inlineDict]);
+  }, [data.word.value, inlineDict, intl]);
   const onClick: MenuProps["onClick"] = (e) => {
     console.log("click ", e);
     if (typeof onChange !== "undefined") {

+ 0 - 17
dashboard/src/components/template/Wbw/WbwDetailAttachment.tsx

@@ -1,4 +1,3 @@
-import { Input, Divider } from "antd";
 import { UploadFile } from "antd/es/upload/interface";
 import { IAttachmentResponse } from "../../api/Attachments";
 import WbwDetailUpload from "./WbwDetailUpload";
@@ -11,22 +10,6 @@ interface IWidget {
   onUpload?: Function;
 }
 const Widget = ({ data, onChange, onUpload }: IWidget) => {
-  const onWordChange = (
-    e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>
-  ) => {
-    console.log("onWordChange:", e.target.value);
-    if (typeof onChange !== "undefined") {
-      onChange({ field: "word", value: e.target.value });
-    }
-  };
-  const onRealChange = (
-    e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>
-  ) => {
-    console.log("onRealChange:", e.target.value);
-    if (typeof onChange !== "undefined") {
-      onChange({ field: "real", value: e.target.value });
-    }
-  };
   return (
     <div>
       <WbwDetailUpload

+ 1 - 7
dashboard/src/components/template/Wbw/WbwDetailBasic.tsx

@@ -1,6 +1,6 @@
 import { useEffect, useState } from "react";
 import { useIntl } from "react-intl";
-import { Divider, Form, Select, Input, Cascader, AutoComplete } from "antd";
+import { Divider, Form, Select, Input, AutoComplete } from "antd";
 import { Collapse } from "antd";
 
 import SelectCase from "../../dict/SelectCase";
@@ -27,12 +27,6 @@ export interface IWordBasic {
   parent?: string;
 }
 
-interface CascaderOption {
-  value: string | number;
-  label: string;
-  children?: CascaderOption[];
-}
-
 interface IWidget {
   data: IWbw;
   onChange?: Function;

+ 1 - 1
dashboard/src/components/template/Wbw/WbwFactorMeaning.tsx

@@ -54,7 +54,7 @@ const Widget = ({ data, display, onChange, factors }: IWidget) => {
       });
       setItems(menu);
     }
-  }, [inlineDict]);
+  }, [data.word.value, inlineDict]);
 
   useEffect(() => {
     if (typeof factors !== "undefined") {

+ 1 - 1
dashboard/src/components/template/Wbw/WbwFactors.tsx

@@ -78,7 +78,7 @@ const Widget = ({ data, display, onChange }: IWidget) => {
       });
       setItems(menu);
     }
-  }, [inlineDict]);
+  }, [data.word.value, inlineDict]);
 
   const onClick: MenuProps["onClick"] = (e) => {
     console.log("click ", e);

+ 1 - 1
dashboard/src/components/template/Wbw/WbwMeaningSelect.tsx

@@ -150,7 +150,7 @@ const Widget = ({ data, onSelect }: IWidget) => {
 
       setParent(mParent);
     }
-  }, [inlineDict]);
+  }, [data.word.value, inlineDict, intl]);
 
   return (
     <div>

+ 0 - 1
dashboard/src/components/template/Wbw/WbwPali.tsx

@@ -16,7 +16,6 @@ import CommentBox from "../../comment/CommentBox";
 import PaliText from "./PaliText";
 import store from "../../../store";
 import { command } from "../../../reducers/command";
-import { IWidgetDict } from "../../dict/DictComponent";
 
 const { Paragraph } = Typography;
 interface IWidget {

+ 2 - 2
dashboard/src/layouts/anonymous/index.tsx

@@ -1,5 +1,5 @@
-import { Outlet, Link } from "react-router-dom";
-import { Col, Layout, Row, Space } from "antd";
+import { Outlet } from "react-router-dom";
+import { Col, Layout, Row } from "antd";
 import UiLangSelect from "../../components/general/UiLangSelect";
 import img_banner from "../../assets/library/images/wikipali_logo_library.svg";
 

+ 0 - 1
dashboard/src/pages/admin/nissaya-ending/index.tsx

@@ -1,7 +1,6 @@
 import { Outlet } from "react-router-dom";
 import { Layout } from "antd";
 import { styleStudioContent } from "../../studio/style";
-import LeftSider from "../../../components/admin/LeftSider";
 
 const { Content } = Layout;
 

+ 1 - 1
dashboard/src/pages/studio/analysis/list.tsx

@@ -1,4 +1,4 @@
-import { Space, Statistic } from "antd";
+import { Space } from "antd";
 import { useParams } from "react-router-dom";
 import Heatmap from "../../../components/exp/Heatmap";
 import ExpStatisticCard from "../../../components/exp/ExpStatisticCard";

+ 1 - 1
dashboard/src/pages/studio/dict/list.tsx

@@ -23,7 +23,7 @@ import {
   IApiResponseDictList,
   IUserDictDeleteRequest,
 } from "../../../components/api/Dict";
-import { delete_, delete_2, get } from "../../../request";
+import { delete_2, get } from "../../../request";
 import { useRef, useState } from "react";
 import DictEdit from "../../../components/dict/DictEdit";
 import { IDeleteResponse } from "../../../components/api/Article";