首页课程分类选择

This commit is contained in:
禺狨 2023-05-08 18:06:09 +08:00
parent 6985b7a8cc
commit 6b69974e2e

View File

@ -19,6 +19,7 @@ interface Option {
const IndexPage = () => { const IndexPage = () => {
const systemConfig = useSelector((state: any) => state.systemConfig.value); const systemConfig = useSelector((state: any) => state.systemConfig.value);
const [open, setOpen] = useState(false);
const [loading, setLoading] = useState<boolean>(false); const [loading, setLoading] = useState<boolean>(false);
const [tabKey, setTabKey] = useState(0); const [tabKey, setTabKey] = useState(0);
const [coursesList, setCoursesList] = useState<any>([]); const [coursesList, setCoursesList] = useState<any>([]);
@ -51,6 +52,10 @@ const IndexPage = () => {
document.title = systemConfig.systemName || "首页"; document.title = systemConfig.systemName || "首页";
}, [systemConfig]); }, [systemConfig]);
const hide = () => {
setOpen(false);
};
const getData = () => { const getData = () => {
setLoading(true); setLoading(true);
user.courses(currentDepId, categoryId).then((res: any) => { user.courses(currentDepId, categoryId).then((res: any) => {
@ -164,6 +169,11 @@ const IndexPage = () => {
const onSelect = (selectedKeys: any, info: any) => { const onSelect = (selectedKeys: any, info: any) => {
setCategoryId(selectedKeys[0]); setCategoryId(selectedKeys[0]);
setCategoryText(info.node.title); setCategoryText(info.node.title);
hide();
};
const handleOpenChange = (newOpen: boolean) => {
setOpen(newOpen);
}; };
const dropItem = ( const dropItem = (
@ -308,8 +318,15 @@ const IndexPage = () => {
)} )}
</div> </div>
))} ))}
<Popover content={dropItem} placement="bottomRight"> <Popover
<Space className={styles["dropButton"]}> className={styles["dropButton"]}
content={dropItem}
placement="bottomRight"
open={open}
trigger="click"
onOpenChange={handleOpenChange}
>
<Space>
{categoryText} {categoryText}
<i <i
className="iconfont icon-icon-xiala" className="iconfont icon-icon-xiala"