AIQuestions.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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-if="drawerVisible" />
  23. <!-- 原左侧折叠面板和右侧AI问答 -->
  24. <div class="content-wrapper">
  25. <div class="left-group2">
  26. <div class="title-box">
  27. <div class="box-icon" @click="goBack">
  28. <el-icon class="left-icon"><ArrowLeftBold /></el-icon>
  29. {{ personName }}
  30. </div>
  31. </div>
  32. </div>
  33. <TextToText
  34. :personId="personId"
  35. :personName="personName"
  36. :personImage="personImage"
  37. :personIntroduce="personIntroduce"
  38. />
  39. </div>
  40. </div>
  41. </template>
  42. <script setup>
  43. import { ref, onMounted, watch } from "vue";
  44. import { useRouter, useRoute } from "vue-router";
  45. import LeftPanel from "@/components/LeftPanel.vue";
  46. import { ArrowLeftBold } from "@element-plus/icons-vue";
  47. import TextToText from "@/components/ai/text/TextToText.vue";
  48. const leftPanelRef = ref(null);
  49. // 抽屉显示状态
  50. const drawerVisible = ref(true);
  51. // 添加切换抽屉显示状态的函数
  52. const toggleDrawer = () => {
  53. drawerVisible.value = !drawerVisible.value;
  54. };
  55. // 返回上一页
  56. const goBack = () => {
  57. // 根据来源页面决定返回路径
  58. const fromPage = route.query.from;
  59. if (fromPage === 'ai-ennumerals') {
  60. router.push("/ai-ennumerals");
  61. } else if (fromPage === 'ai-laboratory' || !fromPage) {
  62. // 默认返回ai-laboratory
  63. router.push("/ai-laboratory");
  64. } else {
  65. router.push(fromPage);
  66. }
  67. };
  68. const router = useRouter();
  69. const route = useRoute();
  70. const personId = ref(route.query.id);
  71. const personName = ref(route.query.name);
  72. const personIntroduce = ref(route.query.message);
  73. const personImage = ref(route.query.image);
  74. // 路由参数变化监听
  75. watch(
  76. () => route.query,
  77. (newQuery, oldQuery) => {
  78. // 只有当id变化时才更新数据,避免不必要的刷新
  79. if (newQuery.id && newQuery.id !== oldQuery?.id) {
  80. // 更新相关数据
  81. personId.value = newQuery.id;
  82. personName.value = newQuery.name;
  83. personIntroduce.value = newQuery.message;
  84. personImage.value = newQuery.image;
  85. }
  86. },
  87. { immediate: true, deep: true }
  88. );
  89. </script>
  90. <style scoped lang="scss">
  91. @use "sass:math";
  92. // 定义rpx转换函数
  93. @function rpx($px) {
  94. @return math.div($px, 750) * 100vw;
  95. }
  96. .home-container {
  97. position: fixed;
  98. top: 0;
  99. left: 0;
  100. right: 0;
  101. bottom: 0;
  102. display: flex;
  103. flex-direction: row;
  104. gap: rpx(0);
  105. background: linear-gradient(to bottom, #e2ddfc, #f1effd);
  106. }
  107. .icon-expand {
  108. width: rpx(8);
  109. height: rpx(35);
  110. border-top-right-radius: rpx(5);
  111. border-bottom-right-radius: rpx(5);
  112. z-index: 9999;
  113. position: absolute;
  114. top: 50%;
  115. left: 18%;
  116. transform: translateY(-50%);
  117. background-color: #44449c;
  118. cursor: pointer;
  119. clip-path: polygon(0 0, 100% 15%, 100% 85%, 0 100%);
  120. display: flex;
  121. justify-content: center;
  122. align-items: center;
  123. transition: all 0.3s ease;
  124. }
  125. .icon-expand .vertical-lines {
  126. color: #8a78d0;
  127. font-size: rpx(10);
  128. }
  129. .content-wrapper {
  130. display: flex;
  131. flex: 1;
  132. }
  133. // 侧边栏
  134. .left-group2 {
  135. // width: rpx(150);
  136. height: 100%;
  137. display: flex;
  138. background-color: #ece9fd;
  139. }
  140. .title-box {
  141. height: rpx(50);
  142. position: absolute;
  143. }
  144. .box-icon {
  145. width: 100%;
  146. height: 100%;
  147. flex: 1;
  148. display: flex;
  149. align-items: center;
  150. color: black;
  151. padding-left: rpx(15);
  152. font-size: rpx(10);
  153. cursor: pointer;
  154. }
  155. .box-icon .left-icon {
  156. margin-left: rpx(10);
  157. margin-right: rpx(5);
  158. }
  159. </style>