yangyin
2024-07-22 e7d76d371384bf0fb9a8638ad1919be0902127ec
fix: 修改模板列表一直调用接口的问题
已修改2个文件
54 ■■■■ 文件已修改
src/components/drawer/CustomDrawer.vue 39 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/project/ch/home/Home.vue 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/drawer/CustomDrawer.vue
@@ -129,11 +129,10 @@
<script setup lang="ts">
import { Search } from '@element-plus/icons-vue';
import { computed, onMounted, reactive, ref, toRefs, watch } from 'vue';
import { computed, onMounted, reactive, ref, watch } from 'vue';
import { getSelectSample, getUserTemplateList } from '/@/api/ai/chat';
import { useSearch } from '/@/hooks/useSearch';
import { activeRoomId, activeSampleId, setRoomConfig } from '/@/stores/chatRoom';
import emitter from '/@/utils/mitt';
import { debounce } from '/@/utils/util';
let state = reactive({
    tabNameList: [
@@ -217,6 +216,10 @@
    inputInstruct: '', //可修改指令
    exampleRandomContent: [],
    exampleContent: [],
    listSampleLoading: false,
    listInstructLoading: false,
    listSampleExpand: false,
    listInstructExpand: false,
});
const instructContentList = ref([]); //指令列表
const exampleList = ref([]); //示例列表
@@ -227,15 +230,15 @@
const emit = defineEmits(['updateChatInput']);
const rightBox = computed(() => (isShow.value ? 354 : 0));
onMounted(() => {
    getSelectListSample();
    getUserTemplate();
});
onMounted(() => {});
//获取模版列表
const getSelectListSample = async () => {
    state.listSampleLoading = true;
    const res = await getSelectSample({
        section_b_id: '',
    }).finally(() => {
        state.listSampleLoading = false;
    });
    // console.log(res, 63);
    state.exampleRandomContent = res.samples;
@@ -250,6 +253,7 @@
    });
    exampleList.value = res.samples;
    state.exampleContent = array;
    state.listSampleExpand = true;
};
//随机生成颜色
const randomHexColor = () => {
@@ -264,12 +268,16 @@
};
//获取用户模板
const getUserTemplate = async () => {
    const res = await getUserTemplateList();
    state.listInstructLoading = true;
    const res = await getUserTemplateList().finally(() => {
        state.listInstructLoading = false;
    });
    instructContentList.value = res.templates;
};
//切换到指令/提问
const handleTabClick = (item) => {
    state.activeName = item.ID;
    getTableData();
};
//标签点击事件(提问示例)
const handleLabelClick = (item) => {
@@ -290,6 +298,22 @@
};
const toggleShow = () => {
    isShow.value = !isShow.value;
    if (!isShow.value) {
        getTableData();
    }
};
const getTableData = () => {
    console.log('🚀 ~ state.activeName:', state.activeName);
    if (state.activeName == 1) {
        if (state.listSampleExpand) return;
        getSelectListSample();
        state.listSampleExpand = true;
    }
    if (state.activeName == 2) {
        if (state.listInstructExpand) return;
        getUserTemplate();
        state.listInstructExpand = true;
    }
};
//关闭高级示例
const handleCloseTemplate = () => {
@@ -339,6 +363,7 @@
    }
);
//#endregion
defineExpose({ getTableData });
</script>
<style scoped lang="scss">
.exampleSlide {
src/views/project/ch/home/Home.vue
@@ -7,7 +7,7 @@
                        <div class="homeBox w100 h-full">
                            <div class="flex items-center h-full overflow-hidden">
                                <div class="flex items-center flex-column">
                                    <waterTop ref="topRef"/>
                                    <waterTop ref="topRef" />
                                    <waterCenter
                                        @advanceExampleClick="advanceExampleClick"
                                        :isShowAdvanceExample="state.isShowAdvanceExample"
@@ -17,10 +17,7 @@
                                    <waterBottom />
                                </div>
                                <CustomDrawer
                                    v-model:isShow = "state.isShowAdvanceExample"
                                    @updateChatInput="updateChatInput"
                                />
                                <CustomDrawer v-model:isShow="state.isShowAdvanceExample" ref="customDrawerrRef" @updateChatInput="updateChatInput" />
                            </div>
                        </div>
                        <!-- <p class="declare">
@@ -47,14 +44,16 @@
const topRef = ref(null);
const waterCenterRef = ref(null);
const customDrawerrRef = ref(null);
const updateChatInput = (val) => {
    topRef.value.updateChatInput(val)
    topRef.value.updateChatInput(val);
};
const advanceExampleClick = (status: boolean) => {
    state.isShowAdvanceExample = status;
    if (status) {
        customDrawerrRef.value.getTableData();
    }
};
</script>
<style scoped lang="scss">
.pc-chat_room {