yangyin
2024-10-29 84db37acc19a165583ecaa01558849ff78efa2c8
修改调接口的次数
已修改2个文件
44 ■■■■ 文件已修改
src/stores/chatRoom.ts 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/project/ch/home/Home.vue 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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
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(() => {