Ver Fonte

修改编程路径

丸子 há 7 meses atrás
pai
commit
adf2af2d6d

+ 9 - 6
src/components/HomePage.vue

@@ -25,6 +25,13 @@
       </div>
       <div class="inner-box right-box">
         <div class="top-right-box">
+          <el-button
+            round
+            class="top-right-btn"
+            :class="{ 'is-active': selectedButton === 'AI编程课' }"
+            @click="router.push('/programming')"
+            >AI编程课</el-button
+          >
           <el-button
             round
             class="top-right-btn"
@@ -53,12 +60,10 @@
             >AI艺术课</el-button
           >
           <!-- 退出登录 -->
-          <!-- <div class="logout-box"> -->
           <el-button round class="logout-box-btn" @click="LogoutClick()">
             <img :src="logoutIcon" alt="Logout" />
             退出登录
           </el-button>
-          <!-- </div> -->
         </div>
       </div>
     </div>
@@ -422,13 +427,11 @@ window.updateTenantName = (newName) => {
   font-size: rpx(8); // 使用 rpx 函数设置字体大小
   outline: none; // 移除默认的外边框
 }
-.top-right-btn.is-active,
-.top-right-btn:active,
-.top-right-btn:focus {
+.top-right-btn:hover {
   background-color: rgb(255, 255, 255, 0.7);
   border: 1px white solid;
   color: black;
-  outline: none; // 移除点击时的外边框
+  outline: none;
   box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
 }
 .dropdown-box {

+ 0 - 11
src/components/LeftPanel.vue

@@ -48,7 +48,6 @@ import image2image from '@/assets/icon/image2image.png'
 import video from '@/assets/icon/video.png'
 import labImage from '@/assets/icon/labImage.png'
 import en from '@/assets/icon/en.png'
-import blockly from '@/assets/icon/blockly.png'
 import avatar from '@/assets/icon/avatar.png'
 // 黑色
 import question02 from '@/assets/icon/question02.png'
@@ -58,7 +57,6 @@ import image2image02 from '@/assets/icon/image2image02.png'
 import video02 from '@/assets/icon/video02.png'
 import labImage02 from '@/assets/icon/labImage02.png'
 import en02 from '@/assets/icon/en02.png'
-import blockly02 from '@/assets/icon/blockly02.png'
 import avatar02 from '@/assets/icon/avatar02.png'
 
 
@@ -107,11 +105,6 @@ const groupList = ref([
     icon: labImage,
     hoverIcon: labImage02,
     title: '虚拟实验室'
-  },
-   {
-    icon: blockly,
-    hoverIcon: blockly02,
-    title: 'blockly游戏'
   }
 ])
 
@@ -130,7 +123,6 @@ const updateActiveIndex = () => {
     'ai-image': '4' ,     // 图生图
     'ai-video': '5' ,     // 图生视频
     'virtual-laboratory':"6",// 虚拟实验室
-    'gamepage':"7"// 虚拟实验室
     
   };
   // 从数字人老师页面进入智能问答页面
@@ -216,9 +208,6 @@ const navigateToAI = async (group) => {
   if (group.title === '虚拟实验室') {
     router.push('/virtual-laboratory')
   }
-  if (group.title === 'blockly游戏') {
-    router.push('/gamepage')
-  }
 }
 
 // 处理菜单展开和关闭

+ 194 - 0
src/components/sidebar/ProgrammingSidebar.vue

@@ -0,0 +1,194 @@
+<template>
+  <!-- 左侧折叠面板 -->
+  <transition name="drawer-slide">
+    <div class="left-group">
+      <el-row class="tac">
+        <el-col :span="12">
+          <el-menu
+            :default-active="currentActiveIndex"
+            class="el-menu-vertical-demo"
+            @open="handleOpen"  
+            @close="handleClose"
+          >
+            <el-menu-item
+              v-for="(item, index) in groupList"
+              :key="index"
+              :index="index.toString()"
+              @click="navigateToAI(item)"
+              v-model="currentActiveIndex"
+              @mouseover="item.isHover = true"
+              @mouseout="item.isHover = false"
+            >
+              <!-- 根据状态切换图片-->
+               <img
+                :src="currentActiveIndex === index.toString() || item.isHover ? item.hoverIcon : item.icon"
+                alt=""
+                class="menu-icon"
+              />
+              {{ item.title }}
+            </el-menu-item>
+          </el-menu>
+        </el-col>
+      </el-row>
+    </div>
+  </transition>
+</template>
+
+<script setup>
+import { ref, onMounted,watch} from 'vue'
+import { useRouter, useRoute } from 'vue-router'
+
+
+// 导入图片 白色
+import blockly from '@/assets/icon/blockly.png'
+// 黑色
+import blockly02 from '@/assets/icon/blockly02.png'
+
+
+ 
+const router = useRouter()
+const route = useRoute()
+
+// 添加抽屉显示状态
+const drawerVisible = ref(true)
+// 当前选中索引状态
+const currentActiveIndex = ref('2')
+
+// 渲染侧边栏
+const groupList = ref([
+   {
+    icon: blockly,
+    hoverIcon: blockly02,
+    title: 'blockly编程'
+  }
+])
+
+
+// 提取更新选中状态的逻辑为单独函数
+// 优化后的更新选中状态的方法
+const updateActiveIndex = () => {
+  const path = route.path;
+  // 使用映射表存储路径和索引的对应关系
+  const pathIndexMap = {
+    'programming':"0" // 编程课
+  };
+  // 查找路径对应的索引
+  for (const [key, index] of Object.entries(pathIndexMap)) {
+    if (path.includes(key)) {
+      currentActiveIndex.value = index;
+      return;
+    }
+  }
+};
+
+// 组件挂载时确保默认选中状态
+onMounted(() => {
+  updateActiveIndex();
+});
+
+// 添加路由变化监听,更新选中状态
+watch(() => route, () => {
+  updateActiveIndex();
+}, { immediate: true, deep: true });
+
+// 跳转智能问答
+const navigateToAI = async (group) => {
+  if (group.title === 'blockly编程') {
+    router.push('/programming')
+  }
+}
+
+// 处理菜单展开和关闭
+const handleOpen = () => {}
+const handleClose = () => {}
+
+// 导出状态和方法供父组件使用
+defineExpose({
+  drawerVisible,
+  toggleDrawer: () => {
+    drawerVisible.value = !drawerVisible.value 
+  }
+})
+</script>
+
+<style scoped lang="scss">
+@use 'sass:math';
+// 定义rpx转换函数
+@function rpx($px) {
+  @return math.div($px, 750) * 100vw;
+}
+/* 添加过渡样式 */
+::v-deep .drawer-slide-enter-active,
+::v-deep .drawer-slide-leave-active {
+  transition: all 0.3s ease;
+}
+::v-deep .drawer-slide-enter-from,
+::v-deep .drawer-slide-leave-to {
+  transform: translateX(-100%);
+  opacity: 0;
+}
+
+// 侧边栏
+.left-group {
+  width: rpx(135);
+  height: 100%;
+  background: linear-gradient(to bottom, #001169, #8a78d0);
+  overflow-y: auto;
+  // 自定义滚动条样式
+  &::-webkit-scrollbar {
+    width: rpx(0); // 滚动条宽度
+  }
+  &::-webkit-scrollbar-track {
+    background-color: rgba(255, 255, 255, 0.1); // 滚动条轨道背景色
+    border-radius: rpx(2); // 滚动条轨道圆角
+  }
+  &::-webkit-scrollbar-thumb {
+    background-color: rgba(255, 255, 255, 0.3); // 滚动条滑块颜色
+    border-radius: rpx(2); // 滚动条滑块圆角
+    transition: background-color 0.3s ease; // 滑块颜色过渡效果
+  }
+  &::-webkit-scrollbar-thumb:hover {
+    background-color: rgba(255, 255, 255, 0.5); // 鼠标悬停时的滑块颜色
+  }
+}
+.mb-2 {
+  color: black;
+  margin-top: rpx(1);
+}
+.tac ::v-deep(.el-menu) {
+  background-color: transparent;
+  border: none;
+  width: 100%;
+  margin-top: rpx(25);
+  margin-left: rpx(10);
+}
+.el-menu-item {
+  width: rpx(115);
+  height: rpx(25);
+  margin-bottom: rpx(5);
+  border-radius: rpx(6);
+  color: white;
+  font-size: rpx(8);
+}
+.el-menu-item .el-icon svg {
+  font-size: rpx(15);
+  color: white;
+}
+.el-menu .el-menu-item:hover {
+  background: linear-gradient(to bottom, #ffefb0, #ffcc00);
+  box-shadow: 0 8px 8px rgb(0, 0, 0, 0.3);
+  color: black;
+  font-size: rpx(8);
+}
+:deep(.el-menu .el-menu-item.is-active) {
+  background: linear-gradient(to bottom, #fee78a, #ffce1b);
+  color: black;
+  font-size: rpx(8);
+  box-shadow: 0 4px 8px rgba(3, 3, 3, 0.3);
+}
+.menu-icon {
+  width: rpx(11);
+  height: rpx(11);
+  margin-right: rpx(2);
+}
+</style>

+ 1 - 1
src/router/index.js

@@ -91,7 +91,7 @@ const routes = [
   { path: '/blockly2', component: () => import('../views/block/Blockly2.vue') },
   { path: '/mapGame', component: () => import('../views/block/MapGame.vue') },
   // 编程游戏列表
-  { path: '/gamepage', component: () => import('../views/gamepage/GameIndex.vue') },
+  { path: '/programming', component: () => import('../views/gamepage/GameIndex.vue') },
 ]
 const router = createRouter({
   history: createWebHistory(),

+ 3 - 3
src/views/gamepage/GameIndex.vue

@@ -20,7 +20,7 @@
     </div>
 
     <!-- 侧边栏组件 -->
-    <LeftPanel ref="leftPanelRef" v-show="drawerVisible" />
+    <ProgrammingSidebar ref="leftPanelRef" v-show="drawerVisible" />
 
     <div class="content-box">
       <div class="box-1">
@@ -89,14 +89,14 @@ import { useRouter, useRoute } from 'vue-router'
 import teachingImg from '@/assets/icon/teaching.png'
 // 引入游戏列表接口
 import { GameList } from '@/api/blockly/game.js'
-import LeftPanel from '@/components/LeftPanel.vue'
+import ProgrammingSidebar from '@/components/sidebar/ProgrammingSidebar.vue'
 const leftPanelRef = ref(null)
 const route = useRoute()
 
 // 获取当前路由对象
 const router = useRouter() 
 // 页面标题
-const pageTitle = ref('blockly游戏')
+const pageTitle = ref('返回首页')
 // 抽屉显示状态
 const drawerVisible = ref(true)
 // 游戏数据