Skip to content

Commit dde0326

Browse files
committed
fix(ranking): 显示旧分数
1 parent 4bb8979 commit dde0326

File tree

5 files changed

+45
-15
lines changed

5 files changed

+45
-15
lines changed

src/background/utils/lbaoAPI.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const lbaoPredictorApi = (
2727
) =>
2828
users.map((user, i) => ({
2929
...user,
30+
oldRating: data[i]?.old_rating,
3031
delta: data[i]?.delta_rating,
3132
newRating: data[i]?.new_rating,
3233
}))

src/content/pages/ranking/App.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,17 @@ const App: FC = () => {
3333
const showPredictordelta = !!options?.contestRankingPage.ratingPredictor
3434
const showLanguageIcon = !!options?.contestRankingPage.languageIcon
3535
const showNewRating = !!options?.contestRankingPage.showNewRating
36+
const showOldRating = !!options?.contestRankingPage.showOldRating
3637

3738
return (
3839
<>
3940
{(showPredictordelta || showNewRating) && titleRoot && (
4041
<Portal container={titleRoot}>
4142
<th>
4243
<Title
43-
showNewRating={showNewRating}
44+
showOldRating={showOldRating}
4445
showPredictordelta={showPredictordelta}
46+
showNewRating={showNewRating}
4547
/>
4648
</th>
4749
</Portal>
@@ -53,8 +55,9 @@ const App: FC = () => {
5355
<Item
5456
row={i}
5557
hasMyRank={hasMyRank}
56-
showNewRating={showNewRating}
58+
showOldRating={showOldRating}
5759
showPredictordelta={showPredictordelta}
60+
showNewRating={showNewRating}
5861
/>
5962
</td>
6063
</Portal>

src/content/pages/ranking/Item.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ import { ParamType, useGetPredictionQuery } from './rankSlice'
88
type ItmeType = {
99
row: number
1010
hasMyRank: boolean
11-
showNewRating: boolean
11+
showOldRating: boolean
1212
showPredictordelta: boolean
13+
showNewRating: boolean
1314
}
1415

1516
function getParam(): ParamType {
@@ -54,8 +55,9 @@ function useUrlChange() {
5455
const Item: FC<ItmeType> = ({
5556
row,
5657
hasMyRank,
57-
showNewRating,
58+
showOldRating,
5859
showPredictordelta,
60+
showNewRating,
5961
}) => {
6062
const [param] = useUrlChange()
6163
const params: ParamType = { ...param }
@@ -71,9 +73,10 @@ const Item: FC<ItmeType> = ({
7173
}
7274

7375
const predictor: number | undefined = items?.[row]?.delta?.toFixed(1),
74-
newRating = items?.[row]?.newRating?.toFixed(1)
76+
newRating = items?.[row]?.newRating?.toFixed(1),
77+
oldRating = items?.[row]?.oldRating?.toFixed(1)
7578

76-
if (!predictor || !newRating) {
79+
if (predictor === undefined) {
7780
return <></>
7881
}
7982

@@ -83,6 +86,7 @@ const Item: FC<ItmeType> = ({
8386
display: flex;
8487
`}
8588
>
89+
{showOldRating && <div style={{ width: 60 }}>{oldRating}</div>}
8690
{showPredictordelta && (
8791
<div
8892
css={css`

src/content/pages/ranking/Title.tsx

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,26 +51,46 @@ const Help = () => {
5151
}
5252

5353
interface TitleProps {
54-
showNewRating: boolean
54+
showOldRating: boolean
5555
showPredictordelta: boolean
56+
showNewRating: boolean
5657
}
5758

58-
const Title: FC<TitleProps> = ({ showNewRating, showPredictordelta }) => {
59+
const Title: FC<TitleProps> = ({
60+
showNewRating,
61+
showPredictordelta,
62+
showOldRating,
63+
}) => {
5964
return (
6065
<>
6166
<div
6267
style={{
6368
display: 'flex',
6469
}}
6570
>
71+
{showOldRating && (
72+
<div style={{ width: 60 }}>
73+
旧分数{!showPredictordelta && !showNewRating && <Help />}
74+
</div>
75+
)}
6676
{showPredictordelta && (
67-
<div style={{ width: 55 }}>
68-
<span>预测</span>
69-
<Help />
77+
<div
78+
style={{
79+
width: 55,
80+
paddingLeft: showNewRating ? 10 : 0,
81+
}}
82+
>
83+
<span>{showNewRating ? 'Δ' : '预测'}</span>
84+
{!showNewRating && <Help />}
7085
</div>
7186
)}
7287

73-
{showNewRating && <div>新分数{!showPredictordelta && <Help />}</div>}
88+
{showNewRating && (
89+
<div>
90+
新分数
91+
<Help />
92+
</div>
93+
)}
7494
</div>
7595
</>
7696
)

src/options/options.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ export const defaultOptions = {
2121
},
2222
contestRankingPage: {
2323
languageIcon: true,
24+
showOldRating: false,
2425
ratingPredictor: true,
25-
showNewRating: false,
26+
showNewRating: true,
2627
},
2728
}
2829

@@ -50,6 +51,7 @@ export const labelMap: { [key: string]: string } = {
5051
fixBackNav: '修复返回导航',
5152
disableShortcutkey: '禁用快捷键',
5253
languageIcon: '语言图标',
53-
ratingPredictor: '预测积分',
54-
showNewRating: '预测新分数',
54+
showOldRating: '显示旧分数',
55+
ratingPredictor: '显示积分',
56+
showNewRating: '显示新分数',
5557
}

0 commit comments

Comments
 (0)