Browse Source

Merge pull request #1788 from visuddhinanda/agile

修复文章路径无限循环渲染的bug
visuddhinanda 2 years ago
parent
commit
ab07680730

+ 2 - 4
dashboard/src/components/article/ArticleView.tsx

@@ -51,9 +51,7 @@ const ArticleViewWidget = ({
   remains,
   remains,
   onPathChange,
   onPathChange,
 }: IWidgetArticleData) => {
 }: IWidgetArticleData) => {
-  const [currPath, setCurrPath] = useState(path);
-
-  useEffect(() => setCurrPath(path), [path]);
+  console.log("ArticleViewWidget render");
 
 
   let currChannelList = <></>;
   let currChannelList = <></>;
   switch (type) {
   switch (type) {
@@ -90,7 +88,7 @@ const ArticleViewWidget = ({
 
 
       <Space direction="vertical">
       <Space direction="vertical">
         <TocPath
         <TocPath
-          data={currPath}
+          data={path}
           channel={channels}
           channel={channels}
           onChange={(
           onChange={(
             node: ITocPathNode,
             node: ITocPathNode,

+ 1 - 1
dashboard/src/components/corpus/TocPath.tsx

@@ -38,7 +38,7 @@ const TocPathWidget = ({
   const [currData, setCurrData] = useState(data);
   const [currData, setCurrData] = useState(data);
   const navigate = useNavigate();
   const navigate = useNavigate();
   const [searchParams] = useSearchParams();
   const [searchParams] = useSearchParams();
-
+  console.log("TocPathWidget render");
   useEffect(() => setCurrData(data), [data]);
   useEffect(() => setCurrData(data), [data]);
   const fullPath = (
   const fullPath = (
     <Breadcrumb
     <Breadcrumb

+ 2 - 2
dashboard/src/components/template/GroupSelect.tsx

@@ -10,7 +10,7 @@ interface IWidget {
   multiple?: boolean;
   multiple?: boolean;
   hidden?: boolean;
   hidden?: boolean;
 }
 }
-const Widget = ({
+const GroupSelectWidget = ({
   name = "user",
   name = "user",
   multiple = false,
   multiple = false,
   width = "md",
   width = "md",
@@ -50,4 +50,4 @@ const Widget = ({
   );
   );
 };
 };
 
 
-export default Widget;
+export default GroupSelectWidget;

+ 2 - 2
dashboard/src/components/template/MdView.tsx

@@ -11,7 +11,7 @@ interface IWidget {
   convertor?: TCodeConvertor;
   convertor?: TCodeConvertor;
   style?: React.CSSProperties;
   style?: React.CSSProperties;
 }
 }
-const Widget = ({
+const MdViewWidget = ({
   html,
   html,
   className,
   className,
   wordWidget = false,
   wordWidget = false,
@@ -28,4 +28,4 @@ const Widget = ({
   }
   }
 };
 };
 
 
-export default Widget;
+export default MdViewWidget;

+ 2 - 0
dashboard/src/components/template/SentEdit/SentTab.tsx

@@ -72,6 +72,8 @@ const SentTabWidget = ({
   const [currNissayaNum, setCurrNissayaNum] = useState(nissayaNum);
   const [currNissayaNum, setCurrNissayaNum] = useState(nissayaNum);
   const [currCommNum, setCurrCommNum] = useState(commNum);
   const [currCommNum, setCurrCommNum] = useState(commNum);
 
 
+  console.log("SentTabWidget render");
+
   useEffect(() => setIsCompact(compact), [compact]);
   useEffect(() => setIsCompact(compact), [compact]);
   const mPath = path
   const mPath = path
     ? [
     ? [

+ 10 - 10
dashboard/src/components/template/SentRead.tsx

@@ -98,19 +98,19 @@ const SentReadFrame = ({
       <div style={{ flex: "5", color: "#9f3a01" }} ref={boxOrg}>
       <div style={{ flex: "5", color: "#9f3a01" }} ref={boxOrg}>
         {origin?.map((item, id) => {
         {origin?.map((item, id) => {
           return (
           return (
-            <MdView
-              key={id}
-              style={{ color: "brown" }}
-              html={item.html}
-              wordWidget={true}
-              convertor={paliCode1}
-            />
+            <Text key={id}>
+              <MdView
+                style={{ color: "brown" }}
+                html={item.html}
+                wordWidget={true}
+                convertor={paliCode1}
+              />
+            </Text>
           );
           );
         })}
         })}
       </div>
       </div>
       <div style={{ flex: "5" }}>
       <div style={{ flex: "5" }}>
         {translation?.map((item, id) => {
         {translation?.map((item, id) => {
-          if (item.html.indexOf("<hr>") >= 0) console.log(item.html);
           return (
           return (
             <Text key={id}>
             <Text key={id}>
               <MdView html={item.html} />
               <MdView html={item.html} />
@@ -122,10 +122,10 @@ const SentReadFrame = ({
   );
   );
 };
 };
 
 
-interface IWidgetTerm {
+interface IWidget {
   props: string;
   props: string;
 }
 }
-const Widget = ({ props }: IWidgetTerm) => {
+const Widget = ({ props }: IWidget) => {
   const prop = JSON.parse(atob(props)) as IWidgetSentReadFrame;
   const prop = JSON.parse(atob(props)) as IWidgetSentReadFrame;
   return (
   return (
     <>
     <>