gerson
2024-07-03 d2fef8a89e63b1ec06d9aec12953329a1b1779d0
src/views/project/ch/home/Scenario.vue
@@ -1,6 +1,6 @@
<template>
   <!-- 应用场景 -->
   <div class="w100 h100 box-border text-[14px] bg-[#f7f8fa] overflow-hidden pt-[42px] pr-[32px] pb-[50px] pl-[32px]">
   <div class="w100 h100 box-border text-[14px] bg-[#f7f8fa] overflow-hidden pr-[32px] pb-[50px] pl-[32px] pt-[42px]">
      <div class="set-body">
         <div class="productivity recently">
            <p class="mb-[24px] flex items-center">
@@ -8,20 +8,25 @@
               <span>最近使用</span>
            </p>
            <div class="flex flex-wrap items-center">
               <div class="list_app" v-for="item in state.recentlyList" :key="item.ID">
               <div class="list_app" v-for="item in state.recentlyList" :key="item.ID" @click="changeApp(item)">
                  <img :src="item.Icon" alt="" class="w-[20px] h-[20px] mr-[14px]" />
                  <span class="text-[14px] text-[#333f4e]">{{ item.Name }}</span>
               </div>
            </div>
         </div>
         <div class="productivity">
         <div
            class="productivity"
            v-for="product in state.productivityList"
            :key="product.section_id"
            v-show="product.children && product.children.length > 0"
         >
            <div class="mb-[24px]">
               <span class="productivity-span"><i></i>生产力</span>
               <span class="productivity-span"><i></i>{{ product.section_name }}</span>
            </div>
            <div class="flex flex-wrap items-center">
               <div class="list_app" v-for="item in state.recentlyList" :key="item.ID">
               <div class="list_app" v-for="item in product.children" :key="item.section_id">
                  <img :src="item.Icon" alt="" class="w-[20px] h-[20px] mr-[14px]" />
                  <span class="text-[14px] text-[#333f4e]">{{ item.Name }}</span>
                  <span class="text-[14px] text-[#333f4e]">{{ item.section_name }}</span>
               </div>
            </div>
         </div>
@@ -30,7 +35,10 @@
</template>
<script setup lang="ts">
import { reactive } from 'vue';
import { onMounted, reactive } from 'vue';
import { getSectionByAllList } from '/@/api/ai/chat';
import router from '/@/router';
let state = reactive({
   recentlyList: [
      {
@@ -43,7 +51,32 @@
         Name: '工作内容',
         Icon: '/static/images/scene/scene_2.png',
      },
   ],
   ], //最近使用
   productivityList: [], //通用的场景
});
//切换到应用场景详情的事件
const changeApp = (item: any) => {
   if (item.ID === 2) {
      router.push({
         name: 'ScenarioDetails',
      });
   }
};
const getSectionByList = async () => {
   const res = await getSectionByAllList();
   const iconList = ['/static/images/scene/scene_1.png', '/static/images/scene/scene_2.png', '/static/images/scene/scene_3.png'];
   res.sections.forEach((item: any) => {
      if (item.children && item.children.length > 0) {
         item.children = item.children.map((child: any) => {
            child.Icon = iconList[Math.floor(Math.random() * 3)];
            return child;
         });
      }
   });
   state.productivityList = res.sections;
};
onMounted(() => {
   getSectionByList();
});
</script>
<style scoped lang="scss">
@@ -72,7 +105,7 @@
         }
      }
      .list_app {
         width: 140px;
         width: 180px;
         display: flex;
         align-items: center;
         border-radius: 8px;
@@ -83,6 +116,24 @@
         cursor: pointer;
         position: relative;
         background-color: #fff;
         &:hover {
            border: 1px solid #1c86ff;
         }
      }
      .productivity-span {
         font-size: 14px;
         color: #081735;
         line-height: 20px;
         display: flex;
         align-items: center;
         i {
            display: block;
            width: 4px;
            height: 14px;
            background: #1c86ff;
            border-radius: 0 100px 100px 0;
            margin-right: 10px;
         }
      }
   }
   .recently {