Skip to content

Commit 05e12f0

Browse files
committed
fix(ranking): 添加关于实时预测的提示信息
1 parent 70e5603 commit 05e12f0

File tree

4 files changed

+57
-9
lines changed

4 files changed

+57
-9
lines changed

src/content/pages/ranking/App.tsx

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ import {
1616
fetchContestInfo,
1717
selectContestInfo,
1818
fetchMyRank,
19+
selectPreviousRatingUpdateTime,
1920
} from './rankSlice'
2021
import { RealTimePredict } from './RealTimePredict'
2122
import { User } from './utils'
23+
import { format } from 'date-fns'
24+
import { css } from 'styled-components/macro'
2225

2326
const App: FC = () => {
2427
const options = useAppSelector(selectOptions)
@@ -85,6 +88,9 @@ const App: FC = () => {
8588
const contestInfo = useAppSelector(state =>
8689
selectContestInfo(state, param.contestId)
8790
)
91+
const updateTime = useAppSelector(state =>
92+
selectPreviousRatingUpdateTime(state, param.contestId)
93+
)
8894

8995
const showPredictordelta = !!options?.contestRankingPage.ratingPredictor
9096
const showLanguageIcon = !!options?.contestRankingPage.languageIcon
@@ -113,7 +119,7 @@ const App: FC = () => {
113119
)
114120

115121
if (!contestInfo || !rows) return null
116-
122+
console.log(updateTime)
117123
return (
118124
<>
119125
{(showPredictordelta || showNewRating || showOldRating) &&
@@ -144,16 +150,45 @@ const App: FC = () => {
144150
)}
145151
{realTimePredict && (
146152
<th
147-
style={{
148-
border: '2px dashed #ddd',
149-
borderBottomStyle: 'solid',
150-
}}
153+
css={css`
154+
&&&& {
155+
border: 2px dashed #ddd;
156+
border-bottom-style: solid;
157+
}
158+
&&::before {
159+
content: '实时预测';
160+
position: fixed;
161+
transform: translate(-10%, -110%);
162+
background: #fafafa;
163+
padding: 0 5px;
164+
font-size: 12px;
165+
color: #999;
166+
}
167+
`}
151168
>
152169
<Title
153170
showOldRating={showOldRating}
154171
showPredictordelta={showPredictordelta}
155172
showNewRating={showNewRating}
156-
help={<>实时预测,仅供参考</>}
173+
help={
174+
<div>
175+
实时预测,仅供参考,详细说明查看帖子
176+
<a
177+
href="https://leetcode.cn/circle/discuss/0OHPDu/"
178+
target="_blank"
179+
rel="noreferrer"
180+
>
181+
实时预测功能
182+
</a>
183+
<br />
184+
{updateTime
185+
? `当前数据更新时间为:「${format(
186+
new Date(updateTime),
187+
'yyyy-MM-dd HH:mm'
188+
)}」`
189+
: ''}
190+
</div>
191+
}
157192
/>
158193
</th>
159194
)}

src/content/pages/ranking/Title.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ const Content = styled.div`
2929
const Help = ({ content }: { content: string | ReactNode }) => {
3030
return (
3131
<ToolTip
32-
placement="bottom"
33-
arrow={true}
32+
placement="left"
33+
arrow={false}
3434
keep={true}
3535
title={<Content>{content}</Content>}
36+
offset={{ left: 70, top: 40 }}
3637
>
3738
<HelpIcon />
3839
</ToolTip>

src/content/pages/ranking/rankSlice.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,17 @@ export const selectPreviousRatingDataStatus = (
470470
contestSlug?: string
471471
): Status | undefined =>
472472
contestSlug ? state.contestInfos[contestSlug].previous.status : undefined
473+
export const selectPreviousRatingUpdateTime = (
474+
state: RootState,
475+
contestSlug?: string
476+
): number | undefined => {
477+
if (contestSlug && state.contestInfos[contestSlug]) {
478+
console.log(state.contestInfos[contestSlug])
479+
}
480+
return contestSlug
481+
? state.contestInfos[contestSlug]?.previous?.RatingData?.update
482+
: undefined
483+
}
473484
export const selectFetchContestRankingState = (
474485
state: RootState,
475486
contestSlug?: string

src/content/utils/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,8 @@ export type PreviousRatingDataType = {
389389
score: number
390390
finish_time: number
391391
}[]
392-
rankUpdate: number
392+
rankUpdate?: number
393+
update?: number
393394
}
394395

395396
export const getPreviousRatingData = async (

0 commit comments

Comments
 (0)