AILaboratory.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <!-- AI实验室 -->
  3. <div class="home-container">
  4. <!-- 展开收起侧边栏 -->
  5. <div class="icon-expand">
  6. <el-icon
  7. @click="toggleDrawer"
  8. :style="{ color: drawerVisible ? 'white' : '#B6B0D8' }"
  9. >
  10. <component :is="drawerVisible ? Fold : Expand" />
  11. </el-icon>
  12. </div>
  13. <!-- 左侧折叠面板 -->
  14. <transition name="drawer-slide">
  15. <div class="left-group" v-if="drawerVisible">
  16. <el-row class="tac">
  17. <el-col :span="12">
  18. <el-menu
  19. default-active="2"
  20. class="el-menu-vertical-demo"
  21. @open="handleOpen"
  22. @close="handleClose"
  23. >
  24. <el-menu-item
  25. v-for="(item, index) in groupList"
  26. :key="index"
  27. @click="navigateToAI(item)"
  28. >
  29. <el-icon><component :is="item.icon" /></el-icon>
  30. {{ item.title }}
  31. </el-menu-item>
  32. </el-menu>
  33. </el-col>
  34. </el-row>
  35. </div>
  36. </transition>
  37. <!-- 右侧数字人 -->
  38. <div class="number-people">
  39. <div class="title-box">
  40. <div class="box-icon" @click="goBack">
  41. <el-icon class="left-icon"><ArrowLeftBold /></el-icon>
  42. AI实验室 | {{ groupList[2].title }}
  43. </div>
  44. </div>
  45. <!-- 动态渲染数字人 -->
  46. <div class="content-box">
  47. <div
  48. v-for="(person, index) in peopleList"
  49. :key="index"
  50. @click="navigateToAIQuestions(person)"
  51. class="small-box"
  52. >
  53. <div class="people-box">
  54. <img :src="person.image" alt="{{ person.name }}" />
  55. </div>
  56. <div class="people-title">{{ person.name }}</div>
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. </template>
  62. <script setup>
  63. import { ref, onMounted } from 'vue'
  64. import { useRouter } from 'vue-router'
  65. import {
  66. Document,
  67. Menu as IconMenu,
  68. Setting,
  69. ArrowLeftBold,
  70. Fold,
  71. Expand,
  72. ChatLineRound,
  73. Picture,
  74. MagicStick,
  75. Avatar
  76. } from '@element-plus/icons-vue'
  77. const router = useRouter()
  78. // 添加抽屉显示状态
  79. const drawerVisible = ref(true)
  80. // 添加切换抽屉显示状态的函数
  81. const toggleDrawer = () => {
  82. drawerVisible.value = !drawerVisible.value
  83. }
  84. // 返回上一页
  85. const goBack = () => {
  86. router.push('/home')
  87. }
  88. // 引入
  89. import NumberPeople00 from '@/assets/images/xiaozhi.png'
  90. import NumberPeople01 from '@/assets/images/number-people01.png'
  91. import NumberPeople02 from '@/assets/images/number-people02.png'
  92. import NumberPeople03 from '@/assets/images/number-people03.png'
  93. import NumberPeople04 from '@/assets/images/number-people04.png'
  94. import NumberPeople05 from '@/assets/images/number-people05.png'
  95. // 渲染数字人老师及图片
  96. const peopleList = ref([
  97. { id: 21, name: '鲁迅', image: NumberPeople01 , message: '您好,我叫鲁迅,著名的文学家、思想家、革命家、教育家、民主战士,新文化运动的重要参与者,中国现代文学的奠基人之一' },
  98. { id: 22, name: '门捷列夫', image: NumberPeople02 , message: '您好,我是门捷列夫,俄国科学家,发现并归纳元素周期律,依照原子量,制作出世界上第一张元素周期表。你需要问我什么问题呢?' },
  99. { id: 19, name: '牛顿', image: NumberPeople03 , message: '您好,我是牛顿爵士,生于英格兰林肯郡伍尔索普村,英国物理学家、数学家、哲学家。欢迎向我询问物理学、数学、哲学问题。' },
  100. { id: 23, name: '特斯拉', image: NumberPeople04 , message: '您好,我是特斯拉,是塞尔维亚裔美籍发明家 、物理学家、机械工程师、电气工程师。有什么需要帮助的?' },
  101. { id: 18, name: '李白', image: NumberPeople05 , message: '您好,我叫李白,出生于蜀郡绵州昌隆县(一说出生于西域碎叶)。我是伟大的浪漫主义诗人,经我创造书写诗文千余篇,有《李太白集》传世。欢迎向我提问诗文。' }
  102. ])
  103. // 跳转页面携带名字和人物形象
  104. const navigateToAIQuestions = person => {
  105. router.push({
  106. // 跳转问答页面
  107. path: '/ai-questions',
  108. query: { id: person.id, name: person.name, image: person.image, message: person.message }
  109. });
  110. };
  111. // 跳转智能问答
  112. const navigateToAI = (group) => {
  113. if (group.title === "智能问答") {
  114. let person = { id: 10, name: '小智', image: NumberPeople00, message: '您好,我是您的AI智能助手小智,我会尽力回答您的问题或提供有用的建议!!!!' };
  115. router.push({
  116. // 跳转问答页面
  117. path: '/ai-questions',
  118. query: { id: person.id, name: person.name, image: person.image, message: person.message }
  119. });
  120. }
  121. if (group.title === "智能绘画") {
  122. router.push('/ai-painting')
  123. }
  124. if (group.title === '数字人老师') {
  125. router.push('/ai-laboratory') // 添加跳转到AI实验室的逻辑
  126. }
  127. }
  128. // 渲染侧边栏
  129. const groupList = ref([
  130. {
  131. icon: ChatLineRound,
  132. title: '智能问答'
  133. },
  134. {
  135. icon: MagicStick,
  136. title: '智能绘画'
  137. },
  138. {
  139. icon: Avatar,
  140. title: '数字人老师'
  141. }
  142. ])
  143. </script>
  144. <style scoped lang="scss">
  145. @use 'sass:math';
  146. // 定义rpx转换函数
  147. @function rpx($px) {
  148. @return math.div($px, 750) * 100vw;
  149. }
  150. /* 添加过渡样式 */
  151. .drawer-slide-enter-active,
  152. .drawer-slide-leave-active {
  153. transition: all 0.3s ease;
  154. }
  155. .drawer-slide-enter-from,
  156. .drawer-slide-leave-to {
  157. transform: translateX(-100%);
  158. opacity: 0;
  159. }
  160. .home-container {
  161. position: fixed;
  162. top: 0;
  163. left: 0;
  164. right: 0;
  165. bottom: 0;
  166. display: flex;
  167. flex-direction: row;
  168. gap: rpx(0);
  169. background: linear-gradient(
  170. to bottom,
  171. #e2ddfc,
  172. #f1effd
  173. );
  174. }
  175. .icon-expand {
  176. width: rpx(30);
  177. height: rpx(30);
  178. z-index: 9999;
  179. position: absolute;
  180. cursor: pointer;
  181. }
  182. .icon-expand .el-icon {
  183. font-size: rpx(15);
  184. position: absolute;
  185. color: white;
  186. left: rpx(9);
  187. margin-top: rpx(17);
  188. }
  189. .icon-expand .el-icon:active {
  190. color: black;
  191. }
  192. // 侧边栏
  193. .left-group {
  194. width: rpx(135);
  195. height: 100%;
  196. background: linear-gradient(to bottom, #001169, #b4a8e1);
  197. }
  198. .mb-2 {
  199. color: black;
  200. margin-top: rpx(1);
  201. }
  202. .tac ::v-deep(.el-menu) {
  203. background-color: transparent;
  204. border: none;
  205. width: 100%;
  206. margin-top: rpx(55);
  207. margin-left: rpx(10);
  208. }
  209. .el-menu-item {
  210. width: rpx(115);
  211. height: rpx(25);
  212. margin-bottom: rpx(5);
  213. border-radius: rpx(6);
  214. color: white;
  215. font-size: rpx(8);
  216. }
  217. .el-menu-item .el-icon svg {
  218. font-size: rpx(15);
  219. color: white;
  220. }
  221. .el-menu ::v-deep(.el-menu-item:hover){
  222. background: linear-gradient(
  223. to bottom,
  224. #ffefb0,
  225. #ffcc00
  226. );
  227. box-shadow: 0 8px 8px rgb(0, 0, 0, 0.3);
  228. color: black;
  229. font-size: rpx(8);
  230. }
  231. .el-menu-vertical-demo .el-menu-item.is-active {
  232. background: linear-gradient(
  233. to bottom,
  234. #ffefb0,
  235. #ffcc00
  236. );
  237. box-shadow: 0 8px 8px rgb(0, 0, 0, 0.3);
  238. color: black;
  239. font-size: rpx(8);
  240. }
  241. // 右侧数字人内容
  242. .number-people {
  243. flex: 1;
  244. height: 100%;
  245. display: flex;
  246. flex-direction: column;
  247. background: linear-gradient(
  248. to bottom,
  249. #e2ddfc,
  250. #f1effd
  251. );
  252. }
  253. // 标题样式
  254. .title-box {
  255. height: rpx(50);
  256. }
  257. .box-icon {
  258. width: 100%;
  259. height: 100%;
  260. flex: 1;
  261. display: flex; // 添加 flex 布局
  262. align-items: center; // 垂直居中
  263. color: black; // 设置图标颜色为白色
  264. padding-left: rpx(15);
  265. font-size: rpx(10); // 设置图标大小,可按需调整
  266. cursor: pointer; // 添加鼠标指针样式
  267. }
  268. .box-icon .left-icon {
  269. margin-left: rpx(10);
  270. margin-right: rpx(5); // 设置图标和文字之间的间距 ;
  271. }
  272. // 内容样式
  273. .content-box {
  274. flex: 1;
  275. display: flex;
  276. flex-wrap: wrap;
  277. }
  278. .small-box {
  279. flex: 0 0 calc(30% - rpx(10)); // 每个小盒子占三分之一宽度,减去间距
  280. width: rpx(180);
  281. height: rpx(110);
  282. margin-top: rpx(10);
  283. margin-left: rpx(20);
  284. border-radius: rpx(6);
  285. border: 1px solid white;
  286. background: rgba($color: #ffffff, $alpha: 0.5);
  287. position: relative;
  288. cursor: pointer; // 添加鼠标指针样式
  289. }
  290. .people-box {
  291. position: absolute;
  292. top: rpx(-30);
  293. overflow: hidden;
  294. width: rpx(180);
  295. height: rpx(140);
  296. border-radius: rpx(6);
  297. margin-bottom: rpx(5);
  298. // background-color: pink;
  299. display: flex;
  300. justify-content: center;
  301. align-items: center;
  302. }
  303. .people-box img {
  304. width: rpx(100);
  305. margin-top: rpx(75);
  306. // margin-left: rpx(50) auto;
  307. }
  308. .people-title {
  309. font-size: rpx(8);
  310. margin-top: rpx(110);
  311. }
  312. .small-box span {
  313. color: black;
  314. font-size: rpx(8);
  315. }
  316. </style>