diff --git a/src/components/GamePanel.tsx b/src/components/GamePanel.tsx index c3044bd..aa49fc8 100644 --- a/src/components/GamePanel.tsx +++ b/src/components/GamePanel.tsx @@ -4,6 +4,7 @@ import { Tabs } from "antd"; import { PlayerList } from "./PlayerList"; import { GroupingPrediction } from "./GroupingPrediction"; import { useMemo } from "react"; +import dayjs from "dayjs"; interface Props { title: string; @@ -15,6 +16,14 @@ export const GamePanel: React.FC = props => { const sneckMode = useMemo(() => { return !!props.title?.includes('争霸赛'); }, [props.title]); + const isPassedGame = useMemo(() => { + const match = /(?\d{4})年(?\d{1,2})月(?\d{1,2})/.exec(props.title); + const { year, month, day } = match?.groups ?? {}; + const date = dayjs(`${year}-${month}-${day}`); + console.debug('date %s', date.format('YYYY-MM-DD')); + if (!date.isValid()) return true; + return date.isBefore(dayjs()); + }, []); return ( <> = props => { { key: 'groups', label: '分组预测', - children: + children: ( + + ), }, { key: 'players', diff --git a/src/components/GroupingPrediction.tsx b/src/components/GroupingPrediction.tsx index cfa0cc4..380fc9d 100644 --- a/src/components/GroupingPrediction.tsx +++ b/src/components/GroupingPrediction.tsx @@ -18,6 +18,7 @@ interface CustomPlayer extends Player { interface Props { players?: Player[]; sneckMode: boolean; + isPassedGame: boolean; } enum OrderScore { @@ -27,7 +28,11 @@ enum OrderScore { export const GroupingPrediction: React.FC = props => { const [maxPlayerSize, setMaxPlayerSize] = useState(48); - const [nowScoreGroup, setNowScoreGroup] = useState(OrderScore.当前积分); + const [nowScoreGroup, setNowScoreGroup] = useState( + props.isPassedGame + ? OrderScore.年度积分 + : OrderScore.当前积分 + ); const refactoredPlayers = useMemo(() => { return nowScoreGroup === OrderScore.当前积分 ? props.players?.map(e => ({ ...e,