Skip to content

Commit 5fdead7

Browse files
committed
2 parents 822a373 + 3e9b26a commit 5fdead7

File tree

8 files changed

+65
-7
lines changed

8 files changed

+65
-7
lines changed
53.6 KB
Loading
45.1 KB
Loading
54 KB
Loading
56.5 KB
Loading

src/components/OperatorSelect.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ export const OperatorSelect: FC<OperatorSelectProps> = ({
7878
}
7979

8080
const add = (operation: OperatorInfo) => {
81-
change([...new Set([...operators, { name: operation.name }])])
81+
if (!operators.some((op) => op.name === operation.name)) {
82+
change([...operators, { name: operation.name }])
83+
} else {
84+
remove(operation)
85+
}
8286
}
8387

8488
const remove = (operation: OperatorInfo) => {

src/components/viewer/OperationRating.tsx

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Icon, IconSize } from '@blueprintjs/core'
2+
import { Popover2InteractionKind, Tooltip2 } from '@blueprintjs/popover2'
23

34
import clsx from 'clsx'
45
import { FC } from 'react'
@@ -7,8 +8,39 @@ import Rating from 'react-rating'
78
import { Operation } from 'models/operation'
89
import { ratingLevelToString } from 'models/rating'
910

11+
type PickedOperation = Pick<
12+
Operation,
13+
'notEnoughRating' | 'ratingRatio' | 'ratingLevel' | 'like' | 'dislike'
14+
>
15+
16+
const GetLevelDescription: FC<{
17+
operation: PickedOperation
18+
layout?: 'horizontal' | 'vertical'
19+
}> = ({ operation, layout }) => {
20+
return operation.notEnoughRating ? (
21+
layout === 'vertical' ? (
22+
<span>还没有足够的评分</span>
23+
) : (
24+
<span>评分不足</span>
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+
)
40+
}
41+
1042
export const OperationRating: FC<{
11-
operation: Pick<Operation, 'notEnoughRating' | 'ratingRatio' | 'ratingLevel'>
43+
operation: PickedOperation
1244
layout?: 'horizontal' | 'vertical'
1345
className?: string
1446
}> = ({ operation, layout = 'vertical', className }) => {
@@ -60,11 +92,7 @@ export const OperationRating: FC<{
6092
layout === 'horizontal' && !operation.notEnoughRating && 'mr-1.5',
6193
)}
6294
>
63-
{operation.notEnoughRating
64-
? layout === 'vertical'
65-
? '还没有足够的评分'
66-
: '评分不足'
67-
: ratingLevelToString(operation.ratingLevel)}
95+
<GetLevelDescription layout={layout} operation={operation} />
6896
</div>
6997
</div>
7098
)

src/models/generated/operators.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,12 @@
323323
"alias": "chunjinaiyafala chunjinyiyafala cjayfl cjyyfl 純燼艾雅法拉",
324324
"alt_name": "Eyjafjalla the Hvít Aska"
325325
},
326+
{
327+
"id": "char_494_vendla",
328+
"name": "刺玫",
329+
"alias": "cimei cm 刺玫",
330+
"alt_name": "Vendela"
331+
},
326332
{
327333
"id": "token_10008_cqbw_box",
328334
"name": "此面向敌",
@@ -347,6 +353,12 @@
347353
"alias": "dageda dgd 達格達",
348354
"alt_name": "Dagda"
349355
},
356+
{
357+
"id": "char_4110_delphn",
358+
"name": "戴菲恩",
359+
"alias": "daifeien dfe 戴菲恩",
360+
"alt_name": "Delphine"
361+
},
350362
{
351363
"id": "char_4032_provs",
352364
"name": "但书",
@@ -539,6 +551,12 @@
539551
"alias": "haojiao haojue hj 號角",
540552
"alt_name": "Horn"
541553
},
554+
{
555+
"id": "char_4088_hodrer",
556+
"name": "赫德雷",
557+
"alias": "hedelei hdl 赫德雷",
558+
"alt_name": "Hoederer"
559+
},
542560
{
543561
"id": "char_4041_chnut",
544562
"name": "褐果",
@@ -1601,6 +1619,12 @@
16011619
"alias": "weicao wc 葦草",
16021620
"alt_name": "Reed"
16031621
},
1622+
{
1623+
"id": "char_4107_vrdant",
1624+
"name": "维荻",
1625+
"alias": "weidi wd 維荻",
1626+
"alt_name": "Verdant"
1627+
},
16041628
{
16051629
"id": "char_275_breeze",
16061630
"name": "微风",

src/models/operation.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export interface Operation {
1717
ratingRatio: number
1818
ratingType: OpRatingType
1919
notEnoughRating: boolean
20+
like: number
21+
dislike: number
2022
commentsCount: number
2123
}
2224

0 commit comments

Comments
 (0)