1
This commit is contained in:
@@ -29,6 +29,7 @@ const ListContainer = (props) => {
|
||||
collapse = false,
|
||||
defaultShowNum,
|
||||
evaluateFlag,
|
||||
enableHomeCards = false, // 仅首页需要 banner 和 NTRP 测评卡片
|
||||
listLoadErrorWrapperHeight,
|
||||
listLoadErrorWidth,
|
||||
listLoadErrorHeight,
|
||||
@@ -94,10 +95,10 @@ const ListContainer = (props) => {
|
||||
};
|
||||
}, []);
|
||||
|
||||
// 获取测试结果,判断最近一个月是否有测试记录
|
||||
// 获取测试结果,判断最近一个月是否有测试记录(仅首页需要)
|
||||
useEffect(() => {
|
||||
const init = async () => {
|
||||
if (!evaluateFlag) return;
|
||||
if (!evaluateFlag || !enableHomeCards) return;
|
||||
// 先等待静默登录完成
|
||||
await waitForAuthInit();
|
||||
// 然后再获取用户信息
|
||||
@@ -112,7 +113,7 @@ const ListContainer = (props) => {
|
||||
}
|
||||
};
|
||||
init();
|
||||
}, [evaluateFlag, userInfo, lastTestResult, fetchLastTestResult]);
|
||||
}, [evaluateFlag, enableHomeCards, userInfo, lastTestResult, fetchLastTestResult]);
|
||||
|
||||
// 从全局状态中获取测试状态
|
||||
const hasTestInLastMonth = lastTestResult?.has_test_in_last_month || false;
|
||||
@@ -169,8 +170,8 @@ const ListContainer = (props) => {
|
||||
}
|
||||
|
||||
const memoizedList = useMemo(
|
||||
() => insertEvaluateCard(data),
|
||||
[evaluateFlag, data, hasTestInLastMonth, showNumber, bannerListImage, bannerDetailImage, bannerListIndex]
|
||||
() => (enableHomeCards ? insertEvaluateCard(data) : data),
|
||||
[enableHomeCards, evaluateFlag, data, hasTestInLastMonth, showNumber, bannerListImage, bannerDetailImage, bannerListIndex]
|
||||
);
|
||||
|
||||
// 渲染 banner 卡片
|
||||
@@ -226,10 +227,10 @@ const ListContainer = (props) => {
|
||||
return (
|
||||
<>
|
||||
{memoizedList.map((match, index) => {
|
||||
if (match?.type === "banner") {
|
||||
if (enableHomeCards && match?.type === "banner") {
|
||||
return renderBanner(match, index);
|
||||
}
|
||||
if (match?.type === "evaluateCard") {
|
||||
if (enableHomeCards && match?.type === "evaluateCard") {
|
||||
return (
|
||||
<NTRPTestEntryCard key={`evaluate-${index}`} type={EvaluateScene.list} />
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user