Selaa lähdekoodia

add dict name

visuddhinanda 2 vuotta sitten
vanhempi
sitoutus
d72492efde

+ 6 - 1
dashboard/src/components/api/Dict.ts

@@ -30,7 +30,11 @@ export interface IDictResponse {
   message: string;
   message: string;
   data: number[];
   data: number[];
 }
 }
-
+export interface IDictInfo {
+  id: string;
+  name: string;
+  shortname: string;
+}
 export interface IApiResponseDictData {
 export interface IApiResponseDictData {
   id: string;
   id: string;
   word: string;
   word: string;
@@ -42,6 +46,7 @@ export interface IApiResponseDictData {
   factors: string;
   factors: string;
   factormean: string;
   factormean: string;
   language: string;
   language: string;
+  dict?: IDictInfo;
   dict_id: string;
   dict_id: string;
   dict_name?: string;
   dict_name?: string;
   dict_shortname?: string;
   dict_shortname?: string;

+ 56 - 45
dashboard/src/components/dict/UserDictList.tsx

@@ -21,6 +21,7 @@ import { ActionType, ProTable } from "@ant-design/pro-components";
 import DictCreate from "../../components/dict/DictCreate";
 import DictCreate from "../../components/dict/DictCreate";
 import {
 import {
   IApiResponseDictList,
   IApiResponseDictList,
+  IDictInfo,
   IUserDictDeleteRequest,
   IUserDictDeleteRequest,
 } from "../../components/api/Dict";
 } from "../../components/api/Dict";
 import { delete_2, get } from "../../request";
 import { delete_2, get } from "../../request";
@@ -40,6 +41,7 @@ export interface IWord {
   meaning: string;
   meaning: string;
   note: string;
   note: string;
   factors: string;
   factors: string;
+  dict?: IDictInfo;
   createdAt: number;
   createdAt: number;
 }
 }
 
 
@@ -178,13 +180,23 @@ const UserDictListWidget = ({ studioName, view = "studio" }: IWidget) => {
             key: "factors",
             key: "factors",
             search: false,
             search: false,
           },
           },
+          {
+            title: intl.formatMessage({
+              id: "forms.fields.dict.shortname.label",
+            }),
+            dataIndex: "dict",
+            key: "dict",
+            search: false,
+            render: (text, row, index, action) => {
+              return row.dict?.shortname;
+            },
+          },
           {
           {
             title: intl.formatMessage({
             title: intl.formatMessage({
               id: "forms.fields.created-at.label",
               id: "forms.fields.created-at.label",
             }),
             }),
             key: "created-at",
             key: "created-at",
             width: 200,
             width: 200,
-
             search: false,
             search: false,
             dataIndex: "createdAt",
             dataIndex: "createdAt",
             valueType: "date",
             valueType: "date",
@@ -193,52 +205,51 @@ const UserDictListWidget = ({ studioName, view = "studio" }: IWidget) => {
           {
           {
             title: intl.formatMessage({ id: "buttons.option" }),
             title: intl.formatMessage({ id: "buttons.option" }),
             key: "option",
             key: "option",
+            hideInTable: view === "all",
             width: 120,
             width: 120,
             valueType: "option",
             valueType: "option",
             render: (text, row, index, action) => {
             render: (text, row, index, action) => {
-              return view === "all"
-                ? undefined
-                : [
-                    <Dropdown.Button
-                      key={index}
-                      type="link"
-                      menu={{
-                        items: [
-                          {
-                            key: "remove",
-                            label: intl.formatMessage({
-                              id: "buttons.delete",
-                            }),
-                            icon: <DeleteOutlined />,
-                            danger: true,
-                          },
-                        ],
-                        onClick: (e) => {
-                          switch (e.key) {
-                            case "share":
-                              break;
-                            case "remove":
-                              showDeleteConfirm([row.wordId], row.word);
-                              break;
-                            default:
-                              break;
-                          }
-                        },
-                      }}
-                    >
-                      <Link
-                        onClick={() => {
-                          setWordId(row.wordId);
-                          setDrawerTitle(row.word);
-                          setIsEditOpen(true);
-                        }}
-                      >
-                        {intl.formatMessage({
-                          id: "buttons.edit",
-                        })}
-                      </Link>
-                    </Dropdown.Button>,
-                  ];
+              return [
+                <Dropdown.Button
+                  key={index}
+                  type="link"
+                  menu={{
+                    items: [
+                      {
+                        key: "remove",
+                        label: intl.formatMessage({
+                          id: "buttons.delete",
+                        }),
+                        icon: <DeleteOutlined />,
+                        danger: true,
+                      },
+                    ],
+                    onClick: (e) => {
+                      switch (e.key) {
+                        case "share":
+                          break;
+                        case "remove":
+                          showDeleteConfirm([row.wordId], row.word);
+                          break;
+                        default:
+                          break;
+                      }
+                    },
+                  }}
+                >
+                  <Link
+                    onClick={() => {
+                      setWordId(row.wordId);
+                      setDrawerTitle(row.word);
+                      setIsEditOpen(true);
+                    }}
+                  >
+                    {intl.formatMessage({
+                      id: "buttons.edit",
+                    })}
+                  </Link>
+                </Dropdown.Button>,
+              ];
             },
             },
           },
           },
         ]}
         ]}
@@ -294,7 +305,6 @@ const UserDictListWidget = ({ studioName, view = "studio" }: IWidget) => {
               }
               }
         }
         }
         request={async (params = {}, sorter, filter) => {
         request={async (params = {}, sorter, filter) => {
-          // TODO
           console.log(params, sorter, filter);
           console.log(params, sorter, filter);
           const offset =
           const offset =
             ((params.current ? params.current : 1) - 1) *
             ((params.current ? params.current : 1) - 1) *
@@ -329,6 +339,7 @@ const UserDictListWidget = ({ studioName, view = "studio" }: IWidget) => {
               meaning: item.mean,
               meaning: item.mean,
               note: item.note,
               note: item.note,
               factors: item.factors,
               factors: item.factors,
+              dict: item.dict,
               createdAt: date.getTime(),
               createdAt: date.getTime(),
             };
             };
           });
           });

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

@@ -70,6 +70,8 @@ const items = {
   "forms.fields.editor.label": "编辑者",
   "forms.fields.editor.label": "编辑者",
   "forms.fields.category.label": "分类",
   "forms.fields.category.label": "分类",
   "forms.fields.match.label": "匹配方式",
   "forms.fields.match.label": "匹配方式",
+  "forms.fields.dict.name.label": "字典名",
+  "forms.fields.dict.shortname.label": "字典名",
 };
 };
 
 
 export default items;
 export default items;