From 4a553c63fc4f1b8bf393f2926c3acc5ea9c66093 Mon Sep 17 00:00:00 2001 From: Ultrame <1019265060@qq.com> Date: Wed, 25 Feb 2026 16:37:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=80=E6=9C=9F=E7=90=83=E5=B1=80=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/user_pages/myself/index.tsx | 50 +++++++++++++++++---------------- src/user_pages/other/index.tsx | 2 +- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/user_pages/myself/index.tsx b/src/user_pages/myself/index.tsx index f339539..ef27250 100644 --- a/src/user_pages/myself/index.tsx +++ b/src/user_pages/myself/index.tsx @@ -16,7 +16,7 @@ import { waitForAuthInit } from "@/utils/authInit"; const MyselfPage: React.FC = () => { const pickerOption = usePickerOption(); - + // 获取页面参数 const instance = Taro.getCurrentInstance(); const user_id = instance.router?.params?.userid || ""; @@ -38,7 +38,7 @@ const MyselfPage: React.FC = () => { // 最近一个月是否有测试记录 const [has_test_in_last_month, setHasTestInLastMonth] = useState(false); - + const { fetchUserInfo } = useUserActions(); // 当前激活的标签页 @@ -89,11 +89,10 @@ const MyselfPage: React.FC = () => { await fetchUserInfo(); } - // 获取测试结果 const res = await evaluateService.getLastResult(); if (res.code === 0) { - console.log( "getLastResult", res.data); + console.log("getLastResult", res.data); setHasTestInLastMonth(res.data.has_test_in_last_month); } }; @@ -110,25 +109,28 @@ const MyselfPage: React.FC = () => { }); // 分类球局数据(使用 useCallback 包装,避免每次渲染都创建新函数) - const classifyGameRecords = useCallback(( - game_records: TennisMatch[] - ): { notEndGames: TennisMatch[]; finishedGames: TennisMatch[] } => { - 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 TennisMatch[], - finishedGames: [] as TennisMatch[], - } - ); - }, []); + const classifyGameRecords = useCallback( + ( + game_records: TennisMatch[] + ): { notEndGames: TennisMatch[]; finishedGames: TennisMatch[] } => { + 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.unshift(cur); + return result; + }, + { + notEndGames: [] as TennisMatch[], + finishedGames: [] as TennisMatch[], + } + ); + }, + [] + ); // 加载球局数据(使用 useCallback 包装,避免每次渲染都创建新函数) const load_game_data = useCallback(async () => { @@ -272,7 +274,7 @@ const MyselfPage: React.FC = () => { {/* 球局列表 */} - + { end_time = end_time.replace(/\s/, "T"); new Date(end_time).getTime() > now ? result.notEndGames.push(cur) - : result.finishedGames.push(cur); + : result.finishedGames.unshift(cur); return result; }, {