diff --git a/src/apis/operation.ts b/src/apis/operation.ts index d2378b49..2319aaf2 100644 --- a/src/apis/operation.ts +++ b/src/apis/operation.ts @@ -44,6 +44,7 @@ export function useOperations({ data: pages, setSize, isValidating, + mutate } = useSWRInfinite( (pageIndex, previousPage: { hasNext: boolean }) => { if (disabled) { @@ -128,8 +129,8 @@ export function useOperations({ // 按 operationIds 的顺序排序 const operations = operationIds?.length ? operationIds - ?.map((id) => _operations?.find((v) => v.id === id)) - .filter((v) => !!v) + ?.map((id) => _operations?.find((v) => v.id === id)) + .filter((v) => !!v) : _operations return { @@ -138,6 +139,7 @@ export function useOperations({ setSize, isValidating, isReachingEnd, + mutate } } diff --git a/src/components/OperationCard.tsx b/src/components/OperationCard.tsx index 7bee455a..a19a59d1 100644 --- a/src/components/OperationCard.tsx +++ b/src/components/OperationCard.tsx @@ -1,14 +1,14 @@ -import { Button, Card, Elevation, H4, H5, Icon, Tag } from '@blueprintjs/core' +import { Button, ButtonGroup, Card, Elevation, H4, H5, Icon, Tag } from '@blueprintjs/core' import { Tooltip2 } from '@blueprintjs/popover2' import clsx from 'clsx' -import { copyShortCode, handleDownloadJSON } from 'services/operation' +import { copyShortCode, handleDownloadJSON, handleRating } from 'services/operation' import { ReLink } from 'components/ReLink' import { RelativeTime } from 'components/RelativeTime' import { AddToOperationSetButton } from 'components/operation-set/AddToOperationSet' import { OperationRating } from 'components/viewer/OperationRating' -import { OpDifficulty, Operation } from 'models/operation' +import { OpDifficulty, Operation, OpRatingType } from 'models/operation' import { useLevels } from '../apis/level' import { createCustomLevel, findLevelByStageName } from '../models/level' @@ -16,7 +16,7 @@ import { Paragraphs } from './Paragraphs' import { EDifficulty } from './entity/EDifficulty' import { EDifficultyLevel, NeoELevel } from './entity/ELevel' -export const NeoOperationCard = ({ operation }: { operation: Operation }) => { +export const NeoOperationCard = ({ operation, updateOperation }: { operation: Operation, updateOperation: (id: number, type: number) => Promise }) => { const { data: levels } = useLevels() return ( @@ -106,12 +106,12 @@ export const NeoOperationCard = ({ operation }: { operation: Operation }) => { - + ) } -export const OperationCard = ({ operation }: { operation: Operation }) => { +export const OperationCard = ({ operation, updateOperation }: { operation: Operation, updateOperation: (id: number, type: number) => Promise }) => { const { data: levels } = useLevels() return ( @@ -197,6 +197,7 @@ export const OperationCard = ({ operation }: { operation: Operation }) => { ) @@ -235,44 +236,87 @@ const OperatorTags = ({ operation }: { operation: Operation }) => { const CardActions = ({ className, operation, + updateOperation, }: { className?: string operation: Operation + updateOperation: (id: number, type: number) => Promise }) => { return ( -
- 下载原 JSON
- } - > -