Procházet zdrojové kódy

支持拷贝句子链接

visuddhinanda před 2 roky
rodič
revize
df0a00de03

+ 13 - 0
dashboard/src/components/template/SentEdit/SentEditMenu.tsx

@@ -19,6 +19,7 @@ import {
   PasteOutLinedIcon,
   PasteOutLinedIcon,
 } from "../../../assets/icon";
 } from "../../../assets/icon";
 import { useIntl } from "react-intl";
 import { useIntl } from "react-intl";
+import { fullUrl } from "../../../utils";
 
 
 interface IWidget {
 interface IWidget {
   data?: ISentence;
   data?: ISentence;
@@ -58,6 +59,18 @@ const SentEditMenuWidget = ({
       case "timeline":
       case "timeline":
         setTimelineOpen(true);
         setTimelineOpen(true);
         break;
         break;
+      case "copy-link":
+        if (data) {
+          let link = `/article/para/${data.book}-${data.para}?mode=edit`;
+          link += `&book=${data.book}&par=${data.para}`;
+          link += `&channel=${data.channel.id}`;
+
+          link += `&focus=${data.book}-${data.para}-${data.wordStart}-${data.wordEnd}`;
+          navigator.clipboard.writeText(fullUrl(link)).then(() => {
+            message.success("链接地址已经拷贝到剪贴板");
+          });
+        }
+        break;
       default:
       default:
         break;
         break;
     }
     }

+ 19 - 1
dashboard/src/components/template/SentEdit/SentTab.tsx

@@ -1,5 +1,5 @@
 import { useEffect, useState } from "react";
 import { useEffect, useState } from "react";
-import { Badge, Space, Tabs, Typography } from "antd";
+import { Badge, Space, Tabs, Typography, message } from "antd";
 import {
 import {
   TranslationOutlined,
   TranslationOutlined,
   CloseOutlined,
   CloseOutlined,
@@ -17,6 +17,7 @@ import SentMenu from "./SentMenu";
 import { ArticleMode } from "../../article/Article";
 import { ArticleMode } from "../../article/Article";
 import { IResNumber } from "../SentEdit";
 import { IResNumber } from "../SentEdit";
 import SentTabCopy from "./SentTabCopy";
 import SentTabCopy from "./SentTabCopy";
+import { fullUrl } from "../../../utils";
 
 
 const { Text } = Typography;
 const { Text } = Typography;
 
 
@@ -161,6 +162,23 @@ const SentTabWidget = ({
                     onModeChange("wbw");
                     onModeChange("wbw");
                   }
                   }
                   break;
                   break;
+                case "copy-id":
+                  const id = `{{${book}-${para}-${wordStart}-${wordEnd}}}`;
+                  navigator.clipboard.writeText(id).then(() => {
+                    message.success("编号已经拷贝到剪贴板");
+                  });
+                  break;
+                case "copy-link":
+                  let link = `/article/para/${book}-${para}?mode=edit`;
+                  link += `&book=${book}&par=${para}`;
+                  if (channelsId) {
+                    link += `&channel=` + channelsId?.join("_");
+                  }
+                  link += `&focus=${book}-${para}-${wordStart}-${wordEnd}`;
+                  navigator.clipboard.writeText(fullUrl(link)).then(() => {
+                    message.success("链接地址已经拷贝到剪贴板");
+                  });
+                  break;
                 default:
                 default:
                   break;
                   break;
               }
               }