From aefc8f607405a5e4ce67ac62810b68fac9d93f89 Mon Sep 17 00:00:00 2001 From: yangyin <1850366751@qq.com> Date: 星期二, 29 十月 2024 11:52:48 +0800 Subject: [PATCH] 修改页面 --- src/views/project/ch/home/component/waterRight/center.vue | 120 ++++++++++++++++++++++++++++++++++------------------------- 1 files changed, 69 insertions(+), 51 deletions(-) diff --git a/src/views/project/ch/home/component/waterRight/center.vue b/src/views/project/ch/home/component/waterRight/center.vue index 8d240d0..f24ab45 100644 --- a/src/views/project/ch/home/component/waterRight/center.vue +++ b/src/views/project/ch/home/component/waterRight/center.vue @@ -6,90 +6,93 @@ <span class="split"></span> <span class="change cursor-pointer" @click="advanceExampleClick">楂樼骇绀轰緥 ></span> </div> - <div class="cursor-pointer"> - <span class="mr-1 changeBatch" @click="batchChange">鎹竴鎵�</span> - <i class="iconfont icon-shuaxin"></i> + <div class="cursor-pointer" @click="batchChange"> + <span class="mr-1 changeBatch">鎹竴鎵�</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="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 height="80" :interval="6000" indicator-position="none"> + <el-carousel-item v-for="(group, index) in state.m_groupArr" :key="index" class="set-carousel-item"> + <div + class="main_item flex items-center cursor-pointer" + v-for="(item, index) in group" + :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 { computed, onMounted, reactive, ref } from 'vue'; -import { getSelectSample } from '/@/api/ai/chat'; +import { reactive, ref } from 'vue'; import { activeRoomId, activeSampleId, setRoomConfig } from '/@/stores/chatRoom'; -import emitter from '/@/utils/mitt'; let state = reactive({ exampleContent: [], - exampleRandomContent: [], + isShowExample: false, + m_groupArr: [], }); const exampleList = ref([]); //妯$増鍒楄〃 const emits = defineEmits<{ (event: 'advanceExampleClick', data): void; + (event: 'updateChatInput', val): void; }>(); -onMounted(() => { - getSelectListSample(); -}); -const groupedArray = computed(() => { +const props = defineProps(['exampleList']); + +const initGroupedArr = () => { const groups = []; let i = 0; - while (state.exampleRandomContent.length > i) { - groups.push(state.exampleRandomContent.slice(i, (i += 4))); + while (state.exampleContent.length > i) { + groups.push(state.exampleContent.slice(i, (i += 4))); } - return groups; -}); -//鑾峰彇妯$増鍒楄〃 -const getSelectListSample = async () => { - const res = await getSelectSample({ - section_b_id: '', - }); - // console.log(res, 63); - 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; + state.m_groupArr = groups; }; const changeExample = (item) => { + emits('updateChatInput', item.sample_question); setRoomConfig(activeRoomId.value, 'isAnswerByLLM', false); activeSampleId.value = item.sample_id; + // topGroupId.value = item.section_a_id; }; //鎹竴鎵� const batchChange = () => { - const index = Math.floor(Math.random() * groupedArray.value.length); - state.exampleContent = groupedArray.value[index]; + let groups = state.m_groupArr; + // 鎵撲贡鎵规椤哄簭 + for (let i = groups.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + [groups[i], groups[j]] = [groups[j], groups[i]]; + } + state.m_groupArr = groups; }; //鎵撳紑楂樼骇绀轰緥 const advanceExampleClick = () => { emits('advanceExampleClick', true); }; +const tagListClick = (tagList) => { + let result = []; + tagList.forEach((tag) => { + props.exampleList.forEach((sample) => { + if (tag == sample.group_id) { + result.push(sample); + } + }); + }); + state.exampleContent = result; + initGroupedArr(); +}; //闅忔満鐢熸垚棰滆壊 const randomHexColor = () => { return `#${Math.floor(Math.random() * 16777215) @@ -97,7 +100,7 @@ .padEnd(6, '0')}`; }; defineExpose({ - getSelectListSample, + tagListClick, }); </script> <style scoped lang="scss"> @@ -141,6 +144,7 @@ width: calc(50% - 16px); margin: 8px; padding: 12px; + height: 84px; border: 1px solid #d9dbde; border-radius: 5px; background-color: transparent; @@ -175,6 +179,9 @@ font-weight: 500; height: 16px; transition: background-color 0.2s; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } p { font-size: 12px; @@ -199,6 +206,10 @@ } } } + .set-carousel-item { + display: flex; + flex-wrap: wrap; + } } } @@ -217,4 +228,11 @@ :deep(.el-drawer__body) { overflow-x: hidden; } +:deep(.el-carousel--horizontal) { + width: 100%; +} +:deep(.el-carousel__container) { + width: 100%; + height: 200px !important; +} </style> -- Gitblit v1.9.3