@@ -13,12 +13,30 @@ type PickedOperation = Pick<
13
13
'notEnoughRating' | 'ratingRatio' | 'ratingLevel' | 'like' | 'dislike'
14
14
>
15
15
16
- const GetLevelDescription = ( operation : PickedOperation ) => {
17
- return `有${ Math . round (
18
- ( operation . like / ( operation . like + operation . dislike ) ) * 100 ,
19
- ) } %的人对本作业点了个赞(${ operation . like } /${
20
- operation . like + operation . dislike
21
- } )`
16
+ const GetLevelDescription : FC < {
17
+ operation : PickedOperation
18
+ layout ?: 'horizontal' | 'vertical'
19
+ } > = ( { operation, layout } ) => {
20
+ return operation . notEnoughRating ? (
21
+ layout === 'vertical' ? (
22
+ < > 还没有足够的评分</ >
23
+ ) : (
24
+ < > 评分不足</ >
25
+ )
26
+ ) : (
27
+ < Tooltip2
28
+ className = "!inline-block !mt-0"
29
+ interactionKind = { Popover2InteractionKind . HOVER }
30
+ content = { `有${ Math . round (
31
+ ( operation . like / ( operation . like + operation . dislike ) ) * 100 ,
32
+ ) } %的人为本作业点了个赞(${ operation . like } /${
33
+ operation . like + operation . dislike
34
+ } )`}
35
+ position = "bottom-left"
36
+ >
37
+ { ratingLevelToString ( operation . ratingLevel ) }
38
+ </ Tooltip2 >
39
+ )
22
40
}
23
41
24
42
export const OperationRating : FC < {
@@ -74,18 +92,7 @@ export const OperationRating: FC<{
74
92
layout === 'horizontal' && ! operation . notEnoughRating && 'mr-1.5' ,
75
93
) }
76
94
>
77
- < Tooltip2
78
- className = "!inline-block !mt-0"
79
- interactionKind = { Popover2InteractionKind . HOVER }
80
- content = { GetLevelDescription ( operation ) }
81
- position = "bottom-left"
82
- >
83
- { operation . notEnoughRating
84
- ? layout === 'vertical'
85
- ? '还没有足够的评分'
86
- : '评分不足'
87
- : ratingLevelToString ( operation . ratingLevel ) }
88
- </ Tooltip2 >
95
+ < GetLevelDescription layout = { layout } operation = { operation } />
89
96
</ div >
90
97
</ div >
91
98
)
0 commit comments