Skip to content

Commit a23ac06

Browse files
authored
Merge pull request #134 from MaaAssistantArknights/dev
fix: downloaded operation is not snake-cased
2 parents 5228f1b + 518de6e commit a23ac06

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

src/components/OperationCard.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,14 @@ export const OperationCard = ({
5858
<div className="flex-1" />
5959
<div className="flex flex-col items-end">
6060
<div className="w-full flex justify-end text-zinc-500">
61-
{!operation.isNotEnoughRating && (
62-
<div className="flex items-center mr-4">
63-
<Icon icon="star" className="mr-1.5" />
64-
<OperationRating
65-
className="text-sm"
66-
operation={operation}
67-
layout="horizontal"
68-
/>
69-
</div>
70-
)}
61+
<div className="flex items-center mr-4">
62+
<Icon icon="star" className="mr-1.5" />
63+
<OperationRating
64+
className="text-sm"
65+
operation={operation}
66+
layout="horizontal"
67+
/>
68+
</div>
7169

7270
<Tooltip2
7371
className="mr-4"

src/components/viewer/OperationRating.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ import { Operation } from 'models/operation'
88
import { ratingLevelToString } from 'models/rating'
99

1010
export const OperationRating: FC<{
11-
operation: Pick<
12-
Operation,
13-
'isNotEnoughRating' | 'ratingRatio' | 'ratingLevel'
14-
>
11+
operation: Pick<Operation, 'notEnoughRating' | 'ratingRatio' | 'ratingLevel'>
1512
layout?: 'horizontal' | 'vertical'
1613
className?: string
1714
}> = ({ operation, layout = 'vertical', className }) => {
@@ -24,7 +21,7 @@ export const OperationRating: FC<{
2421
className,
2522
)}
2623
>
27-
{!operation.isNotEnoughRating && (
24+
{!operation.notEnoughRating && (
2825
<Rating
2926
initialRating={operation.ratingRatio * 5}
3027
fullSymbol={
@@ -60,10 +57,10 @@ export const OperationRating: FC<{
6057
<div
6158
className={clsx(
6259
'text-sm text-zinc-500',
63-
layout === 'horizontal' && !operation.isNotEnoughRating && 'mr-1.5',
60+
layout === 'horizontal' && !operation.notEnoughRating && 'mr-1.5',
6461
)}
6562
>
66-
{operation.isNotEnoughRating
63+
{operation.notEnoughRating
6764
? layout === 'vertical'
6865
? '还没有足够的评分'
6966
: '评分不足'

src/components/viewer/OperationViewer.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { useAtom } from 'jotai'
2121
import { noop } from 'lodash-es'
2222
import { ComponentType, FC, useMemo, useState } from 'react'
2323
import { Link } from 'react-router-dom'
24+
import snakecaseKeys from 'snakecase-keys'
2425

2526
import { FactItem } from 'components/FactItem'
2627
import { Paragraphs } from 'components/Paragraphs'
@@ -145,7 +146,11 @@ export const OperationViewer: ComponentType<{
145146

146147
const handleDownloadJSON = () => {
147148
// pretty print the JSON
148-
const json = JSON.stringify(operationDoc, null, 2)
149+
const json = JSON.stringify(
150+
snakecaseKeys(operationDoc, { deep: true }),
151+
null,
152+
2,
153+
)
149154
const blob = new Blob([json], {
150155
type: 'application/json',
151156
})

src/models/operation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export interface Operation {
1616
ratingLevel: number // integer in [0, 10]
1717
ratingRatio: number
1818
ratingType: OpRatingType
19-
isNotEnoughRating: boolean
19+
notEnoughRating: boolean
2020
difficulty: OpDifficulty
2121
}
2222

0 commit comments

Comments
 (0)