@@ -136,19 +136,11 @@ export function ExpressionReviewer({
136136 const loadStats = useCallback ( async ( ) => {
137137 try {
138138 const result = await getReviewStats ( )
139- if ( result . success ) {
140- setStats ( result . data )
141- } else {
142- toast ( {
143- title : '错误' ,
144- description : result . error ,
145- variant : 'destructive' ,
146- } )
147- }
139+ setStats ( result )
148140 } catch ( error ) {
149141 console . error ( '加载统计失败:' , error )
150142 }
151- } , [ toast ] )
143+ } , [ ] )
152144
153145 // 加载列表
154146 const loadList = useCallback ( async ( ) => {
@@ -160,16 +152,8 @@ export function ExpressionReviewer({
160152 filter_type : filterType ,
161153 search : search || undefined ,
162154 } )
163- if ( result . success ) {
164- setExpressions ( result . data . data )
165- setTotal ( result . data . total )
166- } else {
167- toast ( {
168- title : '加载失败' ,
169- description : result . error ,
170- variant : 'destructive' ,
171- } )
172- }
155+ setExpressions ( result . data )
156+ setTotal ( result . total )
173157 } catch ( error ) {
174158 toast ( {
175159 title : '加载失败' ,
@@ -185,13 +169,11 @@ export function ExpressionReviewer({
185169 const loadChatNames = useCallback ( async ( ) => {
186170 try {
187171 const result = await getChatList ( )
188- if ( result . success ) {
189- const nameMap = new Map < string , string > ( )
190- result . data . forEach ( ( chat : ChatInfo ) => {
191- nameMap . set ( chat . chat_id , chat . chat_name )
192- } )
193- setChatNameMap ( nameMap )
194- }
172+ const nameMap = new Map < string , string > ( )
173+ result . forEach ( ( chat : ChatInfo ) => {
174+ nameMap . set ( chat . chat_id , chat . chat_name )
175+ } )
176+ setChatNameMap ( nameMap )
195177 } catch ( error ) {
196178 console . error ( '加载聚天名称失败:' , error )
197179 }
@@ -214,34 +196,26 @@ export function ExpressionReviewer({
214196 exclude_ids : excludedIds . length > 0 ? excludedIds : undefined ,
215197 } )
216198
217- if ( result . success ) {
218- if ( append ) {
219- const loadedCount = quickExpressionsRef . current . length
220- const existingIds = new Set ( quickExpressionsRef . current . map ( ( e ) => e . id ) )
221- const newItems = result . data . data . filter ( ( e : Expression ) => ! existingIds . has ( e . id ) )
222- newItems . forEach ( ( expr : Expression ) => quickExcludedIdsRef . current . add ( expr . id ) )
223-
224- setQuickExpressions ( ( prev ) => [ ...prev , ...newItems ] )
225- setQuickTotal ( loadedCount + result . data . total )
226- setQuickHasMore ( newItems . length > 0 && result . data . total > newItems . length )
227- } else {
228- quickExcludedIdsRef . current = new Set (
229- result . data . data . map ( ( expr : Expression ) => expr . id )
230- )
231- setQuickExpressions ( result . data . data )
232- setQuickTotal ( result . data . total )
233- setQuickHasMore ( result . data . total > result . data . data . length )
234- }
235-
236- if ( resetIndex ) {
237- setQuickCurrentIndex ( 0 )
238- }
199+ if ( append ) {
200+ const loadedCount = quickExpressionsRef . current . length
201+ const existingIds = new Set ( quickExpressionsRef . current . map ( ( e ) => e . id ) )
202+ const newItems = result . data . filter ( ( e : Expression ) => ! existingIds . has ( e . id ) )
203+ newItems . forEach ( ( expr : Expression ) => quickExcludedIdsRef . current . add ( expr . id ) )
204+
205+ setQuickExpressions ( ( prev ) => [ ...prev , ...newItems ] )
206+ setQuickTotal ( loadedCount + result . total )
207+ setQuickHasMore ( newItems . length > 0 && result . total > newItems . length )
239208 } else {
240- toast ( {
241- title : '加载失败' ,
242- description : result . error ,
243- variant : 'destructive' ,
244- } )
209+ quickExcludedIdsRef . current = new Set (
210+ result . data . map ( ( expr : Expression ) => expr . id )
211+ )
212+ setQuickExpressions ( result . data )
213+ setQuickTotal ( result . total )
214+ setQuickHasMore ( result . total > result . data . length )
215+ }
216+
217+ if ( resetIndex ) {
218+ setQuickCurrentIndex ( 0 )
245219 }
246220 } catch ( error ) {
247221 toast ( {
@@ -324,16 +298,7 @@ export function ExpressionReviewer({
324298 } ,
325299 ] )
326300
327- if ( ! result . success ) {
328- toast ( {
329- title : '操作失败' ,
330- description : result . error ,
331- variant : 'destructive' ,
332- } )
333- return
334- }
335-
336- if ( result . data . results [ 0 ] ?. success ) {
301+ if ( result . results [ 0 ] ?. success ) {
337302 toast ( {
338303 title : approved ? '已通过' : '已删除' ,
339304 description : `表达方式 #${ currentExpr . id } ${ approved ? '已通过' : '已删除' } ` ,
@@ -676,16 +641,7 @@ export function ExpressionReviewer({
676641 { id, approved, require_unchecked : filterType === 'unchecked' } ,
677642 ] )
678643
679- if ( ! result . success ) {
680- toast ( {
681- title : '操作失败' ,
682- description : result . error ,
683- variant : 'destructive' ,
684- } )
685- return
686- }
687-
688- if ( result . data . results [ 0 ] ?. success ) {
644+ if ( result . results [ 0 ] ?. success ) {
689645 toast ( {
690646 title : approved ? '已通过' : '已删除' ,
691647 description : `表达方式 #${ id } ${ approved ? '已通过' : '已删除' } ` ,
@@ -697,7 +653,7 @@ export function ExpressionReviewer({
697653 } else {
698654 toast ( {
699655 title : '操作失败' ,
700- description : result . data . results [ 0 ] ?. message || '未知错误' ,
656+ description : result . results [ 0 ] ?. message || '未知错误' ,
701657 variant : 'destructive' ,
702658 } )
703659 }
@@ -738,19 +694,10 @@ export function ExpressionReviewer({
738694
739695 const result = await batchReviewExpressions ( items )
740696
741- if ( ! result . success ) {
742- toast ( {
743- title : '批量审核失败' ,
744- description : result . error ,
745- variant : 'destructive' ,
746- } )
747- return
748- }
749-
750697 toast ( {
751698 title : '批量审核完成' ,
752- description : `成功 ${ result . data . succeeded } 条,失败 ${ result . data . failed } 条` ,
753- variant : result . data . failed > 0 ? 'destructive' : 'default' ,
699+ description : `成功 ${ result . succeeded } 条,失败 ${ result . failed } 条` ,
700+ variant : result . failed > 0 ? 'destructive' : 'default' ,
754701 } )
755702
756703 // 清空选择并刷新
0 commit comments