细节优化
This commit is contained in:
@@ -96,8 +96,9 @@ const OtherUserPage: React.FC = () => {
|
||||
nickname: userData.nickname || "",
|
||||
avatar_url: userData.avatar_url || "",
|
||||
join_date: userData.subscribe_time
|
||||
? `${new Date(userData.subscribe_time).getFullYear()}年${new Date(userData.subscribe_time).getMonth() + 1
|
||||
}月加入`
|
||||
? `${new Date(userData.subscribe_time).getFullYear()}年${
|
||||
new Date(userData.subscribe_time).getMonth() + 1
|
||||
}月加入`
|
||||
: "",
|
||||
stats: {
|
||||
following_count: userData.stats?.following_count || 0,
|
||||
@@ -132,35 +133,35 @@ const OtherUserPage: React.FC = () => {
|
||||
}, [user_id]);
|
||||
|
||||
// 分类球局数据(使用 useCallback 包装,避免每次渲染都创建新函数)
|
||||
const classifyGameRecords = useCallback((
|
||||
game_records: GameRecord[]
|
||||
): { notEndGames: GameRecord[]; finishedGames: GameRecord[] } => {
|
||||
const now = new Date().getTime();
|
||||
return game_records.reduce(
|
||||
(result, cur) => {
|
||||
let { end_time } = cur;
|
||||
end_time = end_time.replace(/\s/, "T");
|
||||
new Date(end_time).getTime() > now
|
||||
? result.notEndGames.push(cur)
|
||||
: result.finishedGames.push(cur);
|
||||
return result;
|
||||
},
|
||||
{
|
||||
notEndGames: [] as GameRecord[],
|
||||
finishedGames: [] as GameRecord[],
|
||||
}
|
||||
);
|
||||
}, []);
|
||||
const classifyGameRecords = useCallback(
|
||||
(
|
||||
game_records: GameRecord[]
|
||||
): { notEndGames: GameRecord[]; finishedGames: GameRecord[] } => {
|
||||
const now = new Date().getTime();
|
||||
return game_records.reduce(
|
||||
(result, cur) => {
|
||||
let { end_time } = cur;
|
||||
end_time = end_time.replace(/\s/, "T");
|
||||
new Date(end_time).getTime() > now
|
||||
? result.notEndGames.push(cur)
|
||||
: result.finishedGames.push(cur);
|
||||
return result;
|
||||
},
|
||||
{
|
||||
notEndGames: [] as GameRecord[],
|
||||
finishedGames: [] as GameRecord[],
|
||||
}
|
||||
);
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
// 加载球局数据(使用 useCallback 包装,避免每次渲染都创建新函数)
|
||||
const load_game_data = useCallback(async () => {
|
||||
if (!user_id) return;
|
||||
try {
|
||||
set_loading(true);
|
||||
const games_data = await UserService.get_user_games(
|
||||
user_id,
|
||||
active_tab
|
||||
);
|
||||
const games_data = await UserService.get_user_games(user_id, active_tab);
|
||||
const sorted_games = games_data.sort((a, b) => {
|
||||
return (
|
||||
new Date(a.original_start_time.replace(/\s/, "T")).getTime() -
|
||||
@@ -214,7 +215,9 @@ const OtherUserPage: React.FC = () => {
|
||||
const handle_send_message = useCallback(() => {
|
||||
if (!user_info.id) return;
|
||||
Taro.navigateTo({
|
||||
url: `/mode_user/message/chat/index?user_id=${user_info.id}&nickname=${user_info.nickname || ""}`,
|
||||
url: `/mode_user/message/chat/index?user_id=${user_info.id}&nickname=${
|
||||
user_info.nickname || ""
|
||||
}`,
|
||||
});
|
||||
}, [user_info.id, user_info.nickname]);
|
||||
|
||||
@@ -237,7 +240,11 @@ const OtherUserPage: React.FC = () => {
|
||||
// };
|
||||
|
||||
return (
|
||||
<ScrollView scrollY className="other_user_page" refresherBackground="#FAFAFA">
|
||||
<ScrollView
|
||||
scrollY
|
||||
className="other_user_page"
|
||||
refresherBackground="#FAFAFA"
|
||||
>
|
||||
{/* <CustomNavbar>
|
||||
<View className="navbar_content">
|
||||
<View className="navbar_back" onClick={() => Taro.navigateBack()}>
|
||||
@@ -303,11 +310,11 @@ const OtherUserPage: React.FC = () => {
|
||||
isShowNoData={game_records.length === 0}
|
||||
errorImg="ICON_LIST_EMPTY_CARD"
|
||||
emptyText="暂无球局信息"
|
||||
loadMoreMatches={() => { }}
|
||||
loadMoreMatches={() => {}}
|
||||
collapse={true}
|
||||
style={{ paddingBottom: 0, overflow: "hidden" }}
|
||||
listLoadErrorWrapperHeight="267px"
|
||||
listLoadErrorWidth="100%"
|
||||
listLoadErrorWidth="320px"
|
||||
listLoadErrorHeight="152px"
|
||||
defaultShowNum={3}
|
||||
/>
|
||||
@@ -346,11 +353,11 @@ const OtherUserPage: React.FC = () => {
|
||||
isShowNoData={ended_game_records.length === 0}
|
||||
errorImg="ICON_LIST_EMPTY_CARD"
|
||||
emptyText="暂无球局信息"
|
||||
loadMoreMatches={() => { }}
|
||||
loadMoreMatches={() => {}}
|
||||
collapse={true}
|
||||
style={{ paddingBottom: "90px", overflow: "hidden" }}
|
||||
listLoadErrorWrapperHeight="220px"
|
||||
listLoadErrorWidth="100%"
|
||||
listLoadErrorWidth="320px"
|
||||
listLoadErrorHeight="152px"
|
||||
defaultShowNum={3}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user