Explorar o código

onSelect 传递选择消息

visuddhinanda %!s(int64=3) %!d(string=hai) anos
pai
achega
edb3584ed8

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

@@ -16,8 +16,9 @@ export interface IComment {
 interface IWidget {
   data: IComment;
   create?: boolean;
+  onSelect?: Function;
 }
-const Widget = ({ data, create = false }: IWidget) => {
+const Widget = ({ data, create = false, onSelect }: IWidget) => {
   const [edit, setEdit] = useState(false);
 
   return (

+ 10 - 3
dashboard/src/components/comment/CommentList.tsx

@@ -6,8 +6,9 @@ import { Link } from "react-router-dom";
 
 interface IWidget {
   data: IComment[];
+  onSelect?: Function;
 }
-const Widget = ({ data }: IWidget) => {
+const Widget = ({ data, onSelect }: IWidget) => {
   return (
     <div>
       <List
@@ -30,9 +31,15 @@ const Widget = ({ data }: IWidget) => {
             <List.Item.Meta
               avatar={<Avatar src="https://joeschmoe.io/api/v1/random" />}
               title={
-                <Link to={`/comment/${item.id}`}>
+                <span
+                  onClick={(e) => {
+                    if (typeof onSelect !== "undefined") {
+                      onSelect(e);
+                    }
+                  }}
+                >
                   {item.title ? item.title : item.content?.slice(0, 20)}
-                </Link>
+                </span>
               }
               description={item.content?.slice(0, 40)}
             />

+ 11 - 2
dashboard/src/components/comment/CommentShow.tsx

@@ -8,8 +8,9 @@ import TimeShow from "../general/TimeShow";
 interface IWidget {
   data: IComment;
   onEdit?: Function;
+  onSelect?: Function;
 }
-const Widget = ({ data, onEdit }: IWidget) => {
+const Widget = ({ data, onEdit, onSelect }: IWidget) => {
   const onClick: MenuProps["onClick"] = (e) => {
     console.log("click ", e);
     switch (e.key) {
@@ -71,7 +72,15 @@ const Widget = ({ data, onEdit }: IWidget) => {
         }
         style={{ width: "auto" }}
       >
-        {data.content}
+        <span
+          onClick={(e) => {
+            if (typeof onSelect !== "undefined") {
+              onSelect();
+            }
+          }}
+        >
+          {data.content}
+        </span>
       </Card>
     </div>
   );

+ 2 - 1
dashboard/src/components/comment/CommentTopicList.tsx

@@ -6,8 +6,9 @@ import { Link } from "react-router-dom";
 
 interface IWidget {
   data: IComment[];
+  onSelect?: Function;
 }
-const Widget = ({ data }: IWidget) => {
+const Widget = ({ data, onSelect }: IWidget) => {
   return (
     <div>
       <List

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

@@ -13,6 +13,7 @@ import { bookMarkColor } from "./WbwDetailBookMark";
 import "./wbw.css";
 import { PaliReal } from "../../../utils";
 import WbwVideoButton from "./WbwVideoButton";
+import ComentBox from "../../comment/ComentBox";
 
 const { Paragraph } = Typography;
 interface IWidget {
@@ -123,7 +124,10 @@ const Widget = ({ data, onSave }: IWidget) => {
           style={{ width: 500 }}
           content={
             <Space>
-              <Button icon={<QuestionOutlined />} size="small" />
+              <ComentBox
+                trigger={<Button icon={<QuestionOutlined />} size="small" />}
+              />
+
               <Button icon={<CommentOutlined />} size="small" />
             </Space>
           }