图片素材优化

This commit is contained in:
none
2023-03-06 10:38:10 +08:00
parent a20c1c6090
commit cf9c64e04b
4 changed files with 19 additions and 10 deletions

View File

@@ -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<string>("");
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 (
<>
<Button
type="primary"
onClick={() => {
setShowModal(true);
}}
shape="circle"
icon={<PlusOutlined />}
/>
<Modal
onCancel={() => {
setShowModal(false);
}}
onOk={confirm}
open={showModal}
title="创建分类"
>
<Input
placeholder="请输入分类名"
value={name}
onChange={(e) => {
setName(e.target.value);
}}
/>
</Modal>
</>
);
};