| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- <template>
- <!-- 数字人智能问答 -->
- <div class="home-container">
- <!-- 展开收起侧边栏 -->
- <div
- class="icon-expand"
- :style="{
- backgroundColor: drawerVisible ? '#44449c' : '#7F70C840',
- left: drawerVisible ? '18%' : '0',
- }"
- @click="toggleDrawer"
- >
- <span
- class="vertical-lines"
- :style="{
- color: drawerVisible ? '#8a78d0' : 'white',
- }"
- >||</span
- >
- </div>
- <!-- 左侧折叠面板 -->
- <LeftPanel ref="leftPanelRef" v-if="drawerVisible" />
- <!-- 原左侧折叠面板和右侧AI问答 -->
- <div class="content-wrapper">
- <div class="left-group2">
- <div class="title-box">
- <div class="box-icon" @click="goBack">
- <el-icon class="left-icon"><ArrowLeftBold /></el-icon>
- {{ personName }}
- </div>
- </div>
- </div>
-
- <TextToText
- :personId="personId"
- :personName="personName"
- :personImage="personImage"
- :personIntroduce="personIntroduce"
- />
- </div>
- </div>
- </template>
- <script setup>
- import { ref, onMounted, watch } from "vue";
- import { useRouter, useRoute } from "vue-router";
- import LeftPanel from "@/components/LeftPanel.vue";
- import { ArrowLeftBold } from "@element-plus/icons-vue";
- import TextToText from "@/components/ai/text/TextToText.vue";
- const leftPanelRef = ref(null);
- // 抽屉显示状态
- const drawerVisible = ref(true);
- // 添加切换抽屉显示状态的函数
- const toggleDrawer = () => {
- drawerVisible.value = !drawerVisible.value;
- };
- // 返回上一页
- const goBack = () => {
- // 根据来源页面决定返回路径
- const fromPage = route.query.from;
- if (fromPage === 'ai-ennumerals') {
- router.push("/ai-ennumerals");
- } else if (fromPage === 'ai-laboratory' || !fromPage) {
- // 默认返回ai-laboratory
- router.push("/ai-laboratory");
- } else {
- router.push(fromPage);
- }
- };
- const router = useRouter();
- const route = useRoute();
- const personId = ref(route.query.id);
- const personName = ref(route.query.name);
- const personIntroduce = ref(route.query.message);
- const personImage = ref(route.query.image);
- // 路由参数变化监听
- watch(
- () => route.query,
- (newQuery, oldQuery) => {
- // 只有当id变化时才更新数据,避免不必要的刷新
- if (newQuery.id && newQuery.id !== oldQuery?.id) {
- // 更新相关数据
- personId.value = newQuery.id;
- personName.value = newQuery.name;
- personIntroduce.value = newQuery.message;
- personImage.value = newQuery.image;
- }
- },
- { immediate: true, deep: true }
- );
- </script>
- <style scoped lang="scss">
- @use "sass:math";
- // 定义rpx转换函数
- @function rpx($px) {
- @return math.div($px, 750) * 100vw;
- }
- .home-container {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- display: flex;
- flex-direction: row;
- gap: rpx(0);
- background: linear-gradient(to bottom, #e2ddfc, #f1effd);
- }
- .icon-expand {
- width: rpx(8);
- height: rpx(35);
- border-top-right-radius: rpx(5);
- border-bottom-right-radius: rpx(5);
- z-index: 9999;
- position: absolute;
- top: 50%;
- left: 18%;
- transform: translateY(-50%);
- background-color: #44449c;
- cursor: pointer;
- clip-path: polygon(0 0, 100% 15%, 100% 85%, 0 100%);
- display: flex;
- justify-content: center;
- align-items: center;
- transition: all 0.3s ease;
- }
- .icon-expand .vertical-lines {
- color: #8a78d0;
- font-size: rpx(10);
- }
- .content-wrapper {
- display: flex;
- flex: 1;
- }
- // 侧边栏
- .left-group2 {
- // width: rpx(150);
- height: 100%;
- display: flex;
- background-color: #ece9fd;
- }
- .title-box {
- height: rpx(50);
- position: absolute;
- }
- .box-icon {
- width: 100%;
- height: 100%;
- flex: 1;
- display: flex;
- align-items: center;
- color: black;
- padding-left: rpx(15);
- font-size: rpx(10);
- cursor: pointer;
- }
- .box-icon .left-icon {
- margin-left: rpx(10);
- margin-right: rpx(5);
- }
- </style>
|