visuddhinanda 2 anni fa
parent
commit
0902109fb1
1 ha cambiato i file con 12 aggiunte e 0 eliminazioni
  1. 12 0
      dashboard/src/components/discussion/DiscussionShow.tsx

+ 12 - 0
dashboard/src/components/discussion/DiscussionShow.tsx

@@ -24,6 +24,7 @@ import TimeShow from "../general/TimeShow";
 import Marked from "../general/Marked";
 import { delete_ } from "../../request";
 import { IDeleteResponse } from "../api/Article";
+import { fullUrl } from "../../utils";
 
 const { Text } = Typography;
 
@@ -79,6 +80,17 @@ const DiscussionShowWidget = ({
   const onClick: MenuProps["onClick"] = (e) => {
     console.log("click ", e);
     switch (e.key) {
+      case "copy-link":
+        let url = `/discussion/topic/`;
+        if (data.parent) {
+          url += `${data.parent}#${data.id}`;
+        } else {
+          url += data.id;
+        }
+        navigator.clipboard.writeText(fullUrl(url)).then(() => {
+          message.success("链接地址已经拷贝到剪贴板");
+        });
+        break;
       case "edit":
         if (typeof onEdit !== "undefined") {
           onEdit();