Browse Source

下拉菜单没内容显示空状态

visuddhinanda 2 years ago
parent
commit
5e019bbbac

+ 20 - 2
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,11 +55,29 @@ 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 [
       {
         key: "",
+        disabled: true,
         label: (
           <>
             <LoadingOutlined />{" "}

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

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

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

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