فهرست منبع

Merge pull request #1476 from visuddhinanda/agile

文章载入后跳转到topic
visuddhinanda 2 سال پیش
والد
کامیت
7ef4a54fcc
2فایلهای تغییر یافته به همراه20 افزوده شده و 12 حذف شده
  1. 7 3
      dashboard/src/components/discussion/DiscussionBox.tsx
  2. 13 9
      dashboard/src/pages/library/article/show.tsx

+ 7 - 3
dashboard/src/components/discussion/DiscussionBox.tsx

@@ -29,9 +29,13 @@ const DiscussionBoxWidget = () => {
   const discussionMessage = useAppSelector(message);
 
   useEffect(() => {
-    if (discussionMessage?.topic) {
-      setChildrenDrawer(true);
-      setTopicId(discussionMessage?.topic);
+    if (discussionMessage) {
+      if (discussionMessage.topic) {
+        setChildrenDrawer(true);
+        setTopicId(discussionMessage.topic);
+      } else {
+        setChildrenDrawer(false);
+      }
     }
   }, [discussionMessage]);
 

+ 13 - 9
dashboard/src/pages/library/article/show.tsx

@@ -38,7 +38,11 @@ import store from "../../../store";
 import { IRecent } from "../../../components/recent/RecentList";
 import { convertToPlain, fullUrl } from "../../../utils";
 import ThemeSelect from "../../../components/general/ThemeSelect";
-import { show } from "../../../reducers/discussion";
+import {
+  IShowDiscussion,
+  show,
+  showAnchor,
+} from "../../../reducers/discussion";
 import { openPanel } from "../../../reducers/right-panel";
 import { TResType } from "../../../components/discussion/DiscussionListCard";
 
@@ -314,14 +318,14 @@ const Widget = () => {
                 const paramComment = searchParams.get("comment");
                 const paramType = searchParams.get("dis_type");
                 if (paramTopic !== null && paramType !== null) {
-                  store.dispatch(
-                    show({
-                      type: "discussion",
-                      topic: paramTopic,
-                      resType: paramType as TResType,
-                      comment: paramComment ? paramComment : undefined,
-                    })
-                  );
+                  const anchorInfo: IShowDiscussion = {
+                    type: "discussion",
+                    topic: paramTopic,
+                    resType: paramType as TResType,
+                    comment: paramComment ? paramComment : undefined,
+                  };
+                  store.dispatch(show(anchorInfo));
+                  store.dispatch(showAnchor(anchorInfo));
                   store.dispatch(openPanel("discussion"));
                 }
               }}