@@ -103,6 +103,7 @@ import { nextTick, onMounted, ref, onBeforeUnmount } from 'vue'
103103import { useRoute } from ' vue-router'
104104import { copyClick } from ' @/utils/clipboard'
105105import applicationApi from ' @/api/application/application'
106+ import chatAPI from ' @/api/chat/chat'
106107import { datetimeFormat } from ' @/utils/time'
107108import { MsgError } from ' @/utils/message'
108109import bus from ' @/bus'
@@ -118,7 +119,7 @@ const copy = (data: any) => {
118119}
119120const route = useRoute ()
120121const {
121- params : { id }
122+ params : { id },
122123} = route as any
123124
124125const props = withDefaults (
@@ -134,8 +135,8 @@ const props = withDefaults(
134135 }>(),
135136 {
136137 data : () => ({}),
137- type: ' ai-chat'
138- }
138+ type: ' ai-chat' ,
139+ },
139140)
140141
141142const emit = defineEmits ([' update:data' , ' regeneration' ])
@@ -152,12 +153,10 @@ function regeneration() {
152153}
153154
154155function voteHandle(val : string ) {
155- applicationApi
156- .putChatVote (props .applicationId , props .chatId , props .data .record_id , val , loading )
157- .then (() => {
158- buttonData .value [' vote_status' ] = val
159- emit (' update:data' , buttonData .value )
160- })
156+ chatAPI .vote (props .chatId , props .data .record_id , val , loading ).then (() => {
157+ buttonData .value [' vote_status' ] = val
158+ emit (' update:data' , buttonData .value )
159+ })
161160}
162161
163162function markdownToPlainText(md : string ) {
@@ -203,9 +202,9 @@ function smartSplit(
203202 0 : 10 ,
204203 1 : 25 ,
205204 3 : 50 ,
206- 5 : 100
205+ 5 : 100 ,
207206 },
208- is_end = false
207+ is_end = false ,
209208) {
210209 // 匹配中文逗号/句号,且后面至少还有20个字符(含任何字符,包括换行)
211210 const regex = / ([。?\n ] )| (<audio[^ >] * ><\/ audio>)/ g
@@ -261,7 +260,7 @@ enum AudioStatus {
261260 /**
262261 * 错误
263262 */
264- ERROR = ' ERROR'
263+ ERROR = ' ERROR' ,
265264}
266265class AudioManage {
267266 textList: Array <string >
@@ -318,7 +317,7 @@ class AudioManage {
318317 .postTextToSpeech (
319318 (props .applicationId as string ) || (id as string ),
320319 { text: text },
321- loading
320+ loading ,
322321 )
323322 .then (async (res : any ) => {
324323 if (res .type === ' application/json' ) {
@@ -347,7 +346,7 @@ class AudioManage {
347346 this .audioList .push (audioElement )
348347 } else {
349348 const speechSynthesisUtterance: SpeechSynthesisUtterance = new SpeechSynthesisUtterance (
350- text
349+ text ,
351350 )
352351 speechSynthesisUtterance .onend = () => {
353352 this .statusList [index ] = AudioStatus .END
@@ -381,7 +380,7 @@ class AudioManage {
381380 .postTextToSpeech (
382381 (props .applicationId as string ) || (id as string ),
383382 { text: text },
384- loading
383+ loading ,
385384 )
386385 .then (async (res : any ) => {
387386 if (res .type === ' application/json' ) {
@@ -432,7 +431,7 @@ class AudioManage {
432431
433432 // 需要播放的内容
434433 const index = this .statusList .findIndex ((status ) =>
435- [AudioStatus .MOUNTED , AudioStatus .READY ].includes (status )
434+ [AudioStatus .MOUNTED , AudioStatus .READY ].includes (status ),
436435 )
437436 if (index < 0 || this .statusList [index ] === AudioStatus .MOUNTED ) {
438437 return
@@ -502,9 +501,9 @@ class AudioManage {
502501 {
503502 0 : 20 ,
504503 1 : 50 ,
505- 5 : 100
504+ 5 : 100 ,
506505 },
507- is_end
506+ is_end ,
508507 )
509508
510509 return split
0 commit comments