File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -148,8 +148,11 @@ const NodeInfoLogger = (function() {
148148 }
149149
150150 // 使用装饰器模式扩展节点的onMouseDown方法
151+ const serverModeResponse = await fetch ( "/bizyair/server_mode" ) ;
152+ const serverModeData = await serverModeResponse . json ( ) ;
151153 node . onMouseDown = function ( e , pos , canvas ) {
152- if ( this . _isServerMode && this . type === 'LoadImage' ) {
154+ if ( serverModeData . data . server_mode && this . type === 'LoadImage' ) {
155+ console . log ( this . type , 'this=p------' ) ;
153156 return ;
154157 }
155158 // 对于小部件点击或右键点击,直接使用原始方法处理
Original file line number Diff line number Diff line change 422422
423423 return
424424 } catch (error : any ) {
425+ const errorMsgTime = getCurrentTime ()
426+ let errorMessage = ' '
427+ if (error ) {
428+ errorMessage = error .message
429+ }
430+ chatMessages .value .push ({
431+ role: ' assistant' ,
432+ content: ` 发生错误: ${errorMessage }<br><br><span style="color: #ff4d4f;">建议检查Bizyair是否更新到最新版本,并检查网络状态或者代理</span> ` ,
433+ time: errorMsgTime
434+ })
425435 isLoading .value = false
426436 isGenerating .value = false
427437 processingStatus .value = ' '
438+ setTimeout (() => {
439+ scrollToBottom ()
440+ }, 0 )
441+
428442 return
429443 }
430444 }
521535 },
522536 onError : error => {
523537 console .error (' 多模态请求失败:' , error )
524-
525538 const errorMsgTime = getCurrentTime ()
526-
539+ let errorMessage = ' '
540+ if (error ) {
541+ errorMessage = error .message
542+ }
527543 // 添加错误消息
528544 chatMessages .value .push ({
529545 role: ' assistant' ,
530- content: t ( ' sidebar.assistant. errorMessage' ) ,
546+ content: ` 发生错误: ${ errorMessage }<br><br><span style="color: #ff4d4f;">建议检查Bizyair是否更新到最新版本,并检查网络状态或者代理</span> ` ,
531547 time: errorMsgTime
532548 })
533549
545561 )
546562 } catch (error ) {
547563 const errorMsgTime = getCurrentTime ()
564+ // 获取错误信息
565+ let errorMessage = ' '
566+ if (
567+ error &&
568+ typeof error === ' object' &&
569+ ' message' in error &&
570+ typeof error .message === ' string'
571+ ) {
572+ errorMessage = error .message
573+ } else {
574+ errorMessage = String (error )
575+ }
576+
548577 // 添加错误消息
549578 chatMessages .value .push ({
550579 role: ' assistant' ,
553582 })
554583
555584 // 更新状态
556- // isLoading.value = false;
585+ isLoading .value = false
586+ isGenerating .value = false
557587 processingStatus .value = ' '
558588 } finally {
559589 console .log (' 请求处理完成,重置状态' )
Original file line number Diff line number Diff line change @@ -266,7 +266,7 @@ export async function sendStreamChatRequest(
266266 } )
267267
268268 if ( ! response . ok ) {
269- throw new Error ( `API请求失败: ${ response . status } ${ response . statusText } ` )
269+ throw new Error ( `HTTP错误: [ ${ response . status } ] ${ response . statusText } ` )
270270 }
271271
272272 if ( ! response . body ) {
@@ -489,6 +489,9 @@ export async function handleImageWithKontextPro(
489489 } ,
490490 body : JSON . stringify ( requestBody )
491491 } )
492+ if ( ! response . ok ) {
493+ throw new Error ( `HTTP错误: [${ response . status } ] ${ response . statusText } ` )
494+ }
492495 const responseData = await response . json ( )
493496
494497 if ( responseData . code === 20000 && responseData . data ) {
@@ -511,10 +514,16 @@ export async function handleImageWithKontextPro(
511514 }
512515 } else {
513516 console . error ( 'API响应格式不符合预期:' , responseData )
514- throw new Error ( `API响应错误: ${ responseData . message || '未知错误' } ` )
517+ const statusCode = responseData . code || ''
518+ const errorMsg = responseData . message || ''
519+ throw new Error ( `API响应错误: [${ statusCode } ] ${ errorMsg } ` )
515520 }
516521 } catch ( error : any ) {
517- console . error ( '图片编辑处理失败:' , error )
518- throw error
522+ const errorMessage = {
523+ code : 50000 ,
524+ message : error . message ,
525+ data : null
526+ }
527+ throw errorMessage
519528 }
520529}
Original file line number Diff line number Diff line change 1- 1.2.17
1+ 1.2.18
You can’t perform that action at this time.
0 commit comments