소스 검색

修改按钮名称以及返回Bug

丸子 6 달 전
부모
커밋
d911ac583d
2개의 변경된 파일23개의 추가작업 그리고 6개의 파일을 삭제
  1. 3 3
      src/views/Blockly.vue
  2. 20 3
      src/views/virtuallaboratory/index.vue

+ 3 - 3
src/views/Blockly.vue

@@ -5,7 +5,7 @@
     <div class="desk-lamp-title-box">
       <div class="desk-lamp-box-icon" @click="goBackLab">
         <el-icon class="left-icon"><ArrowLeftBold /></el-icon>
-        智能台灯
+        返回虚拟实验室
       </div>
     </div>
 
@@ -16,7 +16,7 @@
     <!-- 右下角按钮组 -->
     <div class="button-group">
       <el-button class="control-button run-button" @click="toggleLight">运行</el-button>
-      <el-button class="control-button code-button" @click="handleViewCode">查看代码</el-button>
+      <el-button class="control-button code-button" @click="handleViewCode">智能台灯</el-button>
     </div>
 
     <!-- 显示当前灯光信息 -->
@@ -32,7 +32,7 @@
     <div class="title-box">
       <div class="box-icon" @click="goBack">
         <el-icon class="left-icon"><ArrowLeftBold /></el-icon>
-        Blockly编程
+        返回虚拟实验室
       </div>
     </div>
 

+ 20 - 3
src/views/virtuallaboratory/index.vue

@@ -72,7 +72,15 @@ const router = useRouter()
 
 // 返回上一页
 const goBack = () => {
-  router.push('/home')
+  try {
+    // 直接使用window.location.href确保页面立即跳转并刷新
+    window.location.href = '/home';
+  } catch (error) {
+    console.error('返回home页面失败:', error);
+    // 备用方案
+    router.replace('/home');
+    window.location.reload();
+  }
 }
 const laboratoryList = ref([
   {
@@ -82,8 +90,17 @@ const laboratoryList = ref([
 ])
 
 const handleLabClick = (item) => {
-  if (item.name === '智能台灯') {
-    router.push('/blockly')
+if (item.name === '智能台灯') {
+    try {
+      // 立即修改URL,不经过Vue Router的队列处理
+      window.location.href = '/blockly';
+    } catch (error) {
+      console.error('直接跳转失败:', error);
+      // 备用方案:强制Vue Router进行跳转
+      router.replace('/blockly');
+      // 强制刷新页面以确保视图更新
+      window.location.reload();
+    }
   }
 }
 </script>