| | |
| | | <script setup lang="ts"> |
| | | import type { CancelTokenSource } from 'axios'; |
| | | import axios from 'axios'; |
| | | import { orderBy } from 'lodash-es'; |
| | | import moment from 'moment'; |
| | | import { computed, nextTick, onActivated, onMounted, ref } from 'vue'; |
| | | import { loadAmisSource } from '../amis/load'; |
| | |
| | | import CustomDrawer from '/@/components/drawer/CustomDrawer.vue'; |
| | | import { Logger } from '/@/model/logger/Logger'; |
| | | import { triggerRef } from 'vue'; |
| | | import { ElLoadingService, ElMessage } from 'element-plus'; |
| | | import { ElMessage } from 'element-plus'; |
| | | import ChatContainer from './components/ChatContainer.vue'; |
| | | import ShareLinkDlg from './components/shareLink/index.vue'; |
| | | import router from '/@/router'; |
| | |
| | | import { useSyncMsg } from './hooks/useSyncMsg'; |
| | | import { getCurrentPosition } from '/@/utils/brower'; |
| | | import { deepClone } from '/@/utils/other'; |
| | | import { ParentRegister } from '/@/stores/global'; |
| | | const containerRef = useCompRef(ChatContainer); |
| | | const chatListDom = computed(() => containerRef.value?.chatListDom); |
| | | |
| | | const scrollToBottom = () => { |
| | | containerRef.value?.scrollToBottom(); |
| | | }; |
| | |
| | | }); |
| | | }; |
| | | |
| | | const enableCallback = ref(false); |
| | | |
| | | let streamOutputIsStart = false; |
| | | let position: Position = null; |
| | | const questionAi = async (text) => { |
| | |
| | | params.tables = JSON.stringify(tableList); |
| | | } |
| | | |
| | | const metricList = attachList.value.filter((item) => item.type === 'metric').map((item) => item.model); |
| | | if (metricList?.length > 0) { |
| | | params.metrics = JSON.stringify(metricList); |
| | | } |
| | | // if (!position) { |
| | | // const loadingInstance = ElLoadingService({ |
| | | // text: '获取位置中...', |
| | |
| | | triggerRefresh(); |
| | | return; |
| | | // chunkRes.value = '准备数据分析'; |
| | | } |
| | | |
| | | if (chunkRes.mode === 'main_frame') { |
| | | const jsonObj = JSON.parse(chunkRes.value); |
| | | if (!enableCallback.value) { |
| | | return; |
| | | } |
| | | |
| | | ParentRegister.notify?.({ |
| | | type: 'main_frame', |
| | | value: jsonObj, |
| | | }); |
| | | return; |
| | | } |
| | | |
| | | if (chunkRes.mode === 'create_work_order') { |
| | | const lastMsg = computedMessageList.value.at(-1); |
| | | lastMsg.modeContent = chunkRes; |
| | | triggerRefresh(); |
| | | return; |
| | | } |
| | | |
| | | if (chunkRes.mode === 'summary') { |
| | |
| | | lastAxiosSource?.cancel(); |
| | | isTalking.value = false; |
| | | chatListLoading.value = false; |
| | | |
| | | streamOutputIsStart = false; |
| | | computedMessageList.value.at(-1).isStopMsg = true; |
| | | }; |
| | | |