GrandCanal.vue 7.7 KB

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