mirror of
https://github.com/PlayEdu/backend
synced 2025-12-23 13:29:50 +08:00
图片素材优化
This commit is contained in:
0
src/compenents/create-rs-category/index.module.less
Normal file
0
src/compenents/create-rs-category/index.module.less
Normal file
61
src/compenents/create-rs-category/index.tsx
Normal file
61
src/compenents/create-rs-category/index.tsx
Normal 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>
|
||||
</>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user