分类组件显示当前列表对应分类数量

This commit is contained in:
禺狨
2023-03-15 12:21:33 +08:00
parent 35ea9e8877
commit b54bf7646e
6 changed files with 60 additions and 19 deletions

View File

@@ -44,6 +44,7 @@ export const CoursePage = () => {
const [title, setTitle] = useState<string>("");
const [dep_ids, setDepIds] = useState<any>([]);
const [selLabel, setLabel] = useState<string>("全部视频");
const [categoryCount, setCategoryCount] = useState<any>({});
const items: TabsProps["items"] = [
{
@@ -53,9 +54,14 @@ export const CoursePage = () => {
<div className="float-left">
<TreeCategory
text={"课程"}
categoryCount={categoryCount}
onUpdate={(keys: any, title: any) => {
setCategoryIds(keys);
setLabel(title);
if (typeof title == "string") {
setLabel(title);
} else {
setLabel(title.props.children[0]);
}
}}
/>
</div>
@@ -172,6 +178,7 @@ export const CoursePage = () => {
.then((res: any) => {
setTotal(res.data.total);
setList(res.data.data);
setCategoryCount(res.data.category_count);
setLoading(false);
})
.catch((err: any) => {