Просмотр исходного кода

Merge pull request #1903 from visuddhinanda/agile

下拉菜单没内容显示空状态
visuddhinanda 2 лет назад
Родитель
Сommit
423ec4ecaf

+ 33 - 3
dashboard/src/components/template/Wbw/WbwCase.tsx

@@ -4,7 +4,7 @@ import { Typography, Button, Space } from "antd";
 import { SwapOutlined } from "@ant-design/icons";
 import type { MenuProps } from "antd";
 import { Dropdown } from "antd";
-import { LoadingOutlined } from "@ant-design/icons";
+import { LoadingOutlined, FileExclamationOutlined } from "@ant-design/icons";
 
 import { IWbw, TWbwDisplayMode } from "./WbwWord";
 import "./wbw.css";
@@ -55,9 +55,39 @@ export const caseInDict = (
       });
       return { key: item, label: noNull.join(" ") };
     });
-    return menu;
+    if (menu.length > 0) {
+      return menu;
+    } else {
+      return [
+        {
+          key: "",
+          disabled: true,
+          label: (
+            <>
+              <FileExclamationOutlined />{" "}
+              {intl.formatMessage({
+                id: "labels.empty",
+              })}
+            </>
+          ),
+        },
+      ];
+    }
   } else {
-    return [];
+    return [
+      {
+        key: "",
+        disabled: true,
+        label: (
+          <>
+            <LoadingOutlined />{" "}
+            {intl.formatMessage({
+              id: "labels.loading",
+            })}
+          </>
+        ),
+      },
+    ];
   }
 };
 

+ 28 - 23
dashboard/src/components/template/Wbw/WbwDetailFm.tsx

@@ -1,5 +1,5 @@
 import { useIntl } from "react-intl";
-import { Button, Dropdown, Input, MenuProps, Space } from "antd";
+import { Button, Dropdown, Input, Space, Tooltip } from "antd";
 import { useEffect, useState } from "react";
 import {
   MoreOutlined,
@@ -15,6 +15,7 @@ import store from "../../../store";
 import { lookup } from "../../../reducers/command";
 import { openPanel } from "../../../reducers/right-panel";
 import { ItemType } from "antd/lib/menu/hooks/useItems";
+import { MergeIcon } from "../../../assets/icon";
 
 interface IWFMI {
   pali: string;
@@ -251,28 +252,32 @@ const WbwDetailFmWidget = ({
                   <PlusOutlined key={`icon-${index}`} />
                 ) : (
                   <>
-                    <Button
-                      key="EditOutlined"
-                      size="small"
-                      type="text"
-                      icon={<EditOutlined />}
-                      onClick={() => setFactorInputEnable(true)}
-                    />
-                    <Button
-                      key="CheckOutlined"
-                      size="small"
-                      type="text"
-                      icon={<CheckOutlined />}
-                      onClick={() => {
-                        if (typeof onJoin !== "undefined") {
-                          onJoin(
-                            factorMeaning
-                              .filter((value) => !value.includes("["))
-                              .join(" ")
-                          );
-                        }
-                      }}
-                    />
+                    <Tooltip title="在文本框中编辑">
+                      <Button
+                        key="EditOutlined"
+                        size="small"
+                        type="text"
+                        icon={<EditOutlined />}
+                        onClick={() => setFactorInputEnable(true)}
+                      />
+                    </Tooltip>
+                    <Tooltip title="合并后替换含义">
+                      <Button
+                        key="CheckOutlined"
+                        size="small"
+                        type="text"
+                        icon={<MergeIcon />}
+                        onClick={() => {
+                          if (typeof onJoin !== "undefined") {
+                            onJoin(
+                              factorMeaning
+                                .filter((value) => !value.includes("["))
+                                .join(" ")
+                            );
+                          }
+                        }}
+                      />
+                    </Tooltip>
                   </>
                 )}
               </span>

+ 2 - 0
dashboard/src/locales/en-US/label.ts

@@ -33,6 +33,8 @@ const items = {
   "labels.input": "input",
   "labels.selected": "Selected",
   "labels.page.number.type.c": "Chapter Title",
+  "labels.loading": "loading",
+  "labels.empty": "empty",
 };
 
 export default items;

+ 2 - 0
dashboard/src/locales/zh-Hans/label.ts

@@ -33,6 +33,8 @@ const items = {
   "labels.input": "请输入",
   "labels.selected": "已经选择",
   "labels.page.number.type.c": "章节名称",
+  "labels.loading": "载入中",
+  "labels.empty": "无内容",
 };
 
 export default items;