| | |
| | | <div class="flex item-center"> |
| | | <span>提问示例</span> |
| | | <span class="split"></span> |
| | | <span class="change cursor-pointer">高级示例 ></span> |
| | | <span class="change cursor-pointer" @click="advanceExampleClick">高级示例 ></span> |
| | | </div> |
| | | <div class="cursor-pointer"> |
| | | <span class="mr-1 changeBatch">换一批</span> |
| | | <i class="iconfont icon-shuaxin"></i> |
| | | <span class="mr-1 changeBatch" @click="batchChange">换一批</span> |
| | | <i class="myiconfont icon-shuaxin"></i> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="main"> |
| | | <div |
| | | class="main_item flex items-center cursor-pointer" |
| | | v-for="(item, index) in state.exampleContent" |
| | | :key="item.ID" |
| | | :class="{ main_item_active: item.ID === state.exampleIndex }" |
| | | @click="changeExample(item)" |
| | | > |
| | | <div class="left flex items-center justify-center" :class="['color' + index]"> |
| | | <img :src="item.Icon" alt="" /> |
| | | </div> |
| | | <div class="right"> |
| | | <h4>{{ item.Title }}</h4> |
| | | <p>{{ item.Content }}</p> |
| | | </div> |
| | | </div> |
| | | <el-carousel height="80" :interval="6000" indicator-position="none"> |
| | | <el-carousel-item v-for="group in batchSourceData" :key="group" class="set-carousel-item"> |
| | | <div |
| | | class="main_item flex items-center cursor-pointer" |
| | | v-for="(item, index) in state.exampleContent" |
| | | :key="index" |
| | | :class="{ main_item_active: item.sample_id === activeSampleId }" |
| | | @click="changeExample(item)" |
| | | > |
| | | <div class="left flex items-center justify-center" :class="['color' + index]"> |
| | | <img :src="item.Icon" alt="" /> |
| | | </div> |
| | | <div class="right"> |
| | | <h4>{{ item.sample_title }}</h4> |
| | | <p>{{ item.sample_question }}</p> |
| | | </div> |
| | | </div> |
| | | </el-carousel-item> |
| | | </el-carousel> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup lang="ts"> |
| | | import { reactive } from 'vue'; |
| | | import { computed, onMounted, reactive, ref } from 'vue'; |
| | | import { getSelectSample } from '/@/api/ai/chat'; |
| | | import { activeRoomId, activeSampleId, activeSectionAId, setRoomConfig } from '/@/stores/chatRoom'; |
| | | let state = reactive({ |
| | | exampleContent: [ |
| | | { |
| | | ID: 1, |
| | | Icon: '/static/images/wave/ChatImg.png', |
| | | Title: '解读李四的反应', |
| | | Content: '张三打了李四一巴掌,李四对张三说:"你是不是没吃饭",李四说这句话含义是?', |
| | | }, |
| | | { |
| | | ID: 2, |
| | | Icon: '/static/images/wave/ChatImg.png', |
| | | Title: '解释努力与内卷的区别', |
| | | Content: '怎么解释努力和内卷的区别?', |
| | | }, |
| | | { |
| | | ID: 3, |
| | | Icon: '/static/images/wave/ChatImg.png', |
| | | Title: '其他问题', |
| | | Content: '请搜索你想知道的问题', |
| | | }, |
| | | { |
| | | ID: 4, |
| | | Icon: '/static/images/wave/ChatImg.png', |
| | | Title: '给宝宝取有文化内涵的名字', |
| | | Content: '请以诗经中的典故给男宝宝取名,姓顾,名字要求3个字,给5个名字供我选择。', |
| | | }, |
| | | ], |
| | | exampleIndex: 0, |
| | | exampleContent: [], |
| | | exampleRandomContent: [], |
| | | }); |
| | | const changeExample = (item) => { |
| | | state.exampleIndex = item.ID; |
| | | const exampleList = ref([]); //模版列表 |
| | | const emits = defineEmits<{ |
| | | (event: 'advanceExampleClick', data): void; |
| | | (event: 'updateChatInput', val): void; |
| | | }>(); |
| | | onMounted(() => { |
| | | getSelectListSample(); |
| | | }); |
| | | //换一批数据源 |
| | | const groupedArray = computed(() => { |
| | | const groups = []; |
| | | let i = 0; |
| | | while (state.exampleRandomContent.length > i) { |
| | | groups.push(state.exampleRandomContent.slice(i, (i += 4))); |
| | | } |
| | | return groups; |
| | | }); |
| | | //自动播放 |
| | | const batchSourceData = computed(() => { |
| | | const batch = []; |
| | | let i = 0; |
| | | while (exampleList.value.length > i) { |
| | | batch.push(exampleList.value.slice(i, (i += 4))); |
| | | } |
| | | return batch; |
| | | }); |
| | | //获取模版列表 |
| | | const getSelectListSample = async () => { |
| | | const res = await getSelectSample({}); |
| | | state.exampleRandomContent = res.samples; |
| | | const array = []; |
| | | res.samples.forEach((sample, index) => { |
| | | sample.Icon = '/static/images/wave/ChatImg.png'; |
| | | sample.BgColor = randomHexColor(); |
| | | if (index < 4) { |
| | | array.push(sample); |
| | | } |
| | | }); |
| | | exampleList.value = res.samples; |
| | | state.exampleContent = array; |
| | | }; |
| | | |
| | | const changeExample = (item) => { |
| | | emits('updateChatInput', item.sample_question); |
| | | setRoomConfig(activeRoomId.value, 'isAnswerByLLM', false); |
| | | activeSampleId.value = item.sample_id; |
| | | activeSectionAId.value = item.section_a_id; |
| | | }; |
| | | //换一批 |
| | | const batchChange = () => { |
| | | const index = Math.floor(Math.random() * groupedArray.value.length); |
| | | state.exampleContent = groupedArray.value[index]; |
| | | }; |
| | | //打开高级示例 |
| | | const advanceExampleClick = () => { |
| | | emits('advanceExampleClick', true); |
| | | }; |
| | | const tagListClick = (group_item) => { |
| | | const curGroupID = group_item.p_group_id; |
| | | const curID = group_item.group_id; |
| | | const exampleContent = exampleList.value; |
| | | let curGroupIDs = []; |
| | | if (!curGroupID) { |
| | | curGroupIDs.push(curID); |
| | | } else { |
| | | exampleContent.forEach((item) => { |
| | | curGroupIDs.push(item.group_id); |
| | | }); |
| | | } |
| | | let result = []; |
| | | curGroupIDs.forEach((curItem) => { |
| | | exampleContent.forEach((sample) => { |
| | | if (curItem == sample.group_id) result.push(sample); |
| | | }); |
| | | }); |
| | | batchChange(); |
| | | }; |
| | | //随机生成颜色 |
| | | const randomHexColor = () => { |
| | | return `#${Math.floor(Math.random() * 16777215) |
| | | .toString(16) |
| | | .padEnd(6, '0')}`; |
| | | }; |
| | | defineExpose({ |
| | | getSelectListSample, |
| | | tagListClick, |
| | | }); |
| | | </script> |
| | | <style scoped lang="scss"> |
| | | .pc-prompts { |
| | |
| | | } |
| | | } |
| | | } |
| | | .set-carousel-item { |
| | | display: flex; |
| | | flex-wrap: wrap; |
| | | } |
| | | } |
| | | } |
| | | |
| | | :deep(.el-drawer__header) { |
| | | padding: 30px 20px 26px !important; |
| | | box-sizing: border-box; |
| | | width: 100%; |
| | | background-color: #e0e7fb; |
| | | |
| | | position: relative; |
| | | |
| | | height: unset !important; |
| | | margin-bottom: unset !important; |
| | | border-bottom: unset !important; |
| | | } |
| | | :deep(.el-drawer__body) { |
| | | overflow-x: hidden; |
| | | } |
| | | :deep(.el-carousel--horizontal) { |
| | | width: 100%; |
| | | } |
| | | :deep(.el-carousel__container) { |
| | | width: 100%; |
| | | height: 200px !important; |
| | | } |
| | | </style> |