优化活动加载更多
This commit is contained in:
@@ -384,11 +384,11 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
|
|||||||
<View className="stats_section">
|
<View className="stats_section">
|
||||||
<View
|
<View
|
||||||
className="stats_container"
|
className="stats_container"
|
||||||
style={{
|
// style={{
|
||||||
marginBottom: `${
|
// marginBottom: `${
|
||||||
collapseProfile && setMarginBottom ? "16px" : "unset"
|
// collapseProfile && setMarginBottom ? "16px" : "unset"
|
||||||
}`,
|
// }`,
|
||||||
}}
|
// }}
|
||||||
>
|
>
|
||||||
<View
|
<View
|
||||||
className="stat_item clickable"
|
className="stat_item clickable"
|
||||||
|
|||||||
@@ -125,29 +125,35 @@ const ListContainer = (props) => {
|
|||||||
|
|
||||||
// 对于没有ntrp等级的用户每个月展示一次, 插在第二个位置后面
|
// 对于没有ntrp等级的用户每个月展示一次, 插在第二个位置后面
|
||||||
function insertEvaluateCard(list) {
|
function insertEvaluateCard(list) {
|
||||||
if (!evaluateFlag) return list;
|
if (!evaluateFlag)
|
||||||
|
return showNumber !== undefined ? list.slice(0, showNumber) : list;
|
||||||
if (!list || list.length === 0) {
|
if (!list || list.length === 0) {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
// 如果最近一个月有测试记录,则不插入 card
|
// 如果最近一个月有测试记录,则不插入 card
|
||||||
if (hasTestInLastMonth) {
|
if (hasTestInLastMonth) {
|
||||||
return list;
|
return showNumber !== undefined ? list.slice(0, showNumber) : list;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list.length <= 2) {
|
if (list.length <= 2) {
|
||||||
return [...list, { type: "evaluateCard" }];
|
return [...list, { type: "evaluateCard" }];
|
||||||
}
|
}
|
||||||
const [item1, item2, ...rest] = list;
|
const [item1, item2, ...rest] = list;
|
||||||
return [item1, item2, { type: "evaluateCard" }, ...rest];
|
return [
|
||||||
|
item1,
|
||||||
|
item2,
|
||||||
|
{ type: "evaluateCard" },
|
||||||
|
...(showNumber !== undefined ? rest.slice(0, defaultShowNum - 2) : rest),
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
const memoizedList = useMemo(
|
const memoizedList = useMemo(
|
||||||
() => insertEvaluateCard(data),
|
() => insertEvaluateCard(data),
|
||||||
[evaluateFlag, data, hasTestInLastMonth]
|
[evaluateFlag, data, hasTestInLastMonth, showNumber]
|
||||||
);
|
);
|
||||||
|
|
||||||
// 渲染列表
|
// 渲染列表
|
||||||
const renderList = (list) => {
|
const renderList = () => {
|
||||||
// 请求数据为空
|
// 请求数据为空
|
||||||
if (isShowNoData) {
|
if (isShowNoData) {
|
||||||
return (
|
return (
|
||||||
@@ -162,8 +168,6 @@ const ListContainer = (props) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
showNumber !== undefined && (list = list.slice(0, showNumber));
|
|
||||||
|
|
||||||
// 渲染数据
|
// 渲染数据
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -181,7 +185,7 @@ const ListContainer = (props) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<View className="listContentWrapper" style={style}>
|
<View className="listContentWrapper" style={style}>
|
||||||
{renderList(data)}
|
{renderList()}
|
||||||
{/* 显示骨架屏 - 只有在 loading 超过 300ms 时才显示 */}
|
{/* 显示骨架屏 - 只有在 loading 超过 300ms 时才显示 */}
|
||||||
{loading && showSkeleton && renderSkeleton()}
|
{loading && showSkeleton && renderSkeleton()}
|
||||||
{/* <View className="recommendTextWrapper">
|
{/* <View className="recommendTextWrapper">
|
||||||
|
|||||||
Reference in New Issue
Block a user