@@ -8,7 +8,7 @@ import React, { useState, useEffect, useCallback, useRef, useMemo, CSSProperties
8
8
import FlipMove from "react-flip-move" ;
9
9
import { StickyContainer , Sticky } from "react-sticky" ;
10
10
import { Transition } from "react-transition-group" ;
11
- import { Tooltip } from "antd" ;
11
+ import { Tooltip , message } from "antd" ;
12
12
13
13
function cvtColor ( state : vo . ProblemStateKind ) : string | undefined {
14
14
if ( state === vo . ProblemStateKind . Passed ) {
@@ -23,6 +23,10 @@ function cvtColor(state: vo.ProblemStateKind): string | undefined {
23
23
return undefined ;
24
24
}
25
25
26
+ function messageInfo ( content : string ) : void {
27
+ void message . info ( { content, className : "info-message" , duration : 0.4 } ) ;
28
+ }
29
+
26
30
interface BoardProps {
27
31
data : dto . Contest ;
28
32
options : vo . BoardOptions ;
@@ -70,12 +74,12 @@ const Board: React.FC<BoardProps> = ({ data, options }: BoardProps) => {
70
74
setHighlightItem ( value ) ;
71
75
72
76
let delay ;
73
- delay = options . shiningBeforeReveal ? 1200 : ( autoReveal ? 400 : 0 ) ;
77
+ delay = options . shiningBeforeReveal ? 600 : ( autoReveal ? 200 : 0 ) ;
74
78
console . log ( "delay" , delay / speedFactor ) ;
75
79
await util . delay ( delay / speedFactor ) ; // wait for shining
76
80
handleNextStep ( ) ;
77
81
78
- delay = autoReveal ? ( value . accepted ? 800 : 300 ) : ( 0 ) ;
82
+ delay = autoReveal ? ( value . accepted ? 500 : 200 ) : ( 0 ) ;
79
83
console . log ( "delay" , delay / speedFactor ) ;
80
84
await util . delay ( delay / speedFactor ) ; // wait for showing result
81
85
@@ -85,7 +89,7 @@ const Board: React.FC<BoardProps> = ({ data, options }: BoardProps) => {
85
89
const curRank = team ?. rank ;
86
90
87
91
if ( prevRank !== curRank ) {
88
- delay = 2000 ;
92
+ delay = vo . FLIP_MOVE_DURATION ;
89
93
console . log ( "delay" , delay / speedFactor ) ;
90
94
await util . delay ( delay / speedFactor ) ; // wait for moving up
91
95
}
@@ -148,28 +152,36 @@ const Board: React.FC<BoardProps> = ({ data, options }: BoardProps) => {
148
152
handleNextStep ( ) ;
149
153
}
150
154
if ( e . key === "p" ) {
151
- setAutoReveal ( a => {
152
- if ( a ) {
153
- console . log ( "disable autoReveal ") ;
154
- } else {
155
- console . log ( "enable autoReveal" ) ;
156
- }
157
- return ! a ;
158
- } ) ;
155
+ if ( autoReveal ) {
156
+ console . log ( "disable autoReveal" ) ;
157
+ messageInfo ( "禁用自动运行 ") ;
158
+ } else {
159
+ console . log ( "enable autoReveal" ) ;
160
+ messageInfo ( "启用自动运行" ) ;
161
+ }
162
+ setAutoReveal ( a => ! a ) ;
159
163
}
160
164
if ( e . key === "+" ) {
161
- const s = speedFactor + 0.1 ;
162
- if ( s > 10 ) { return ; }
165
+ const s = Math . min ( speedFactor + 0.1 , vo . MAX_SPEED_FACTOR ) ;
163
166
setSpeedFactor ( s ) ;
164
167
console . log ( "speedFactor" , s ) ;
168
+ messageInfo ( `速度因子:${ s . toFixed ( 1 ) } ` ) ;
165
169
}
166
170
if ( e . key === "-" ) {
167
- const s = speedFactor - 0.1 ;
168
- if ( s < 0.1 ) { return ; }
171
+ const s = Math . max ( speedFactor - 0.1 , vo . MIN_SPEED_FACTOR ) ;
172
+ setSpeedFactor ( s ) ;
173
+ console . log ( "speedFactor" , s ) ;
174
+ messageInfo ( `速度因子:${ s . toFixed ( 1 ) } ` ) ;
175
+ }
176
+ if ( e . key === "Control" ) {
177
+ let s = speedFactor + 3 ;
178
+ if ( s > vo . MAX_SPEED_FACTOR ) { s -= vo . MAX_SPEED_FACTOR ; }
179
+ if ( s < vo . MIN_SPEED_FACTOR ) { s = vo . MIN_SPEED_FACTOR ; }
169
180
setSpeedFactor ( s ) ;
170
181
console . log ( "speedFactor" , s ) ;
182
+ messageInfo ( `速度因子:${ s . toFixed ( 1 ) } ` ) ;
171
183
}
172
- } , [ handleNextStep , keyLock , speedFactor , state . cursor ] ) ;
184
+ } , [ handleNextStep , keyLock , speedFactor , state . cursor , autoReveal ] ) ;
173
185
174
186
useEffect ( ( ) => {
175
187
document . addEventListener ( "keydown" , handleKeydown ) ;
@@ -299,7 +311,7 @@ const Board: React.FC<BoardProps> = ({ data, options }: BoardProps) => {
299
311
textAlign : "center" ,
300
312
transformStyle : "preserve-3d"
301
313
} }
302
- duration = { 2000 / speedFactor }
314
+ duration = { vo . FLIP_MOVE_DURATION / speedFactor }
303
315
onFinish = { handleMovingFinished }
304
316
>
305
317
0 commit comments