@@ -20,7 +20,7 @@ import { useOperation } from 'apis/query'
20
20
import { apiPostRating } from 'apis/rating'
21
21
import { useAtom } from 'jotai'
22
22
import { noop } from 'lodash-es'
23
- import { ComponentType , FC , useMemo , useState } from 'react'
23
+ import { ComponentType , FC , useEffect , useMemo , useState } from 'react'
24
24
import { Link } from 'react-router-dom'
25
25
import snakecaseKeys from 'snakecase-keys'
26
26
@@ -44,6 +44,7 @@ import { CopilotDocV1 } from '../../models/copilot.schema'
44
44
import { createCustomLevel , findLevelByStageName } from '../../models/level'
45
45
import { Level } from '../../models/operation'
46
46
import { toShortCode } from '../../models/shortCode'
47
+ import { formatError } from '../../utils/error'
47
48
import { ActionCard } from '../ActionCard'
48
49
import { CommentArea } from './comment/CommentArea'
49
50
@@ -123,19 +124,22 @@ export const OperationViewer: ComponentType<{
123
124
124
125
const [ auth ] = useAtom ( authAtom )
125
126
127
+ // make eslint happy: we got Suspense out there
128
+ if ( ! operation ) return null
129
+
126
130
const operationDoc = useMemo (
127
- ( ) => toCopilotOperation ( operation ! ) ,
131
+ ( ) => toCopilotOperation ( operation ) ,
128
132
[ operation ] ,
129
133
)
130
134
131
- // make eslint happy: we got Suspense out there
132
- if ( ! operation ) return null
133
-
134
- if ( error ) {
135
- return (
136
- < NonIdealState icon = "error" title = "获取作业失败" description = { error } />
137
- )
138
- }
135
+ useEffect ( ( ) => {
136
+ if ( error ) {
137
+ AppToaster . show ( {
138
+ intent : 'danger' ,
139
+ message : `刷新作业失败: ${ formatError ( error ) } ` ,
140
+ } )
141
+ }
142
+ } , [ error ] )
139
143
140
144
const handleCopyShortCode = ( ) => {
141
145
const shortCode = toShortCode ( operation . id )
0 commit comments