index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <!-- AI实验室 - 英文数字人老师 -->
  3. <div class="home-container">
  4. <!-- 展开收起侧边栏 -->
  5. <div
  6. class="icon-expand"
  7. :style="{
  8. backgroundColor: drawerVisible ? '#44449c' : '#7F70C840',
  9. left: drawerVisible ? '18%' : '0',
  10. }"
  11. @click="toggleDrawer"
  12. >
  13. <span
  14. class="vertical-lines"
  15. :style="{
  16. color: drawerVisible ? '#8a78d0' : 'white',
  17. }"
  18. >||</span
  19. >
  20. </div>
  21. <!-- 侧边栏组件 -->
  22. <LeftPanel ref="leftPanelRef" v-show="drawerVisible" />
  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. 返回首页|英文数字人老师
  29. </div>
  30. </div>
  31. <!-- 动态渲染数字人 -->
  32. <div class="content-box">
  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="" />
  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, useRoute } from "vue-router";
  51. import {
  52. Document,
  53. Menu as IconMenu,
  54. Setting,
  55. ArrowLeftBold,
  56. Fold,
  57. Expand,
  58. ChatLineRound,
  59. Picture,
  60. MagicStick,
  61. User,
  62. } from "@element-plus/icons-vue";
  63. import LeftPanel from "@/components/LeftPanel.vue";
  64. const leftPanelRef = ref(null);
  65. // 数字人接口
  66. import { teacherList } from "@/api/teachers.js";
  67. import {homeRoutes} from "@/router/index.js";
  68. // 抽屉显示状态
  69. const drawerVisible = ref(true);
  70. // 切换抽屉显示状态的函数
  71. const toggleDrawer = () => {
  72. drawerVisible.value = !drawerVisible.value;
  73. };
  74. const router = useRouter();
  75. const route = useRoute();
  76. // 返回上一页
  77. const goBack = () => {
  78. router.push(homeRoutes.home);
  79. };
  80. // 数字人接口
  81. const grade = ref("");
  82. const peopleList = ref([]);
  83. onMounted(async () => {
  84. try {
  85. grade.value = route.query.grade || localStorage.getItem("selectedGrade");
  86. // 获取小学低年级数据
  87. const juniorRes = await teacherList({ category: grade.value + 'EN'});
  88. peopleList.value = juniorRes.data.list.map((person) => ({
  89. id: person.id,
  90. name: person.name,
  91. image: person.model2dPath,
  92. message: person.systemMessage,
  93. default: person.questTip,
  94. }));
  95. } catch (error) {
  96. console.error("获取小学低年级数据失败:", error);
  97. }
  98. });
  99. // 跳转页面携带名字和人物形象
  100. const navigateToAIQuestions = (person) => {
  101. router.push({
  102. path: "/ai-questions",
  103. state: {
  104. ...person,
  105. from: "ai-ennumerals",
  106. category: grade.value,
  107. }
  108. });
  109. };
  110. </script>
  111. <style scoped lang="scss">
  112. @use "sass:math";
  113. // 定义rpx转换函数
  114. @function rpx($px) {
  115. @return math.div($px, 750) * 100vw;
  116. }
  117. /* 添加过渡样式 */
  118. .drawer-slide-enter-active,
  119. .drawer-slide-leave-active {
  120. transition: all 0.3s ease;
  121. }
  122. .drawer-slide-enter-from,
  123. .drawer-slide-leave-to {
  124. transform: translateX(-100%);
  125. opacity: 0;
  126. transition: all 0.3s ease;
  127. }
  128. .home-container {
  129. position: fixed;
  130. top: 0;
  131. left: 0;
  132. right: 0;
  133. bottom: 0;
  134. display: flex;
  135. flex-direction: row;
  136. gap: rpx(0);
  137. background: linear-gradient(to bottom, #e2ddfc, #f1effd);
  138. }
  139. .icon-expand {
  140. width: rpx(8);
  141. height: rpx(35);
  142. border-top-right-radius: rpx(5);
  143. border-bottom-right-radius: rpx(5);
  144. z-index: 9999;
  145. position: absolute;
  146. top: 50%;
  147. left: 18%;
  148. transform: translateY(-50%);
  149. background-color: #44449c;
  150. cursor: pointer; // 添加鼠标指针样式
  151. clip-path: polygon(0 0, 100% 15%, 100% 85%, 0 100%);
  152. display: flex;
  153. justify-content: center;
  154. align-items: center;
  155. transition: all 0.3s ease;
  156. }
  157. .icon-expand .vertical-lines {
  158. color: #8a78d0;
  159. font-size: rpx(10);
  160. }
  161. .menu-icon {
  162. width: rpx(11);
  163. height: rpx(11);
  164. margin-right: rpx(2);
  165. }
  166. // 侧边栏
  167. .left-group {
  168. width: rpx(135);
  169. height: 100%;
  170. background: linear-gradient(to bottom, #001169, #8a78d0);
  171. }
  172. .mb-2 {
  173. color: black;
  174. margin-top: rpx(1);
  175. }
  176. .tac ::v-deep(.el-menu) {
  177. background-color: transparent;
  178. border: none;
  179. width: 100%;
  180. margin-top: rpx(55);
  181. margin-left: rpx(10);
  182. }
  183. .el-menu-item {
  184. width: rpx(115);
  185. height: rpx(25);
  186. margin-bottom: rpx(5);
  187. border-radius: rpx(6);
  188. color: white;
  189. font-size: rpx(8);
  190. }
  191. .el-menu-item .el-icon svg {
  192. font-size: rpx(15);
  193. color: white;
  194. }
  195. .el-menu ::v-deep(.el-menu-item:hover) {
  196. background: linear-gradient(to bottom, #ffefb0, #ffcc00);
  197. box-shadow: 0 8px 8px rgb(0, 0, 0, 0.3);
  198. color: black;
  199. font-size: rpx(8);
  200. }
  201. .el-menu-vertical-demo .el-menu-item.is-active {
  202. background: linear-gradient(to bottom, #ffefb0, #ffcc00);
  203. box-shadow: 0 8px 8px rgb(0, 0, 0, 0.3);
  204. color: black;
  205. font-size: rpx(8);
  206. }
  207. .el-menu .el-menu-item.is-active {
  208. background: linear-gradient(to bottom, #fee78a, #ffce1b);
  209. color: black;
  210. font-size: rpx(8);
  211. box-shadow: 0 4px 8px rgba(3, 3, 3, 0.3);
  212. }
  213. // 右侧数字人内容
  214. .number-people {
  215. flex: 1;
  216. height: 100%;
  217. display: flex;
  218. flex-direction: column;
  219. background: linear-gradient(to bottom, #e2ddfc, #f1effd);
  220. }
  221. // 标题样式
  222. .title-box {
  223. height: rpx(35);
  224. }
  225. .box-icon {
  226. width: 100%;
  227. height: 100%;
  228. flex: 1;
  229. display: flex; // 添加 flex 布局
  230. align-items: center; // 垂直居中
  231. color: black; // 设置图标颜色为白色
  232. padding-left: rpx(15);
  233. font-size: rpx(10); // 设置图标大小,可按需调整
  234. cursor: pointer; // 添加鼠标指针样式
  235. }
  236. .box-icon .left-icon {
  237. margin-left: rpx(10);
  238. margin-right: rpx(5); // 设置图标和文字之间的间距 ;
  239. }
  240. // 内容样式
  241. .content-box {
  242. // width: 100%;
  243. box-sizing: border-box;
  244. cursor: pointer; // 鼠标指针样式
  245. flex: 1;
  246. display: flex;
  247. flex-wrap: wrap;
  248. overflow-y: auto;
  249. // justify-content: center;
  250. }
  251. .content-box::-webkit-scrollbar {
  252. width: rpx(2);
  253. }
  254. .content-box::-webkit-scrollbar-track {
  255. background: transparent; // 设置滚动条轨道背景
  256. border-radius: rpx(3); // 设置滚动条轨道圆角
  257. }
  258. .content-box::-webkit-scrollbar-thumb {
  259. background: linear-gradient(to bottom, hsl(230, 100%, 21%), #8a78d0);
  260. border-radius: rpx(3); // 设置滚动条滑块圆角
  261. }
  262. .content-box::-webkit-scrollbar-thumb:hover {
  263. background: linear-gradient(to bottom, hsl(230, 100%, 21%), #8a78d0);
  264. }
  265. .small-box {
  266. flex: 0 0 calc(30% - rpx(10)); // 每个小盒子占三分之一宽度,减去间距
  267. // width: rpx(180);
  268. height: rpx(110);
  269. margin-top: rpx(30);
  270. margin-left: rpx(25);
  271. border-radius: rpx(6);
  272. border: 1px solid white;
  273. background: rgba($color: #ffffff, $alpha: 0.5);
  274. position: relative;
  275. cursor: pointer; // 鼠标指针样式
  276. display: flex; // 此行,启用flex布局
  277. flex-direction: column; // 此行,垂直排列子元素
  278. align-items: center;
  279. }
  280. .people-box {
  281. position: absolute;
  282. top: rpx(-30);
  283. overflow: hidden;
  284. width: rpx(180);
  285. height: rpx(140);
  286. border-radius: rpx(6);
  287. margin-bottom: rpx(5);
  288. // background-color: pink;
  289. display: flex;
  290. justify-content: center;
  291. align-items: center;
  292. }
  293. .people-box img {
  294. width: rpx(100);
  295. margin-top: rpx(75);
  296. // margin-left: rpx(50) auto;
  297. transition: transform 0.3s ease; // 过渡效果
  298. }
  299. .people-box img:hover {
  300. transform: scale(1.1); // 鼠标经过时放大1.1倍
  301. }
  302. .people-title {
  303. font-size: rpx(8);
  304. margin-top: rpx(110);
  305. }
  306. .small-box span {
  307. color: black;
  308. font-size: rpx(8);
  309. }
  310. </style>