Skip to content

Commit ac98e0a

Browse files
committed
add board option: showMedal
1 parent 9c45dec commit ac98e0a

File tree

6 files changed

+37
-6
lines changed

6 files changed

+37
-6
lines changed

data/test.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -17731,5 +17731,10 @@
1773117731
"duration": 7200000,
1773217732
"penaltyTime": 1200000,
1773317733
"freezeTime": 3600000,
17734-
"name": "Shenyang Warmup Contest"
17734+
"name": "Shenyang Warmup Contest",
17735+
"medal": {
17736+
"gold": 19,
17737+
"silver": 38,
17738+
"bronze": 57
17739+
}
1773517740
}

src/app/Board.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
.focused-team{
88
width: 100%;
9+
position: relative;
910
z-index: 512;
1011
border: 1px solid transparent;
11-
background-color: white;
1212
box-shadow: 0 5px 12px 4px rgba(0, 0, 0, 0.09), 0 -5px 12px 4px rgba(0, 0, 0, 0.09);
1313
transition: box-shadow 0.2s ease-out;
1414
}

src/app/Board.tsx

+15-1
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,20 @@ const Board: React.FC<BoardProps> = ({ data, options }: BoardProps) => {
306306
{state.teamStates.map((team, idx) => {
307307
const isFocused = idx === focusIndex;
308308

309+
let backgroundColor = "white";
310+
if (state.info.medal && options.showMedal) {
311+
const goldLine = state.info.medal.gold;
312+
const silverLine = goldLine + state.info.medal.silver;
313+
const bronzeLine = silverLine + state.info.medal.bronze;
314+
if (idx < goldLine) {
315+
backgroundColor = "#fff9c0";
316+
} else if (idx < silverLine) {
317+
backgroundColor = "#f6f6f6";
318+
} else if (idx < bronzeLine) {
319+
backgroundColor = "#eddccf";
320+
}
321+
}
322+
309323
return (
310324
<table
311325
key={team.info.id}
@@ -317,7 +331,7 @@ const Board: React.FC<BoardProps> = ({ data, options }: BoardProps) => {
317331
<tr
318332
style={{
319333
transform: isFocused ? "perspective(65535px) translateZ(1px)" : undefined,
320-
backgroundColor: isFocused ? "white" : undefined
334+
backgroundColor
321335
}}
322336
>
323337
<td style={{ width: "5%" }}>

src/app/Loader.tsx

+9-3
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ const Loader: React.FC<LoaderProps> = ({ onLoad, onStart }: LoaderProps) => {
5858
const autoReveal = !!form.getFieldValue("autoReveal");
5959
const shiningBeforeReveal = !!form.getFieldValue("shiningBeforeReveal");
6060
const speedFactor = parseFloat(form.getFieldValue("speedFactor"));
61-
onStart({ autoReveal, shiningBeforeReveal, speedFactor });
62-
}, [onStart, form]);
61+
const showMedal = (data?.medal !== undefined) && (!!form.getFieldValue("showMedal"));
62+
onStart({ autoReveal, shiningBeforeReveal, speedFactor, showMedal });
63+
}, [onStart, form, data]);
6364

6465
return (
6566
<Card
@@ -158,7 +159,7 @@ const Loader: React.FC<LoaderProps> = ({ onLoad, onStart }: LoaderProps) => {
158159
</Row>
159160
<Row>
160161
<Form form={form} style={{ width: "100%" }} layout="inline"
161-
initialValues={{ autoReveal: false, shiningBeforeReveal: true, speedFactor: 1 }}
162+
initialValues={{ autoReveal: false, shiningBeforeReveal: true, speedFactor: 1, showMedal: true }}
162163
>
163164
<Form.Item name="autoReveal" label="自动运行" valuePropName="checked">
164165
<Switch />
@@ -169,6 +170,11 @@ const Loader: React.FC<LoaderProps> = ({ onLoad, onStart }: LoaderProps) => {
169170
<Form.Item name="speedFactor" label="速度因子">
170171
<InputNumber min={0.1} max={10} step={0.1} />
171172
</Form.Item>
173+
{data.medal === undefined ? null : (
174+
<Form.Item name="showMedal" label="显示奖牌" valuePropName="checked">
175+
<Switch />
176+
</Form.Item>
177+
)}
172178
</Form>
173179
</Row>
174180
<Row justify="center" style={{ marginTop: "1em" }}>

src/app/dto.ts

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ export interface Contest {
66
penaltyTime: number;
77
freezeTime: number;
88
name: string;
9+
medal?: {
10+
gold: number;
11+
silver: number;
12+
bronze: number;
13+
}
914
}
1015

1116
export interface Problem {

src/app/vo.ts

+1
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,5 @@ export interface BoardOptions {
194194
autoReveal: boolean;
195195
shiningBeforeReveal: boolean;
196196
speedFactor: number;
197+
showMedal: boolean;
197198
}

0 commit comments

Comments
 (0)