From a762b59c2c4b459f72ede19716d476bb3513f622 Mon Sep 17 00:00:00 2001 From: gerson <1405270578@qq.com> Date: 星期四, 20 二月 2025 08:27:57 +0800 Subject: [PATCH] 获取位置 --- src/components/chat/Chat.vue | 55 +++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 35 insertions(+), 20 deletions(-) diff --git a/src/components/chat/Chat.vue b/src/components/chat/Chat.vue index 410008a..a1a2058 100644 --- a/src/components/chat/Chat.vue +++ b/src/components/chat/Chat.vue @@ -60,7 +60,7 @@ import CustomDrawer from '/@/components/drawer/CustomDrawer.vue'; import { Logger } from '/@/model/logger/Logger'; import { triggerRef } from 'vue'; -import { ElMessage } from 'element-plus'; +import { ElLoadingService, ElMessage } from 'element-plus'; import ChatContainer from './components/ChatContainer.vue'; import ShareLinkDlg from './components/shareLink/index.vue'; import router from '/@/router'; @@ -79,6 +79,7 @@ import { toMyFixed } from '/@/utils/util'; import { useLoadData } from './hooks/useLoadData'; import { useSyncMsg } from './hooks/useSyncMsg'; +import { getCurrentPosition } from '/@/utils/brower'; const containerRef = useCompRef(ChatContainer); const chatListDom = computed(() => containerRef.value?.chatListDom); const scrollToBottom = () => { @@ -101,7 +102,6 @@ }); let questionRes = null; -let position = null; const preQuestion = ref(null); let lastAxiosSource: CancelTokenSource = null; @@ -114,6 +114,7 @@ isTalking.value = !isTalking.value; }); }; +let position: Position = null; const questionAi = async (text) => { let judgeParams = null; if (!preQuestion.value) { @@ -131,11 +132,21 @@ ...judgeParams, } as any; - if (position) { - const longitude = position.coords.longitude; - const latitude = position.coords.latitude; - params.cur_pos = [longitude, latitude].join(','); - } + // if (!position) { + // const loadingInstance = ElLoadingService({ + // text: '鑾峰彇浣嶇疆涓�...', + // target: '.layout-parent', + // fullscreen:false, + // }); + // position = await getCurrentPosition().finally(() => { + // loadingInstance.close(); + // }); + // } + + // if (position) { + // const { latitude, longitude } = position; + // params.cur_pos = [longitude, latitude].join(','); + // } if (activeGroupType.value) { params.group_type = activeGroupType.value; @@ -182,6 +193,10 @@ const lastMsg = computedMessageList.value.at(-1); // lastMsg.content.values = lastMsg.content.values.concat([]); // 宸茬粡瑙f瀽杩囦竴娆� reports + if (!lastMsg.content.values) { + lastMsg.content.values = []; + } + lastMsg.content.values.push({ content: parseContent(res, true, { origin: res, @@ -248,7 +263,7 @@ } } const getLastGroup = () => { - const lastGroup = computedMessageList.value.at(-1).stepGroup.at(-1); + const lastGroup = computedMessageList.value.at(-1).stepGroup[0]; return lastGroup; }; const getLastStepList = () => { @@ -280,19 +295,19 @@ // 鏆傛椂涓嶈�冭檻澶氫釜 report 鎯呭喌 - // if (lastIsResult && chunkRes.mode !== 'finish') { - // const lastTow = computedMessageList.value.at(-1); - // lastTow.stepGroup.at(-1).value.at(-1).finishLoading = true; - // // lastTow.content.values = lastTow.content.values.concat([]); + if (lastIsResult && chunkRes.mode !== 'finish') { + // const lastTow = computedMessageList.value.at(-1); + // lastTow.stepGroup.at(-1).value.at(-1).finishLoading = true; + // lastTow.content.values = lastTow.content.values.concat([]); - // // 寮�濮嬪鍔犳柊鐨� stepGroup - // computedMessageList.value.at(-1).stepGroup.push({ - // value: [], - // isShow: true, - // }); - // lastIsResult = false; - // } - const lastGroup = computedMessageList.value.at(-1).stepGroup.at(-1); + // 寮�濮嬪鍔犳柊鐨� stepGroup锛屽悗缁殑 stepGroup 骞舵病鏈夊疄闄呬綔鐢紝鍙槸涓轰簡鍋氳凯浠g敤锛岃凯浠e嚭缁勪欢锛屽睅灞变唬鐮佸疄鍦ㄥお闅炬敼浜嗭紒锛侊紒 + computedMessageList.value.at(-1).stepGroup.push({ + value: [], + isShow: true, + }); + lastIsResult = false; + } + const lastGroup = computedMessageList.value.at(-1).stepGroup[0]; const stepList = lastGroup?.value ?? []; const currentTimeStamp = new Date().getTime(); const ms = toMyFixed(currentTimeStamp - lastTimestamp, 2) + ' ms'; -- Gitblit v1.9.3