From cf7eda004123f2ee07bfa7d05f51f71f9dbb4bcd Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期四, 18 七月 2024 11:48:59 +0800 Subject: [PATCH] Merge branch 'master' of http://47.103.154.90:83/r/WI/Web.V1.0 --- src/components/chat/chatComponents/mapCom/MapCom.vue | 2 + src/components/chat/Chat.vue | 11 +++-- src/components/chat/chatComponents/htmlCom/HTMLCom.vue | 3 + src/components/chat/chatComponents/recordSetCom/RecordSetCom.vue | 9 +--- src/components/chat/chatComponents/normalTextCom/NormalTextCom.vue | 7 +-- src/utils/request.ts | 16 ++++--- src/components/chat/chatComponents/knowledgeCom/KnowledgeCom.vue | 3 + src/components/chat/chatComponents/common.ts | 14 ++++++- src/components/chat/model/types.ts | 3 + src/components/chat/chatComponents/summaryCom/SummaryCom.vue | 10 ++--- 10 files changed, 45 insertions(+), 33 deletions(-) diff --git a/src/components/chat/Chat.vue b/src/components/chat/Chat.vue index 71ac205..cf71224 100644 --- a/src/components/chat/Chat.vue +++ b/src/components/chat/Chat.vue @@ -22,7 +22,8 @@ class="text-sm rounded-[6px] p-4 leading-relaxed" :style="{ backgroundColor: item.role === RoleEnum.user ? 'rgb(197 224 255)' : 'white' }" > - <component :is="answerTypeMapCom[item.content.type]" :data="item.content.values" :error="item.content.error" /> + <div v-if="item.content.errCode === ErrorCode.Message" class="text-red-500 w-full">{{ item.content.msg }}</div> + <component v-else :is="answerTypeMapCom[item.content.type]" :data="item.content.values" /> </div> <div v-if="item.role === RoleEnum.assistant" class="absolute flex items-center right-0 mr-2 mt-2 space-x-2"> @@ -92,6 +93,7 @@ import { activeChatRoom, activeLLMId, activeRoomId, activeSampleId, activeSectionAId, roomConfig } from '/@/stores/chatRoom'; import { v4 as uuidv4 } from 'uuid'; import _ from 'lodash'; +import { ErrorCode } from '/@/utils/request'; const chatWidth = '75%'; @@ -118,7 +120,7 @@ const parseContent = (res) => { let content: ChatContent = { type: AnswerType.Text, - values: '鍙戠敓閿欒锛�', + values: '瑙f瀽澶辫触锛�', }; switch (res.answer_type) { @@ -146,7 +148,6 @@ content = { type: AnswerType.Summary, values: res.summary, - error: res.json_msg, }; break; case AnswerType.Url: @@ -158,11 +159,13 @@ default: content = { type: AnswerType.Text, - values: '鍙戠敓閿欒锛�', + values: '瑙f瀽澶辫触锛�', }; break; } content.askMoreList = _.orderBy(res.context_history, [(item) => Number(item.radio)], ['desc']); + content.errCode = res?.err_code; + content.msg = res?.json_msg; return content; }; //#region ====================== 鏌ヨ杩涘害 ====================== diff --git a/src/components/chat/chatComponents/common.ts b/src/components/chat/chatComponents/common.ts index 62f6760..ce27b57 100644 --- a/src/components/chat/chatComponents/common.ts +++ b/src/components/chat/chatComponents/common.ts @@ -1,3 +1,6 @@ +import { buildProps } from 'element-plus/es/utils/vue/props/runtime'; +import type { ExtractPropTypes, PropType } from 'vue'; + export const timeDataOptionToContent = (opt) => { const headerList = [opt.xAxis[0]] .concat(opt.yAxis) @@ -36,7 +39,14 @@ 'path://M445.7 609.8c0 19.4 10.3 37.3 27.1 46.9 16.8 9.7 37.4 9.7 54.2 0 16.8-9.7 27.1-27.6 27.1-46.9 0-29.9-24.3-54.2-54.2-54.2s-54.2 24.3-54.2 54.2z m0 0M179.2 613.8c-42.2 0-76.5 34.3-76.5 76.5s34.3 76.5 76.5 76.5 76.5-34.3 76.5-76.5-34.3-76.5-76.5-76.5z m0 0M144.9 401.1c0 29 23.5 52.5 52.5 52.5s52.5-23.5 52.5-52.5-23.5-52.5-52.5-52.5-52.5 23.5-52.5 52.5z m0 0M598.7 404c0 42.2 34.3 76.5 76.5 76.5 42.3 0 76.5-34.3 76.5-76.5 0-42.3-34.3-76.5-76.5-76.5-42.3 0-76.5 34.3-76.5 76.5z m0 0M849.3 169.2c-42.2 0-76.5 34.3-76.5 76.5s34.3 76.5 76.5 76.5 76.5-34.3 76.5-76.5-34.3-76.5-76.5-76.5z m0 0M261.6 583.1c0 13.2 7.1 25.5 18.5 32.1 11.5 6.6 25.6 6.6 37.1 0s18.5-18.9 18.5-32.1c0-20.5-16.6-37.1-37.1-37.1-20.4 0.1-37 16.7-37 37.1z m0 0M276.8 425.1c0 42.3 34.3 76.5 76.5 76.5 42.3 0 76.5-34.3 76.5-76.5s-34.3-76.5-76.5-76.5-76.5 34.3-76.5 76.5z m0 0M445.7 421.4c0 18.5 9.9 35.5 25.8 44.8 16 9.2 35.7 9.2 51.7 0s25.8-26.3 25.8-44.8c0-28.5-23.1-51.7-51.7-51.7-28.5 0-51.6 23.2-51.6 51.7z m0 0M398.2 208.8c0 42.3 34.3 76.5 76.5 76.5s76.5-34.3 76.5-76.5c0-42.3-34.3-76.5-76.5-76.5s-76.5 34.3-76.5 76.5z m0 0M693.7 599.2c0 42.3 34.3 76.5 76.5 76.5s76.5-34.3 76.5-76.5-34.3-76.5-76.5-76.5c-42.3 0-76.5 34.3-76.5 76.5z m0 0M62.1 828.9H959v60.7H62.1z', bar: 'path://M580.8 228.8h-136v500.8h136V228.8z m-40 460.8h-56V268.8h56v420.8zM788.8 420.8h-136v308.8h136V420.8z m-40 268.8h-56V460.8h56v228.8zM372.8 326.4h-136v401.6h136V326.4z m-40 363.2h-56V366.4h56v323.2zM208 788.8h608v40H208z', - line:'path://M664.1 783c-3.8 0-7.6-0.2-11.3-0.5-36.3-3.1-68.9-20.6-96.9-52.1-28.4-32-52.5-79.4-71.4-140.8-32.4-105-66.1-182.6-100.3-230.6-25.5-35.8-50.2-54-73.4-54h-0.4c-38.8 0.4-84.8 51-129.3 142.7-37 76.2-59.4 153-59.7 153.8L64 582.6c1-3.4 24.3-83.1 63.7-164.3 56.8-117 118.1-176.6 182.1-177.3h1c43 0 83.8 26.7 121.2 79.3 38.2 53.7 75.1 137.5 109.5 249.3 29.3 94.9 68.3 145.1 116 149.1 21.3 1.8 45.6-5.2 72.2-20.9 24.5-14.4 50.3-35.8 76.8-63.5 49.6-51.9 87.7-111.9 100.1-137.6L960 526c-14.6 30.4-56.4 96.4-111.4 154-30.4 31.8-60.6 56.6-89.9 73.9-32.8 19.3-64.6 29.1-94.6 29.1z' + line: 'path://M664.1 783c-3.8 0-7.6-0.2-11.3-0.5-36.3-3.1-68.9-20.6-96.9-52.1-28.4-32-52.5-79.4-71.4-140.8-32.4-105-66.1-182.6-100.3-230.6-25.5-35.8-50.2-54-73.4-54h-0.4c-38.8 0.4-84.8 51-129.3 142.7-37 76.2-59.4 153-59.7 153.8L64 582.6c1-3.4 24.3-83.1 63.7-164.3 56.8-117 118.1-176.6 182.1-177.3h1c43 0 83.8 26.7 121.2 79.3 38.2 53.7 75.1 137.5 109.5 249.3 29.3 94.9 68.3 145.1 116 149.1 21.3 1.8 45.6-5.2 72.2-20.9 24.5-14.4 50.3-35.8 76.8-63.5 49.6-51.9 87.7-111.9 100.1-137.6L960 526c-14.6 30.4-56.4 96.4-111.4 154-30.4 31.8-60.6 56.6-89.9 73.9-32.8 19.3-64.6 29.1-94.6 29.1z', }; -export const SCATTER_SYMBOL_SIZE = 4 \ No newline at end of file +export const SCATTER_SYMBOL_SIZE = 4; + +export const chatComProps = buildProps({ + data: { + type: Object as PropType<any>, + } +} as const); +export type ChatComPropsType = ExtractPropTypes<typeof chatComProps>; diff --git a/src/components/chat/chatComponents/htmlCom/HTMLCom.vue b/src/components/chat/chatComponents/htmlCom/HTMLCom.vue index 1bc5780..4141f53 100644 --- a/src/components/chat/chatComponents/htmlCom/HTMLCom.vue +++ b/src/components/chat/chatComponents/htmlCom/HTMLCom.vue @@ -17,8 +17,9 @@ <script setup lang="ts"> import IframeResizer from '@iframe-resizer/vue/iframe-resizer.vue'; import { ref } from 'vue'; +import { chatComProps } from '../common'; const iframeRef = ref<HTMLIFrameElement>(null); -defineProps(['data']); +const props = defineProps(chatComProps); </script> <style scoped lang="scss"></style> diff --git a/src/components/chat/chatComponents/knowledgeCom/KnowledgeCom.vue b/src/components/chat/chatComponents/knowledgeCom/KnowledgeCom.vue index 6bbdf98..dff677d 100644 --- a/src/components/chat/chatComponents/knowledgeCom/KnowledgeCom.vue +++ b/src/components/chat/chatComponents/knowledgeCom/KnowledgeCom.vue @@ -16,9 +16,10 @@ <script setup lang="ts"> import { md } from '../../libs/markdown'; +import { chatComProps } from '../common'; -defineProps(['data']) +const props = defineProps(chatComProps); const pageLinkClick = (item) => { const nwin = window.open(''); diff --git a/src/components/chat/chatComponents/mapCom/MapCom.vue b/src/components/chat/chatComponents/mapCom/MapCom.vue index 95c7c7d..01ae60d 100644 --- a/src/components/chat/chatComponents/mapCom/MapCom.vue +++ b/src/components/chat/chatComponents/mapCom/MapCom.vue @@ -5,8 +5,10 @@ <script setup lang="ts"> import { onMounted, ref } from 'vue'; import { GaoDeMap } from '/@/model/map/GaoDeMap'; +import { chatComProps } from '../common'; let gaoDeMap = new GaoDeMap(); const containerRef = ref<HTMLDivElement>(null); +const props = defineProps(chatComProps); onMounted(async () => { await gaoDeMap.init({ diff --git a/src/components/chat/chatComponents/normalTextCom/NormalTextCom.vue b/src/components/chat/chatComponents/normalTextCom/NormalTextCom.vue index e5c9988..83e0296 100644 --- a/src/components/chat/chatComponents/normalTextCom/NormalTextCom.vue +++ b/src/components/chat/chatComponents/normalTextCom/NormalTextCom.vue @@ -4,11 +4,8 @@ <script setup lang="ts"> import { md } from '../../libs/markdown'; +import { chatComProps } from '../common'; -const props = defineProps({ - data: { - type: String, - }, -}); +const props = defineProps(chatComProps); </script> <style scoped lang="scss"></style> diff --git a/src/components/chat/chatComponents/recordSetCom/RecordSetCom.vue b/src/components/chat/chatComponents/recordSetCom/RecordSetCom.vue index e45cb04..fc29950 100644 --- a/src/components/chat/chatComponents/recordSetCom/RecordSetCom.vue +++ b/src/components/chat/chatComponents/recordSetCom/RecordSetCom.vue @@ -32,16 +32,13 @@ import { ChartTypeEnum, chartTypeMapEchart, chartTypeMapName } from '../types'; import type { RecordSetValues } from '/@/api/ai/chat'; import { dateRegex } from '/@/utils/toolsValidate'; -import { PATH_ICON, SCATTER_SYMBOL_SIZE, timeDataOptionToContent } from '../common'; +import { PATH_ICON, SCATTER_SYMBOL_SIZE, chatComProps, timeDataOptionToContent } from '../common'; const activeName = ref('first'); const chartRef = ref<HTMLDivElement>(null); const selectChartType = ref<ChartTypeEnum>(ChartTypeEnum.Line); -const props = defineProps({ - data: { - type: Object as PropType<RecordSetValues>, - }, -}); +const props = defineProps(chatComProps); + const selectChartTypeChange = () => { drawChart(); diff --git a/src/components/chat/chatComponents/summaryCom/SummaryCom.vue b/src/components/chat/chatComponents/summaryCom/SummaryCom.vue index 4338465..ab0a51f 100644 --- a/src/components/chat/chatComponents/summaryCom/SummaryCom.vue +++ b/src/components/chat/chatComponents/summaryCom/SummaryCom.vue @@ -26,10 +26,8 @@ <div v-if="urlList && urlList.length > 0" class="w-full"> <!-- <HTMLCom data="http://101.133.133.173:8019/ai_html/views/demo/html/MonthlyPay.html" v-for="(item, index) in urlList" :key="index"></HTMLCom> --> <HTMLCom :data="item.url" v-for="(item, index) in urlList" :key="index"></HTMLCom> - </div> </template> - <div v-else class="text-red-500">{{ error }}</div> </div> </template> @@ -39,11 +37,11 @@ import _ from 'lodash'; import { computed, onMounted, ref } from 'vue'; import { AnswerType } from '../../model/types'; -import { PATH_ICON, SCATTER_SYMBOL_SIZE, timeDataOptionToContent } from '../common'; +import { PATH_ICON, SCATTER_SYMBOL_SIZE, chatComProps, timeDataOptionToContent } from '../common'; import HTMLCom from '../htmlCom/HTMLCom.vue'; import { ChartTypeEnum, chartTypeMapEchart } from '../types'; import { axisLabelFormatter } from '/@/utils/chart'; -const props = defineProps(['data', 'error']); +const props = defineProps(chatComProps); const selectChartType = ref<ChartTypeEnum>(ChartTypeEnum.Line); @@ -147,8 +145,8 @@ grid: { // bottom: 120, // right: '15%', - left:'5%', - right:'5%', + left: '5%', + right: '5%', bottom: '8%', }, toolbox: { diff --git a/src/components/chat/model/types.ts b/src/components/chat/model/types.ts index 490d425..6b10ebd 100644 --- a/src/components/chat/model/types.ts +++ b/src/components/chat/model/types.ts @@ -42,8 +42,9 @@ export type ChatContent = { type: AnswerType; values: any; - error?: string; + msg?: string; askMoreList?:ContextHistory[]; + errCode?:string; }; export interface ChatMessage { diff --git a/src/utils/request.ts b/src/utils/request.ts index 822ca60..2330610 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -12,6 +12,10 @@ //#region ====================== 鍚庣 res.err_code ====================== export const enum ErrorCode { /** @description 鏉冮檺楠岃瘉澶辫触 */ + Message = 'MESSAGE', + /** @description 鍐呴儴閿欒 */ + Exception = 'EXCEPTION', + /** @description 鏃犳潈浣跨敤 */ Auth = 'AUTH', } //#endregion @@ -88,14 +92,12 @@ handleNoAuth(); throw '鏉冮檺楠岃瘉澶辫触'; } + break; + case ErrorCode.Exception: + ElMessage.error('鍐呴儴閿欒锛�'); + throw '鍐呴儴閿欒'; } - // const msg = serveData.json_msg ?? ''; - - // const error = serveData?.err_code ? `${msg ? `銆�${serveData.err_code}銆慲 : serveData.err_code}` : ''; - // const tip = error + msg || '璇锋眰澶辫触'; - // ElMessage.error(tip); - // const url = res.request.responseURL; - // throw new Error(url + '\n' + tip); + } return res.data; }, -- Gitblit v1.9.3