Kaynağa Gözat

fix(Analytics): Bug 6151 - 平台数据点击详情无反应,添加 try/catch 和参数校验

ethanfly 4 gün önce
ebeveyn
işleme
9e36b153eb
1 değiştirilmiş dosya ile 25 ekleme ve 17 silme
  1. 25 17
      client/src/views/Analytics/Platform/index.vue

+ 25 - 17
client/src/views/Analytics/Platform/index.vue

@@ -316,23 +316,31 @@ function handleDetail(row: PlatformData) {
   console.log('[Platform] platform:', row.platform);
   console.log('[Platform] startDate:', startDate.value, 'endDate:', endDate.value);
 
-  // 直接按完整路径跳转,避免动态路由参数解析问题
-  const path = `/analytics/platform-detail/${row.platform}`;
-  router.push({
-    path,
-    query: {
-      startDate: startDate.value,
-      endDate: endDate.value,
-    },
-  }).then(() => {
-    console.log('[Platform] 路由跳转成功, path:', path);
-  }).catch((error) => {
-    // 仅在真正的错误时提示,重复导航等忽略
-    console.error('[Platform] 路由跳转失败:', error);
-    if (error && error.name !== 'NavigationDuplicated') {
-      ElMessage.error('跳转失败: ' + (error?.message || '未知错误'));
-    }
-  });
+  if (!row.platform) {
+    ElMessage.error('缺少平台参数,无法查看详情');
+    return;
+  }
+
+  try {
+    // 直接按完整路径跳转,避免动态路由参数解析问题
+    const path = `/analytics/platform-detail/${row.platform}`;
+    router.push({
+      path,
+      query: {
+        startDate: startDate.value,
+        endDate: endDate.value,
+      },
+    }).catch((error) => {
+      // 仅在真正的错误时提示,重复导航等忽略
+      console.error('[Platform] 路由跳转失败:', error);
+      if (error && error.name !== 'NavigationDuplicated') {
+        ElMessage.error('跳转详情页失败: ' + (error?.message || '未知错误'));
+      }
+    });
+  } catch (error: any) {
+    console.error('[Platform] handleDetail 异常:', error);
+    ElMessage.error('查看详情失败: ' + (error?.message || '未知错误'));
+  }
 }
 
 // 加载平台详情