Quellcode durchsuchen

fix(frontend): 天盘页面 routeDone 路由错误修复 - 导航工具加锁防重复跳转、修复 canvas 混合 API 用法

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Xiaogang Liao vor 1 Monat
Ursprung
Commit
94d2e8561c

+ 2 - 1
cfc-frontend/pages/index-home/index.vue

@@ -332,6 +332,7 @@ import DimensionProducts from '../../components/DimensionProducts.vue'
 import ArticleBookshelf from '../../components/ArticleBookshelf.vue'
 import FamilyChallengeCard from '../../components/FamilyChallengeCard.vue'
 import { acceptParentInvite, productList, getActivityList, getFeaturedArticles, getFamilyEnergySandbox, getVisibleFamilyMembers, getChildren, getChallengeList, switchToFamilyMember, getMyMembership, updateChallengeProgress, respondChallenge, getTodayTasks, completeTask as completeTaskApi, getTodayParentTasks, completeParentTask as completeParentTaskApi, getTaskHistory, getNotices } from '../../utils/api.js'
+import nav from '../../utils/nav.js'
 import config from '@/config.js'
 
 export default {
@@ -752,7 +753,7 @@ export default {
       })
     },
     navTo: function(url) {
-      uni.navigateTo({ url: url })
+      nav.goPage(url)
     },
     goActivityDetail: function(act) {
       if (!act || !act.id) return

+ 2 - 2
cfc-frontend/pages/mind-detail/family-dashboard.vue

@@ -75,7 +75,7 @@
         
         <!-- 五行罗盘 -->
         <view class="compass-section">
-          <canvas canvas-id="dashboardCompass" id="dashboardCompass" type="2d" class="dashboard-compass"></canvas>
+          <canvas id="dashboardCompass" type="2d" class="dashboard-compass"></canvas>
         </view>
       </view>
       <view class="card-footer">
@@ -90,7 +90,7 @@
       </view>
       <view class="section-body">
         <view class="trend-chart">
-          <canvas canvas-id="weekTrendChart" id="weekTrendChart" type="2d" class="trend-canvas"></canvas>
+          <canvas id="weekTrendChart" type="2d" class="trend-canvas"></canvas>
         </view>
       </view>
     </view>

+ 14 - 0
cfc-frontend/utils/nav.js

@@ -2,7 +2,16 @@
  * 统一导航工具
  * TabBar 页面列表(4个新Tab:首页/健康/成长/我的)
  * 五维页已移出 TabBar,统一用 navigateTo 访问
+ *
+ * 【导航防抖说明】
+ * 快速连续多次 navigateTo 同一页面时,微信框架会因上次路由未完成而销毁
+ * 新创建的 webview,随后上次路由执行 routeDone 时触发
+ * "routeDone with a webviewId XX is not found" 错误。
+ * 因此所有导航统一在此加锁:导航期间(约 300ms)重复跳转自动忽略。
  */
+var NAV_LOCK = false
+var NAV_LOCK_DURATION = 300
+
 var TAB_BAR_PAGES = [
   '/pages/index-home/index',
   '/pages/health-main/index',
@@ -33,6 +42,11 @@ function goDimension(dimCode) {
  */
 function goPage(url) {
   if (!url) return
+  // 导航锁:防止快速重复点击导致 routeDone 错误
+  if (NAV_LOCK) return
+  NAV_LOCK = true
+  setTimeout(function() { NAV_LOCK = false }, NAV_LOCK_DURATION)
+
   if (TAB_BAR_PAGES.indexOf(url) !== -1) {
     uni.switchTab({ url: url })
   } else {