AILaboratory.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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 v-for="(item, index) in groupList" :key="index"
  15. @click="navigateToAI(item)">
  16. <el-icon><component :is="item.icon" /></el-icon>
  17. <span>{{ item.title }}</span>
  18. </el-menu-item>
  19. </el-menu>
  20. </el-col>
  21. </el-row>
  22. </div>
  23. <!-- 右侧数字人 -->
  24. <div class="number-people">
  25. <div class="title-box">
  26. <div class="box-icon" @click="goBack">
  27. <el-icon class="left-icon"><ArrowLeftBold /></el-icon>
  28. AI实验室 | {{ groupList[2].title }}
  29. </div>
  30. </div>
  31. <div class="content-box">
  32. <!-- 动态渲染数字人 -->
  33. <div
  34. v-for="(person, index) in peopleList"
  35. :key="index"
  36. @click="navigateToAIQuestions(person)"
  37. class="small-box"
  38. >
  39. <div class="people-box">
  40. <img :src="person.image" alt="{{ person.name }}" />
  41. </div>
  42. <div class="people-title">{{ person.name }}</div>
  43. </div>
  44. </div>
  45. </div>
  46. </div>
  47. </template>
  48. <script setup>
  49. import { ref, onMounted } from 'vue'
  50. import { useRouter } from 'vue-router'
  51. import {
  52. Document,
  53. Menu as IconMenu,
  54. Setting,
  55. ArrowLeftBold
  56. } from '@element-plus/icons-vue'
  57. const router = useRouter()
  58. // 返回上一页
  59. const goBack = () => {
  60. router.go(-1)
  61. }
  62. // 引入
  63. import NumberPeople00 from '@/assets/images/xiaozhi.png'
  64. import NumberPeople01 from '@/assets/images/number-people01.png'
  65. import NumberPeople02 from '@/assets/images/number-people02.png'
  66. import NumberPeople03 from '@/assets/images/number-people03.png'
  67. import NumberPeople04 from '@/assets/images/number-people04.png'
  68. import NumberPeople05 from '@/assets/images/number-people05.png'
  69. // 渲染数字人老师及图片
  70. const peopleList = ref([
  71. { id: 21, name: '鲁迅', image: NumberPeople01 , message: '您好,我叫鲁迅,著名的文学家、思想家、革命家、教育家、民主战士,新文化运动的重要参与者,中国现代文学的奠基人之一' },
  72. { id: 22, name: '门捷列夫', image: NumberPeople02 , message: '您好,我是门捷列夫,俄国科学家,发现并归纳元素周期律,依照原子量,制作出世界上第一张元素周期表。你需要问我什么问题呢?' },
  73. { id: 19, name: '牛顿', image: NumberPeople03 , message: '您好,我是牛顿爵士,生于英格兰林肯郡伍尔索普村,英国物理学家、数学家、哲学家。欢迎向我询问物理学、数学、哲学问题。' },
  74. { id: 23, name: '特斯拉', image: NumberPeople04 , message: '您好,我是特斯拉,是塞尔维亚裔美籍发明家 、物理学家、机械工程师、电气工程师。有什么需要帮助的?' },
  75. { id: 18, name: '李白', image: NumberPeople05 , message: '您好,我叫李白,出生于蜀郡绵州昌隆县(一说出生于西域碎叶)。我是伟大的浪漫主义诗人,经我创造书写诗文千余篇,有《李太白集》传世。欢迎向我提问诗文。' }
  76. ])
  77. // 跳转页面携带名字和人物形象
  78. const navigateToAIQuestions = person => {
  79. router.push({
  80. // 跳转问答页面
  81. path: '/ai-questions',
  82. query: { id: person.id, name: person.name, image: person.image, message: person.message }
  83. });
  84. };
  85. // 跳转智能问答
  86. const navigateToAI = (group) => {
  87. if (group.title === "智能问答") {
  88. let person = { id: 10, name: '小智', image: NumberPeople00, message: '您好,我是您的AI智能助手小智,我会尽力回答您的问题或提供有用的建议!!!!' };
  89. router.push({
  90. // 跳转问答页面
  91. path: '/ai-questions',
  92. query: { id: person.id, name: person.name, image: person.image, message: person.message }
  93. });
  94. }
  95. if (group.title === "智能绘图") {
  96. router.push('/ai-painting')
  97. }
  98. };
  99. // 渲染侧边栏
  100. const groupList = ref([
  101. {
  102. icon: IconMenu,
  103. title: '智能问答'
  104. },
  105. {
  106. icon: Document,
  107. title: '智能绘图',
  108. },
  109. {
  110. icon: Setting,
  111. title: '数字人老师'
  112. }
  113. ])
  114. </script>
  115. <style scoped lang="scss">
  116. @use 'sass:math';
  117. // 定义rpx转换函数
  118. @function rpx($px) {
  119. @return math.div($px, 750) * 100vw;
  120. }
  121. .home-container {
  122. position: fixed;
  123. top: 0;
  124. left: 0;
  125. right: 0;
  126. bottom: 0;
  127. display: flex;
  128. flex-direction: row;
  129. gap: rpx(0);
  130. }
  131. // 侧边栏
  132. .left-group {
  133. width: rpx(150);
  134. height: 100%;
  135. background: linear-gradient(to bottom, #001169, #b4a8e1);
  136. }
  137. .mb-2 {
  138. color: black;
  139. margin-top: rpx(1);
  140. }
  141. .tac ::v-deep(.el-menu) {
  142. background-color: transparent;
  143. border: none;
  144. width: 100%;
  145. margin-top: rpx(30);
  146. margin-left: rpx(10);
  147. }
  148. .el-menu-item {
  149. width: rpx(130);
  150. height: rpx(25);
  151. margin-bottom: rpx(5);
  152. border-radius: rpx(6);
  153. }
  154. .el-menu-item .el-icon svg {
  155. font-size: rpx(15);
  156. color: white;
  157. }
  158. .el-menu-item span {
  159. color: white;
  160. font-size: rpx(8);
  161. padding-left: rpx(5);
  162. }
  163. .el-menu ::v-deep(.el-menu-item:hover),
  164. .el-menu ::v-deep(.el-menu-item:focus),
  165. .el-menu ::v-deep(.el-menu-item:active) {
  166. background: linear-gradient(
  167. to bottom,
  168. #fee78a,
  169. #ffce1b
  170. ); /* 设置悬停、聚焦、点击状态下的背景色 */
  171. }
  172. // 右侧数字人内容
  173. .number-people {
  174. flex: 1;
  175. height: 100%;
  176. display: flex;
  177. flex-direction: column; /* 子元素上下排列 */
  178. background-color: #e5e1fc;
  179. }
  180. // 标题样式
  181. .title-box {
  182. height: rpx(50);
  183. }
  184. .box-icon {
  185. width: 100%;
  186. height: 100%;
  187. flex: 1;
  188. display: flex; // 添加 flex 布局
  189. align-items: center; // 垂直居中
  190. color: black; // 设置图标颜色为白色
  191. padding-left: rpx(15);
  192. font-size: rpx(10); // 设置图标大小,可按需调整
  193. cursor: pointer; // 添加鼠标指针样式
  194. }
  195. .box-icon .left-icon {
  196. margin-left: rpx(10);
  197. margin-right: rpx(5); // 设置图标和文字之间的间距 ;
  198. }
  199. // 内容样式
  200. .content-box {
  201. flex: 1;
  202. display: flex;
  203. flex-wrap: wrap;
  204. }
  205. .small-box {
  206. width: rpx(180);
  207. height: rpx(110);
  208. margin-top: rpx(10);
  209. margin-left: rpx(15);
  210. border-radius: rpx(6);
  211. border: 1px solid white;
  212. background: rgba($color: #ffffff, $alpha: 0.5);
  213. position: relative;
  214. cursor: pointer; // 添加鼠标指针样式
  215. }
  216. .people-box {
  217. position: absolute;
  218. top: rpx(-30);
  219. overflow: hidden;
  220. width: rpx(180);
  221. height: rpx(140);
  222. border-radius: rpx(6);
  223. margin-bottom: rpx(5);
  224. // background-color: pink;
  225. display: flex;
  226. justify-content: center;
  227. align-items: center;
  228. }
  229. .people-box img {
  230. width: rpx(100);
  231. margin-top: rpx(75);
  232. }
  233. .people-title {
  234. font-size: rpx(8);
  235. margin-top: rpx(110);
  236. }
  237. .small-box span {
  238. color: black;
  239. font-size: rpx(8);
  240. }
  241. </style>