|
85 | 85 | </div> |
86 | 86 | </template> |
87 | 87 | <script setup lang="ts"> |
88 | | -import { ref, nextTick, computed, watch, reactive, onMounted, onBeforeUnmount } from 'vue' |
| 88 | +import { type Ref, ref, nextTick, computed, watch, reactive, onMounted, onBeforeUnmount } from 'vue' |
89 | 89 | import { useRoute } from 'vue-router' |
90 | 90 | import applicationApi from '@/api/application/application' |
| 91 | +import chatAPI from '@/api/chat/chat' |
91 | 92 | import chatLogApi from '@/api/application/chat-log' |
92 | 93 | import { ChatManagement, type chatType } from '@/api/type/application' |
93 | 94 | import { randomId } from '@/utils/utils' |
@@ -280,23 +281,35 @@ const handleDebounceClick = debounce((val, other_params_data?: any, chat?: chatT |
280 | 281 | */ |
281 | 282 | const openChatId: () => Promise<string> = () => { |
282 | 283 | const obj = props.applicationDetails |
| 284 | + return getOpenChatAPI()(obj.id) |
| 285 | + .then((res) => { |
| 286 | + chartOpenId.value = res.data |
| 287 | + return res.data |
| 288 | + }) |
| 289 | + .catch((res) => { |
| 290 | + if (res.response.status === 403) { |
| 291 | + return application.asyncAppAuthentication(accessToken).then(() => { |
| 292 | + return openChatId() |
| 293 | + }) |
| 294 | + } |
| 295 | + return Promise.reject(res) |
| 296 | + }) |
| 297 | +} |
| 298 | +
|
| 299 | +const getChatMessageAPI = () => { |
283 | 300 | if (props.type === 'debug-ai-chat') { |
284 | | - return applicationApi |
285 | | - .open(obj.id) |
286 | | - .then((res) => { |
287 | | - chartOpenId.value = res.data |
288 | | - return res.data |
289 | | - }) |
290 | | - .catch((res) => { |
291 | | - if (res.response.status === 403) { |
292 | | - return application.asyncAppAuthentication(accessToken).then(() => { |
293 | | - return openChatId() |
294 | | - }) |
295 | | - } |
296 | | - return Promise.reject(res) |
297 | | - }) |
| 301 | + return applicationApi.chat |
| 302 | + } else { |
| 303 | + return chatAPI.chat |
| 304 | + } |
| 305 | +} |
| 306 | +const getOpenChatAPI = () => { |
| 307 | + if (props.type === 'debug-ai-chat') { |
| 308 | + return applicationApi.open |
298 | 309 | } else { |
299 | | - return Promise.reject('暂不支持') |
| 310 | + return (a?: string, loading?: Ref<boolean>) => { |
| 311 | + return chatAPI.open(loading) |
| 312 | + } |
300 | 313 | } |
301 | 314 | } |
302 | 315 | /** |
@@ -453,8 +466,7 @@ function chatMessage(chat?: any, problem?: string, re_chat?: boolean, other_para |
453 | 466 | }, |
454 | 467 | } |
455 | 468 | // 对话 |
456 | | - applicationApi |
457 | | - .chat(chartOpenId.value, obj) |
| 469 | + getChatMessageAPI()(chartOpenId.value, obj) |
458 | 470 | .then((response) => { |
459 | 471 | if (response.status === 401) { |
460 | 472 | application |
|
0 commit comments