Sfoglia il codice sorgente

[Feat 0000]皮带巷优化路由监听

bobo04052021@163.com 2 mesi fa
parent
commit
735e47ba6e
1 ha cambiato i file con 6 aggiunte e 12 eliminazioni
  1. 6 12
      src/views/vent/home/configurable/belt/belt-new.vue

+ 6 - 12
src/views/vent/home/configurable/belt/belt-new.vue

@@ -69,15 +69,8 @@ const route = useRoute();
 const { configs, fetchConfigs } = useInitConfigs();
 const { updateEnhancedConfigs, updateData, data } = useInitPage('皮带巷智能管控');
 const pageType = computed(() => {
-  const queryType = route.query.pageType;
-  if (queryType) {
-    return queryType;
-  } else {
-    const isFireMonitorPath = window.location.href.includes('fireMonitor');
-    const isEmergencyControlPath = window.location.href.includes('emergencyControl');
-    const isSprayControlPath = window.location.href.includes('sprayControl');
-    return isFireMonitorPath ? 'fireMonitor' : isEmergencyControlPath ? 'emergencyControl' : isSprayControlPath ? 'sprayControl' : 'fireMonitor';
-  }
+  const currentType = route.params.type as string;
+  return currentType;
 });
 
 // 下拉框选项
@@ -263,11 +256,12 @@ function initInterval() {
 }
 
 watch(
-  () => route.query.pageType,
+  // 监听动态路由参数 :type
+  () => route.params.type,
   (newVal) => {
     if (newVal) {
-      console.log('切换页面:', newVal);
-      refresh(); // 关键:切换菜单自动刷新
+      console.log('切换页面类型:', newVal);
+      refresh(); // 切换路由自动刷新
     }
   },
   { immediate: true }