feat: 增加默认跳转

This commit is contained in:
秋水浮尘
2023-10-15 00:12:03 +08:00
parent a387a61d02
commit 7ba8d52bfe
7 changed files with 97 additions and 81 deletions

View File

@@ -24,7 +24,7 @@ const QuestionBank = () => {
/**
* 获取一级分类数据
* 获取大类分类
*/
const getPrimaryCategoryInfo = () => {
setIsShowSpin(true)
@@ -35,16 +35,34 @@ const QuestionBank = () => {
})
.then((res: Record<string, any>) => {
if (res.data && res.data.length > 0) {
setPromaryCategoryId(res.data[0].primaryCategoryId);
setPromaryCategoryId(res.data[0].id);
setFirstCategoryList(res.data)
setIsShowSpin(false)
} else {
setIsShowSpin(false)
}
})
.catch((err: string) => console.log(err));
.catch((err: string) => {
console.log(err)
}).finally(() => {
setIsShowSpin(false)
})
}
// 获取大类下分类
const getCategoryByPrimary = () => {
req({
method: 'post',
url: apiName.queryCategoryByPrimary,
data: { categoryType: 1, parentId: 1 }
}).then(res => {
console.log(res)
})
}
useEffect(() => {
if (primaryCategoryId) {
getCategoryByPrimary()
}
}, [primaryCategoryId])
/**
* 切换一级分类
* @param {*} e