AILaboratory.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <!-- AI实验室 -->
  3. <div class="home-container">
  4. <!-- 左侧折叠面板 -->
  5. <div class="left-group">
  6. <el-row class="tac">
  7. <el-col :span="12">
  8. <el-menu
  9. default-active="2"
  10. class="el-menu-vertical-demo"
  11. @open="handleOpen"
  12. @close="handleClose"
  13. >
  14. <el-menu-item @click="handleMenuItemClick(item)" v-for="(item, index) in groupList" :key="index">
  15. <el-icon><component :is="item.icon" /></el-icon>
  16. <span>{{ item.title }}</span>
  17. </el-menu-item>
  18. </el-menu>
  19. </el-col>
  20. </el-row>
  21. </div>
  22. <!-- 右侧数字人 -->
  23. <div class="number-people">
  24. <div class="title-box">
  25. <div class="box-icon" @click="goBack">
  26. <el-icon class="left-icon"><ArrowLeftBold /></el-icon>
  27. AI实验室 | {{ groupList[2].title }}
  28. </div>
  29. </div>
  30. <div class="content-box">
  31. <!-- 动态渲染数字人 -->
  32. <div
  33. v-for="(person, index) in peopleList"
  34. :key="index"
  35. @click="navigateToAIQuestions(person)"
  36. class="small-box"
  37. >
  38. <div class="people-box">
  39. <img :src="person.image" alt="{{ person.name }}" />
  40. </div>
  41. <div class="people-title">{{ person.name }}</div>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. </template>
  47. <script setup>
  48. import { ref, onMounted } from 'vue'
  49. import { useRouter } from 'vue-router'
  50. import {
  51. Document,
  52. Menu as IconMenu,
  53. Setting,
  54. ArrowLeftBold
  55. } from '@element-plus/icons-vue'
  56. const router = useRouter()
  57. // 返回上一页
  58. const goBack = () => {
  59. router.go(-1)
  60. }
  61. // 引入
  62. import NumberPeople01 from '@/assets/images/number-people01.png'
  63. import NumberPeople02 from '@/assets/images/number-people02.png'
  64. import NumberPeople03 from '@/assets/images/number-people03.png'
  65. import NumberPeople04 from '@/assets/images/number-people04.png'
  66. import NumberPeople05 from '@/assets/images/number-people05.png'
  67. // 渲染数字人老师及图片
  68. const peopleList = ref([
  69. { id: 10, name: '小智', image: NumberPeople01 },
  70. { id: 21, name: '鲁迅', image: NumberPeople01 },
  71. { id: 22, name: '门捷列夫', image: NumberPeople02 },
  72. { id: 19, name: '牛顿', image: NumberPeople03 },
  73. { id: 23, name: '特斯拉', image: NumberPeople04 },
  74. { id: 18, name: '李白', image: NumberPeople05 }
  75. ])
  76. // 跳转页面携带名字和人物形象
  77. const navigateToAIQuestions = person => {
  78. router.push({
  79. // 跳转问答页面
  80. path: '/ai-questions',
  81. query: { id: person.id, name: person.name, image: person.image }
  82. })
  83. // console.log(person.id)
  84. }
  85. // 处理菜单项点击事件
  86. const handleMenuItemClick = (item) => {
  87. if (item.title === '智能绘图') {
  88. router.push('/ai-painting')
  89. }
  90. }
  91. // 渲染侧边栏
  92. const groupList = ref([
  93. {
  94. icon: IconMenu,
  95. title: '智能问答'
  96. },
  97. {
  98. icon: Document,
  99. title: '智能绘图',
  100. },
  101. {
  102. icon: Setting,
  103. title: '数字人老师'
  104. }
  105. ])
  106. </script>
  107. <style scoped lang="scss">
  108. @use 'sass:math';
  109. // 定义rpx转换函数
  110. @function rpx($px) {
  111. @return math.div($px, 750) * 100vw;
  112. }
  113. .home-container {
  114. position: fixed;
  115. top: 0;
  116. left: 0;
  117. right: 0;
  118. bottom: 0;
  119. display: flex;
  120. flex-direction: row;
  121. gap: rpx(0);
  122. }
  123. // 侧边栏
  124. .left-group {
  125. width: rpx(150);
  126. height: 100%;
  127. background: linear-gradient(to bottom, #001169, #b4a8e1);
  128. }
  129. .mb-2 {
  130. color: black;
  131. margin-top: rpx(1);
  132. }
  133. .tac ::v-deep(.el-menu) {
  134. background-color: transparent;
  135. border: none;
  136. width: 100%;
  137. margin-top: rpx(30);
  138. margin-left: rpx(10);
  139. }
  140. .el-menu-item {
  141. width: rpx(130);
  142. height: rpx(25);
  143. margin-bottom: rpx(5);
  144. border-radius: rpx(6);
  145. }
  146. .el-menu-item .el-icon svg {
  147. font-size: rpx(15);
  148. color: white;
  149. }
  150. .el-menu-item span {
  151. color: white;
  152. font-size: rpx(8);
  153. padding-left: rpx(5);
  154. }
  155. .el-menu ::v-deep(.el-menu-item:hover),
  156. .el-menu ::v-deep(.el-menu-item:focus),
  157. .el-menu ::v-deep(.el-menu-item:active) {
  158. background: linear-gradient(
  159. to bottom,
  160. #fee78a,
  161. #ffce1b
  162. ); /* 设置悬停、聚焦、点击状态下的背景色 */
  163. }
  164. // 右侧数字人内容
  165. .number-people {
  166. flex: 1;
  167. height: 100%;
  168. display: flex;
  169. flex-direction: column; /* 子元素上下排列 */
  170. background-color: #e5e1fc;
  171. }
  172. // 标题样式
  173. .title-box {
  174. height: rpx(50);
  175. }
  176. .box-icon {
  177. width: 100%;
  178. height: 100%;
  179. flex: 1;
  180. display: flex; // 添加 flex 布局
  181. align-items: center; // 垂直居中
  182. color: black; // 设置图标颜色为白色
  183. padding-left: rpx(15);
  184. font-size: rpx(10); // 设置图标大小,可按需调整
  185. cursor: pointer; // 添加鼠标指针样式
  186. }
  187. .box-icon .left-icon {
  188. margin-left: rpx(10);
  189. margin-right: rpx(5); // 设置图标和文字之间的间距 ;
  190. }
  191. // 内容样式
  192. .content-box {
  193. flex: 1;
  194. display: flex;
  195. flex-wrap: wrap;
  196. }
  197. .small-box {
  198. width: rpx(180);
  199. height: rpx(110);
  200. margin-top: rpx(10);
  201. margin-left: rpx(15);
  202. border-radius: rpx(6);
  203. border: 1px solid white;
  204. background: rgba($color: #ffffff, $alpha: 0.5);
  205. position: relative;
  206. cursor: pointer; // 添加鼠标指针样式
  207. }
  208. .people-box {
  209. position: absolute;
  210. top: rpx(-30);
  211. overflow: hidden;
  212. width: rpx(180);
  213. height: rpx(140);
  214. border-radius: rpx(6);
  215. margin-bottom: rpx(5);
  216. // background-color: pink;
  217. display: flex;
  218. justify-content: center;
  219. align-items: center;
  220. }
  221. .people-box img {
  222. width: rpx(100);
  223. margin-top: rpx(75);
  224. }
  225. .people-title {
  226. font-size: rpx(8);
  227. margin-top: rpx(110);
  228. }
  229. .small-box span {
  230. color: black;
  231. font-size: rpx(8);
  232. }
  233. </style>