首页优化

This commit is contained in:
禺狨 2023-07-05 10:09:48 +08:00
parent 00b74f5ab0
commit b0b26d8e47

View File

@ -7,6 +7,7 @@ import { useSelector } from "react-redux";
import { useNavigate, useLocation } from "react-router-dom"; import { useNavigate, useLocation } from "react-router-dom";
import { Footer, TabBarFooter, Empty } from "../../components"; import { Footer, TabBarFooter, Empty } from "../../components";
import { CoursesModel } from "./compenents/courses-model"; import { CoursesModel } from "./compenents/courses-model";
import { isEmptyObject } from "../../utils/index";
type LocalUserLearnHourRecordModel = { type LocalUserLearnHourRecordModel = {
[key: number]: UserLearnHourRecordModel; [key: number]: UserLearnHourRecordModel;
@ -74,7 +75,7 @@ const IndexPage = () => {
return; return;
} }
getData(); getData();
}, [tabKey, currentDepId, categoryId]); }, [currentDepId, categoryId]);
const getData = () => { const getData = () => {
setLoading(true); setLoading(true);
@ -127,7 +128,7 @@ const IndexPage = () => {
const getParams = () => { const getParams = () => {
user.coursesCategories().then((res: any) => { user.coursesCategories().then((res: any) => {
const categories = res.data.categories; const categories = res.data.categories;
if (JSON.stringify(categories) !== "{}") { if (!isEmptyObject(categories)) {
const new_arr: any[] = checkArr(categories, 0); const new_arr: any[] = checkArr(categories, 0);
new_arr.unshift({ new_arr.unshift({
key: 0, key: 0,
@ -204,9 +205,16 @@ const IndexPage = () => {
activeKey={tabKey} activeKey={tabKey}
onChange={(key: any) => { onChange={(key: any) => {
setTabKey(key); setTabKey(key);
navigate( setTimeout(() => {
"/?cid=" + categoryId + "&catName=" + categoryText + "&tab=" + key navigate(
); "/?cid=" +
categoryId +
"&catName=" +
categoryText +
"&tab=" +
key
);
}, 250);
}} }}
style={{ style={{
"--fixed-active-line-width": "20px", "--fixed-active-line-width": "20px",