@@ -37,7 +37,10 @@ import { authAtom } from 'store/auth'
37
37
import { NetworkError } from 'utils/fetcher'
38
38
import { wrapErrorMessage } from 'utils/wrapErrorMessage'
39
39
40
+ import { useLevels } from '../../apis/arknights'
40
41
import { toCopilotOperation } from '../../models/converter'
42
+ import { CopilotDocV1 } from '../../models/copilot.schema'
43
+ import { createCustomLevel , findLevelByStageName } from '../../models/level'
41
44
import { toShortCode } from '../../models/shortCode'
42
45
43
46
const ManageMenu : FC < {
@@ -109,6 +112,8 @@ export const OperationViewer: ComponentType<{
109
112
const { data, error, mutate } = useOperation ( operationId )
110
113
const operation = data ?. data
111
114
115
+ const levels = useLevels ( { suspense : false } ) ?. data ?. data || [ ]
116
+
112
117
const [ auth ] = useAtom ( authAtom )
113
118
const authed = ! ! auth . token
114
119
@@ -250,7 +255,11 @@ export const OperationViewer: ComponentType<{
250
255
< div className = "flex flex-col" >
251
256
< FactItem title = "作战" >
252
257
< EDifficultyLevel
253
- level = { operation . level }
258
+ level = {
259
+ operation . level ||
260
+ findLevelByStageName ( levels , operationDoc . stageName ) ||
261
+ createCustomLevel ( operationDoc . stageName )
262
+ }
254
263
difficulty = { operation . difficulty }
255
264
/>
256
265
</ FactItem >
@@ -316,35 +325,42 @@ export const OperationViewer: ComponentType<{
316
325
< H4 className = "mb-4" > 干员与干员组</ H4 >
317
326
< H5 className = "mb-4 text-slate-600" > 干员</ H5 >
318
327
< div className = "flex flex-col mb-4" >
319
- { operation . operators . map ( ( operator ) => (
320
- < OperatorCard key = { operator } operator = { operator } />
328
+ { operationDoc . opers ? .map ( ( operator ) => (
329
+ < OperatorCard key = { operator . name } operator = { operator } />
321
330
) ) }
322
- { operation . operators . length === 0 && (
331
+ { ! operationDoc . opers ? .length && (
323
332
< EmptyOperator description = "作业并未添加干员" />
324
333
) }
325
334
</ div >
326
335
327
336
< H5 className = "mb-4 text-slate-600" > 干员组</ H5 >
328
337
< div className = "flex flex-col" >
329
- { operation . groups . map ( ( el ) => (
330
- < Card elevation = { Elevation . ONE } className = "mb-4" >
338
+ { operationDoc . groups ?. map ( ( group ) => (
339
+ < Card
340
+ elevation = { Elevation . ONE }
341
+ className = "mb-4"
342
+ key = { group . name }
343
+ >
331
344
< div className = "flex flex-col" >
332
- < H5 className = "text-gray-800 font-bold" > { el . name } </ H5 >
345
+ < H5 className = "text-gray-800 font-bold" > { group . name } </ H5 >
333
346
334
347
< div className = "flex flex-col" >
335
- { el . operators . filter ( Boolean ) . map ( ( operator ) => (
336
- < OperatorCard key = { operator } operator = { operator } />
348
+ { group . opers ?. filter ( Boolean ) . map ( ( operator ) => (
349
+ < OperatorCard
350
+ key = { operator . name }
351
+ operator = { operator }
352
+ />
337
353
) ) }
338
354
339
- { el . operators . filter ( Boolean ) . length === 0 && (
355
+ { group . opers ? .filter ( Boolean ) . length === 0 && (
340
356
< EmptyOperator description = "干员组中并未添加干员" />
341
357
) }
342
358
</ div >
343
359
</ div >
344
360
</ Card >
345
361
) ) }
346
362
347
- { operation . groups . length === 0 && (
363
+ { ! operationDoc . groups ? .length && (
348
364
< EmptyOperator
349
365
title = "暂无干员组"
350
366
description = "作业并未添加干员组"
@@ -369,9 +385,9 @@ export const OperationViewer: ComponentType<{
369
385
)
370
386
371
387
const OperatorCard : FC < {
372
- operator : string
388
+ operator : CopilotDocV1 . Operator
373
389
} > = ( { operator } ) => {
374
- const [ name , skill ] = operator . split ( '::' )
390
+ const { name, skill } = operator
375
391
return (
376
392
< Card elevation = { Elevation . ONE } className = "mb-2 last:mb-0 flex" >
377
393
< OperatorAvatar name = { name } size = "large" className = "mr-3" />
0 commit comments