| | |
| | | |
| | | <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: [ |
| | |
| | | inputInstruct: '', //可修改指令 |
| | | exampleRandomContent: [], |
| | | exampleContent: [], |
| | | listSampleLoading: false, |
| | | listInstructLoading: false, |
| | | listSampleExpand: false, |
| | | listInstructExpand: false, |
| | | }); |
| | | const instructContentList = ref([]); //指令列表 |
| | | const exampleList = ref([]); //示例列表 |
| | |
| | | |
| | | 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; |
| | |
| | | }); |
| | | exampleList.value = res.samples; |
| | | state.exampleContent = array; |
| | | state.listSampleExpand = true; |
| | | }; |
| | | //随机生成颜色 |
| | | const randomHexColor = () => { |
| | |
| | | }; |
| | | //获取用户模板 |
| | | 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) => { |
| | |
| | | }; |
| | | 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 = () => { |
| | |
| | | } |
| | | ); |
| | | //#endregion |
| | | defineExpose({ getTableData }); |
| | | </script> |
| | | <style scoped lang="scss"> |
| | | .exampleSlide { |