diff --git a/package.json b/package.json index ccf86c8..16f8b5d 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.1.0", "private": true, "dependencies": { + "@ant-design/icons": "^5.0.1", "@babel/core": "^7.16.0", "@pmmmwh/react-refresh-webpack-plugin": "^0.5.3", "@svgr/webpack": "^5.5.0", diff --git a/src/api/resource.ts b/src/api/resource.ts index d9212e6..12e284e 100644 --- a/src/api/resource.ts +++ b/src/api/resource.ts @@ -2,7 +2,7 @@ import client from "./internal/httpClient"; export function resourceList( page: number, - size: null, + size: number, sortField: string, sortAlgo: string, name: string, diff --git a/src/compenents/createResourceCategory/index.module.less b/src/compenents/createResourceCategory/index.module.less new file mode 100644 index 0000000..e69de29 diff --git a/src/compenents/createResourceCategory/index.tsx b/src/compenents/createResourceCategory/index.tsx new file mode 100644 index 0000000..6915c21 --- /dev/null +++ b/src/compenents/createResourceCategory/index.tsx @@ -0,0 +1,61 @@ +import { Button, Input, message, Modal } from "antd"; +import { useState } from "react"; +import { resourceCategory } from "../../api"; +import { PlusOutlined } from "@ant-design/icons"; + +interface PropInterface { + type: string; + onUpdate: () => void; +} + +export const CreateResourceCategory = (props: PropInterface) => { + const [showModal, setShowModal] = useState(false); + const [name, setName] = useState(""); + + const confirm = () => { + if (name.length == 0) { + message.error("请输入分类名"); + return; + } + resourceCategory + .storeResourceCategory(props.type, name, 0) + .then(() => { + setName(""); + message.success("分类添加成功"); + setShowModal(false); + props.onUpdate(); + }) + .catch((err) => { + console.log("错误", err); + }); + }; + + return ( + <> + {showModal && ( - { + { setShowModal(false); }} open={showModal} + width="1000px" + maskClosable={false} > -

Some contents...

-

Some contents...

-

Some contents...

-
+ + + <> +
+
图片分类
+
+ { + setRefreshCategories(refreshCategories + 1); + }} + > +
+
+ {categories.length === 0 && ( + + )} + + {categories.map((item) => ( +
{ + setDefaultCid(item.id); + }} + > +
{item.name}
+
+
+
+ ))} + + + + + + + + + + {imageList.length === 0 && ( + + + + )} + + {imageList.map((item) => ( + + + + ))} + + +
+ )} );