From 84db37acc19a165583ecaa01558849ff78efa2c8 Mon Sep 17 00:00:00 2001 From: yangyin <1850366751@qq.com> Date: 星期二, 29 十月 2024 13:58:45 +0800 Subject: [PATCH] 修改调接口的次数 --- src/views/project/ch/home/Home.vue | 21 +++------------------ src/stores/chatRoom.ts | 23 +++++++++++++++++++++-- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/stores/chatRoom.ts b/src/stores/chatRoom.ts index 70ab0e1..4523155 100644 --- a/src/stores/chatRoom.ts +++ b/src/stores/chatRoom.ts @@ -1,7 +1,6 @@ import { computed, ref } from 'vue'; -import { getSectionList } from '../api/ai/chat'; +import { getSectionList,getSelectSample, getUserTemplateList } from '../api/ai/chat'; import type { ChatRoomItem } from '../layout/component/sidebar/components/types'; - /** * Room 鍏宠仈鐨勪竴浜涢厤缃� */ @@ -87,11 +86,31 @@ const res = await getSectionList(); sceneGroupList.value = res?.groups ?? []; }; +const getSelectListSample = async () => { + const res1 = getSelectSample({}); + const res2 = getUserTemplateList(); + const [sampleListPromise, templateListPromise] = await Promise.allSettled([res1, res2]); + const samples = (sampleListPromise as any).value?.samples ?? []; + const templateSamples = ((templateListPromise as any).value?.templates ?? []).map((item) => ({ + group_id: item.template_group, + sample_id: item.template_id, + sample_title: item.template_title, + sample_question: item.template_value, + + //#region ====================== template 鐗规湁瀛楁 ====================== + template_create_time: item.create_time, + template_type: item.template_type, + isTemplate: true, + //#endregion + })); + exampleSceneList.value = samples.concat(templateSamples).map((item) => ({ ...item, Icon: '/static/images/wave/ChatImg.png' })); +}; /** * 鑾峰彇鍏ㄥ眬鎵�鏈夋暟鎹� */ export const getAllData = async () => { getSceneGroupList(); + getSelectListSample(); }; //#endregion diff --git a/src/views/project/ch/home/Home.vue b/src/views/project/ch/home/Home.vue index 54fe903..6db92df 100644 --- a/src/views/project/ch/home/Home.vue +++ b/src/views/project/ch/home/Home.vue @@ -38,7 +38,8 @@ import waterBottom from './component/waterRight/bottom.vue'; import waterCenter from './component/waterRight/center.vue'; import waterTop from './component/waterRight/top.vue'; -import { getSelectSample, getUserTemplateList } from '/@/api/ai/chat'; +import { exampleSceneList } from '/@/stores/chatRoom'; + import CustomDrawer from '/@/components/drawer/CustomDrawer.vue'; let state = reactive({ isShowAdvanceExample: false, @@ -58,23 +59,7 @@ }; //鑾峰彇妯$増鍒楄〃 const getSelectListSample = async () => { - const res1 = getSelectSample({}); - const res2 = getUserTemplateList(); - const [sampleListPromise, templateListPromise] = await Promise.allSettled([res1, res2]); - const samples = (sampleListPromise as any).value?.samples ?? []; - const templateSamples = ((templateListPromise as any).value?.templates ?? []).map((item) => ({ - group_id: item.template_group, - sample_id: item.template_id, - sample_title: item.template_title, - sample_question: item.template_value, - - //#region ====================== template 鐗规湁瀛楁 ====================== - template_create_time: item.create_time, - template_type: item.template_type, - isTemplate: true, - //#endregion - })); - exampleList.value = samples.concat(templateSamples).map((item) => ({ ...item, Icon: '/static/images/wave/ChatImg.png' })); + exampleList.value = exampleSceneList.value; }; const tagListClick = (tag) => { isFinishPromise?.then(() => { -- Gitblit v1.9.3