浏览代码

消息通讯

xujunjie 1 年之前
父节点
当前提交
bc22597d23

+ 5 - 6
src/pages/Controller/Hardware.js

@@ -2,19 +2,18 @@ import PageContent from '@/components/PageContent';
 import PageTitle from '@/components/PageTitle';
 import TabsContent from '@/components/TabsContent';
 import { UnityAction } from '@/utils/utils';
-import { useEffect } from 'react';
 import AirConditioner from './components/AirConditioner';
 import Light from './components/Light';
 
 function Hardware() {
   const handleTabsChange = (tab) => {
-    UnityAction.sendMsg(tab == '1' ? 'ACData' : 'lightData');
+    // UnityAction.sendMsg(tab == '1' ? 'ACData' : 'lightData');
   };
 
-  useEffect(() => {
-    UnityAction.sendMsg('ACData');
-  }, []);
-  
+  // useEffect(() => {
+  //   UnityAction.sendMsg('ACData');
+  // }, []);
+
   return (
     <PageContent closeable={false}>
       <PageTitle

+ 4 - 0
src/pages/Controller/components/AirConditioner.js

@@ -2,12 +2,16 @@ import { queryIotList } from '@/services/controller';
 import { useParams, useRequest } from '@umijs/max';
 import { Spin } from 'antd';
 import styles from '../index.less';
+import { UnityAction } from '@/utils/utils';
 
 const Work = (props) => {
   const { projectId } = useParams();
 
   const { data, loading } = useRequest(queryIotList, {
     defaultParams: [projectId],
+    onSuccess(res) {
+      UnityAction.sendMsg('ACData', res.list);
+    },
   });
 
   const getIconStatus = (status) => {

+ 4 - 0
src/pages/Controller/components/Light.js

@@ -2,12 +2,16 @@ import { queryLightList } from '@/services/controller';
 import { useParams, useRequest } from '@umijs/max';
 import { Spin } from 'antd';
 import styles from '../index.less';
+import { UnityAction } from '@/utils/utils';
 
 const Work = (props) => {
   const { projectId } = useParams();
 
   const { data, loading } = useRequest(queryLightList, {
     defaultParams: [projectId],
+    onSuccess(res) {
+      UnityAction.sendMsg('lightData', res.list);
+    },
   });
 
   const getIconStatus = (status) => {