|
|
@@ -100,7 +100,7 @@
|
|
|
<script setup>
|
|
|
import {ref, reactive, watch, onMounted, computed, onUnmounted, nextTick} from 'vue'
|
|
|
// 返回图标
|
|
|
-import { ArrowLeftBold } from '@element-plus/icons-vue';
|
|
|
+import {ArrowLeftBold, Message} from '@element-plus/icons-vue';
|
|
|
// 导入路由
|
|
|
import { useRouter } from 'vue-router';
|
|
|
// 导入按钮图片
|
|
|
@@ -113,6 +113,7 @@ import { logoutLogic } from '@/utils/loginUtils.js'
|
|
|
// 实验课主题接口
|
|
|
import { getThemeExperimentList } from '@/api/laboratory/index.js'
|
|
|
import {aiCourseRoutes} from "@/router/index.js";
|
|
|
+import {scrollToCenter} from "@/utils/pageCss/scrollToCenter.js";
|
|
|
|
|
|
// 常量定义
|
|
|
const CONSTANTS = {
|
|
|
@@ -166,7 +167,7 @@ const fetchExperimentList = async () => {
|
|
|
});
|
|
|
|
|
|
// 数据加载完成后,等待下一个DOM更新周期,然后调用middleBoxWidth
|
|
|
- nextTick(() => {
|
|
|
+ await nextTick(() => {
|
|
|
middleBoxWidth();
|
|
|
});
|
|
|
}
|
|
|
@@ -183,23 +184,7 @@ watch(activeButton, () => {
|
|
|
|
|
|
// 中间卡片居中显示和放大效果
|
|
|
const middleBoxWidth = ()=> {
|
|
|
- if (middleBox.value) {
|
|
|
- // 找到对应的课程卡片元素
|
|
|
- const courseElement = middleBox.value.querySelector(`.middle-inner-box:nth-child(${activeButton.value + 1})`);
|
|
|
- if (courseElement) {
|
|
|
- // 计算滚动位置,选中的卡片居中
|
|
|
- const containerWidth = middleBox.value.clientWidth;
|
|
|
- const elementLeft = courseElement.offsetLeft;
|
|
|
- const elementWidth = courseElement.offsetWidth;
|
|
|
- // 计算居中位置
|
|
|
- const scrollPosition = elementLeft - (containerWidth / 2) + (elementWidth / 2);
|
|
|
- // 平滑滚动到计算的位置
|
|
|
- middleBox.value.scrollTo({
|
|
|
- left: scrollPosition,
|
|
|
- behavior: 'smooth'
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
+ scrollToCenter(middleBox.value, activeButton.value);
|
|
|
}
|
|
|
|
|
|
// 鼠标按下事件处理函数
|