visuddhinanda 2 лет назад
Родитель
Сommit
fc41959b48
1 измененных файлов с 20 добавлено и 15 удалено
  1. 20 15
      dashboard/src/components/template/SentEdit/SentEditMenu.tsx

+ 20 - 15
dashboard/src/components/template/SentEdit/SentEditMenu.tsx

@@ -2,17 +2,20 @@ import { Button, Dropdown } from "antd";
 import { useState } from "react";
 import { EditOutlined, CopyOutlined, MoreOutlined } from "@ant-design/icons";
 import type { MenuProps } from "antd";
+import { ISentence } from "../SentEdit";
 
-interface ISentEditMenu {
+interface IWidget {
+  data: ISentence;
   children?: React.ReactNode;
   onModeChange?: Function;
   onConvert?: Function;
 }
 const SentEditMenuWidget = ({
+  data,
   children,
   onModeChange,
   onConvert,
-}: ISentEditMenu) => {
+}: IWidget) => {
   const [isHover, setIsHover] = useState(false);
 
   const onClick: MenuProps["onClick"] = (e) => {
@@ -28,24 +31,26 @@ const SentEditMenuWidget = ({
         break;
     }
   };
-  const items = [
+  const items: MenuProps["items"] = [
     {
       key: "timeline",
       label: "时间线",
     },
     {
-      key: "convert",
-      label: "转换格式",
-      children: [
-        {
-          key: "markdown",
-          label: "markdown",
-        },
-        {
-          key: "json",
-          label: "json",
-        },
-      ],
+      type: "divider",
+    },
+    {
+      key: "markdown",
+      label: "Markdown",
+      disabled: data.contentType === "markdown",
+    },
+    {
+      key: "json",
+      label: "Json",
+      disabled: data.contentType === "json",
+    },
+    {
+      type: "divider",
     },
     {
       key: "share",