| | |
| | | import { AssistantContent } from './types'; |
| | | import { agentStreamByPost } from '/@/api/ai/chat'; |
| | | import { Logger } from '/@/model/logger/Logger'; |
| | | import type { OLMap } from '/@/model/map/OLMap'; |
| | | import { GaoDeSourceType, gaoDeSourceTypeMap, type OLMap } from '/@/model/map/OLMap'; |
| | | import assistantPic from '/static/images/role/assistant-200x192.png'; |
| | | import userPic from '/static/images/role/user-200x206.png'; |
| | | import { useDrag } from '/@/hooks/useDrag'; |
| | |
| | | |
| | | const chatContainerRef = ref<HTMLDivElement>(null); |
| | | |
| | | const { startDrag, style: chatContainerStyle, handleStyle } = useDrag({ |
| | | const { |
| | | startDrag, |
| | | style: chatContainerStyle, |
| | | handleStyle, |
| | | } = useDrag({ |
| | | handle: chatHeaderRef, |
| | | }); |
| | | |
| | |
| | | return result as ChatMessage<AssistantContent>; |
| | | }; |
| | | |
| | | const mockCommand = (question: string) => { |
| | | if (question === `切换${gaoDeSourceTypeMap[GaoDeSourceType.Vector]}`) { |
| | | handleMapCommand({ operate: '切换标准地图' }); |
| | | return; |
| | | } else if (question === `切换${gaoDeSourceTypeMap[GaoDeSourceType.Satellite]}`) { |
| | | handleMapCommand({ operate: '切换卫星地图' }); |
| | | return; |
| | | } else if (question === `切换${gaoDeSourceTypeMap[GaoDeSourceType.SatelliteRoad]}`) { |
| | | handleMapCommand({ operate: '切换路网地图' }); |
| | | return; |
| | | } else if (question === '显示设备') { |
| | | handleMapCommand({ operate: '显示设备' }); |
| | | return; |
| | | } else if (question === '隐藏设备') { |
| | | handleMapCommand({ operate: '隐藏设备' }); |
| | | return; |
| | | } else if (question === '聚焦设备') { |
| | | handleMapCommand({ operate: '聚焦设备' }); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | const startStream = (question: string) => { |
| | | if (lastIsInit) { |
| | | showHistory.value = false; |
| | | } |
| | | |
| | | // mockCommand(question); |
| | | // return; |
| | | let haveMapOperate = false; |
| | | agentStreamByPost( |
| | | { |
| | |
| | | last.content.isLoading = content.isLoading; |
| | | } |
| | | }; |
| | | |
| | | const handleMapCommand = (command: any) => { |
| | | if (!command) return; |
| | | switch (command.operate) { |
| | |
| | | |
| | | case '缩小': |
| | | props.olMap.zoomOut(); |
| | | break; |
| | | case `切换${gaoDeSourceTypeMap[GaoDeSourceType.Vector]}`: |
| | | props.olMap.setSourceType(GaoDeSourceType.Vector); |
| | | break; |
| | | case `切换${gaoDeSourceTypeMap[GaoDeSourceType.Satellite]}`: |
| | | props.olMap.setSourceType(GaoDeSourceType.Satellite); |
| | | break; |
| | | |
| | | case `切换${gaoDeSourceTypeMap[GaoDeSourceType.SatelliteRoad]}`: |
| | | props.olMap.setSourceType(GaoDeSourceType.SatelliteRoad); |
| | | break; |
| | | |
| | | case '显示设备': |
| | | props.olMap.toggleMarkerOverlayVisible(true); |
| | | break; |
| | | case '隐藏设备': |
| | | props.olMap.toggleMarkerOverlayVisible(false); |
| | | break; |
| | | case '聚焦设备': |
| | | props.olMap.adjustViewToMarkers(); |
| | | break; |
| | | } |
| | | refreshAssistantMessage({ value: `已执行操作: ${command.operate}` }); |
| | |
| | | const [userMessage, assistantMessage] = applyMessage(); |
| | | const question = inputText.value; |
| | | inputText.value = ''; |
| | | |
| | | |
| | | startStream(question); |
| | | }; |
| | | |