优化活动加载更多

This commit is contained in:
2025-11-27 15:56:32 +08:00
parent 4f32312209
commit a20490f28d

View File

@@ -43,25 +43,28 @@ const MyselfPageContent: React.FC = () => {
}); });
// 分类球局数据(使用 useCallback 包装,避免每次渲染都创建新函数) // 分类球局数据(使用 useCallback 包装,避免每次渲染都创建新函数)
const classifyGameRecords = useCallback(( const classifyGameRecords = useCallback(
game_records: TennisMatch[] (
): { notEndGames: TennisMatch[]; finishedGames: TennisMatch[] } => { game_records: TennisMatch[]
const now = new Date().getTime(); ): { notEndGames: TennisMatch[]; finishedGames: TennisMatch[] } => {
return game_records.reduce( const now = new Date().getTime();
(result, cur) => { return game_records.reduce(
let { end_time } = cur; (result, cur) => {
end_time = end_time.replace(/\s/, "T"); let { end_time } = cur;
new Date(end_time).getTime() > now end_time = end_time.replace(/\s/, "T");
? result.notEndGames.push(cur) new Date(end_time).getTime() > now
: result.finishedGames.push(cur); ? result.notEndGames.push(cur)
return result; : result.finishedGames.push(cur);
}, return result;
{ },
notEndGames: [] as TennisMatch[], {
finishedGames: [] as TennisMatch[], notEndGames: [] as TennisMatch[],
} finishedGames: [] as TennisMatch[],
); }
}, []); );
},
[]
);
// 使用 useCallback 包装 load_game_data避免每次渲染都创建新函数 // 使用 useCallback 包装 load_game_data避免每次渲染都创建新函数
const load_game_data = useCallback(async () => { const load_game_data = useCallback(async () => {
@@ -144,7 +147,7 @@ const MyselfPageContent: React.FC = () => {
const handleScroll = (event: any) => { const handleScroll = (event: any) => {
const scrollData = event.detail; const scrollData = event.detail;
setCollapseProfile(scrollData.scrollTop > 10); setCollapseProfile(scrollData.scrollTop > 10);
} };
return ( return (
<ScrollView scrollY className={styles.myselfPage} onScroll={handleScroll}> <ScrollView scrollY className={styles.myselfPage} onScroll={handleScroll}>
@@ -162,46 +165,52 @@ const MyselfPageContent: React.FC = () => {
on_follow={handle_follow} on_follow={handle_follow}
onTab={handleOnTab} onTab={handleOnTab}
/> />
{ {!collapseProfile ? (
!collapseProfile ? <View className={styles.quickActionsSection}>
<View className={styles.quickActionsSection}> <View className={styles.actionCard}>
<View className={styles.actionCard}> <View
<View className={styles.actionContent} onClick={handle_game_orders}> className={styles.actionContent}
<Image onClick={handle_game_orders}
className={styles.actionIcon} >
src={require("@/static/userInfo/order_btn.svg")} <Image
/> className={styles.actionIcon}
<Text className={styles.actionText}></Text> src={require("@/static/userInfo/order_btn.svg")}
</View> />
<View className={styles.actionDivider}></View> <Text className={styles.actionText}></Text>
<View className={styles.actionContent} onClick={handle_wallet}>
<Image
className={styles.actionIcon}
src={require("@/static/userInfo/wallet.svg")}
/>
<Text className={styles.actionText}></Text>
</View>
</View> </View>
</View> : <View className={styles.actionDivider}></View>
null <View className={styles.actionContent} onClick={handle_wallet}>
} <Image
className={styles.actionIcon}
src={require("@/static/userInfo/wallet.svg")}
/>
<Text className={styles.actionText}></Text>
</View>
</View>
</View>
) : null}
</View> </View>
<View className={styles.testEntryCardBox}> {!collapseProfile ? (
<NTRPTestEntryCard type={EvaluateScene.user} /> <View className={styles.testEntryCardBox}>
</View> <NTRPTestEntryCard type={EvaluateScene.user} />
</View>
) : null}
<View className={styles.gameTabsSection}> <View className={styles.gameTabsSection}>
<View className={styles.tabContainer}> <View className={styles.tabContainer}>
<View <View
className={`${styles.tabItem} ${active_tab === "hosted" ? styles.active : ""}`} className={`${styles.tabItem} ${
active_tab === "hosted" ? styles.active : ""
}`}
onClick={() => setActiveTab("hosted")} onClick={() => setActiveTab("hosted")}
> >
<Text className={styles.tabText}></Text> <Text className={styles.tabText}></Text>
</View> </View>
<View <View
className={`${styles.tabItem} ${active_tab === "participated" ? styles.active : "" className={`${styles.tabItem} ${
}`} active_tab === "participated" ? styles.active : ""
}`}
onClick={() => setActiveTab("participated")} onClick={() => setActiveTab("participated")}
> >
<Text className={styles.tabText}></Text> <Text className={styles.tabText}></Text>
@@ -222,7 +231,7 @@ const MyselfPageContent: React.FC = () => {
btnImg="ICON_ADD" btnImg="ICON_ADD"
reload={goPublish} reload={goPublish}
isShowNoData={game_records.length === 0} isShowNoData={game_records.length === 0}
loadMoreMatches={() => { }} loadMoreMatches={() => {}}
collapse={true} collapse={true}
style={{ paddingBottom: 0, overflow: "hidden" }} style={{ paddingBottom: 0, overflow: "hidden" }}
listLoadErrorHeight="320px" listLoadErrorHeight="320px"
@@ -241,7 +250,7 @@ const MyselfPageContent: React.FC = () => {
error={null} error={null}
errorImg="ICON_LIST_EMPTY" errorImg="ICON_LIST_EMPTY"
isShowNoData={ended_game_records.length === 0} isShowNoData={ended_game_records.length === 0}
loadMoreMatches={() => { }} loadMoreMatches={() => {}}
collapse={true} collapse={true}
style={{ paddingBottom: "90px", overflow: "hidden" }} style={{ paddingBottom: "90px", overflow: "hidden" }}
listLoadErrorHeight="320px" listLoadErrorHeight="320px"