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

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

@@ -4,16 +4,39 @@ import { useState } from "react";
 import { IComment } from "./CommentItem";
 import CommentList from "./CommentList";
 
+const defaultData: IComment[] = Array(5)
+  .fill(3)
+  .map((item, id) => {
+    return {
+      id: "dd",
+      content: "评论内容",
+      title: "评论标题" + id,
+      user: {
+        id: "string",
+        nickName: "Visuddhinanda",
+        realName: "Visuddhinanda",
+        avatar: "",
+      },
+    };
+  });
 interface IWidget {
   resId: string;
+  onSelect?: Function;
 }
-const Widget = ({ resId }: IWidget) => {
-  const [data, setData] = useState<IComment[]>([]);
+const Widget = ({ resId, onSelect }: IWidget) => {
+  const [data, setData] = useState<IComment[]>(defaultData);
 
   return (
     <div>
       <Card title="问题列表" extra={<a href="#">More</a>}>
-        <CommentList data={data} />
+        <CommentList
+          onSelect={(e: React.MouseEvent<HTMLSpanElement, MouseEvent>) => {
+            if (typeof onSelect !== "undefined") {
+              onSelect(e);
+            }
+          }}
+          data={data}
+        />
       </Card>
     </div>
   );

+ 17 - 1
dashboard/src/components/comment/CommentTopic.tsx

@@ -5,11 +5,27 @@ import CommentItem, { IComment } from "./CommentItem";
 import CommentTopicList from "./CommentTopicList";
 import CommentTopicHead from "./CommentTopicHead";
 
+const defaultData: IComment[] = Array(5)
+  .fill(3)
+  .map((item, id) => {
+    return {
+      id: "dd",
+      content: "评论内容",
+      title: "评论标题" + id,
+      user: {
+        id: "string",
+        nickName: "Visuddhinanda",
+        realName: "Visuddhinanda",
+        avatar: "",
+      },
+    };
+  });
+
 interface IWidget {
   resId: string;
 }
 const Widget = ({ resId }: IWidget) => {
-  const [childrenData, setChildrenData] = useState<IComment[]>([]);
+  const [childrenData, setChildrenData] = useState<IComment[]>(defaultData);
   const [data, setData] = useState<IComment>();
 
   return (