Jelajahi Sumber

fix: 远程控制修改

wzyyy 3 tahun lalu
induk
melakukan
396759948f
1 mengubah file dengan 5 tambahan dan 11 penghapusan
  1. 5 11
      src/pages/edge/Device/Remote/index.tsx

+ 5 - 11
src/pages/edge/Device/Remote/index.tsx

@@ -6,33 +6,27 @@ import { service } from '@/pages/device/Instance';
 const Remote = () => {
 const Remote = () => {
   const location = useLocation();
   const location = useLocation();
   const [url, setUrl] = useState<string>('');
   const [url, setUrl] = useState<string>('');
-  const [id, setId] = useState<string>('');
 
 
-  const _stop = async () => await service._stopControl(id);
+  const _stop = async (id: string) => await service._stopControl(id);
 
 
   useEffect(() => {
   useEffect(() => {
     const params = new URLSearchParams(location.search);
     const params = new URLSearchParams(location.search);
     const deviceId = params.get('id');
     const deviceId = params.get('id');
     if (deviceId) {
     if (deviceId) {
-      setId(deviceId);
       service._control(deviceId).then((resp: any) => {
       service._control(deviceId).then((resp: any) => {
         if (resp.status === 200) {
         if (resp.status === 200) {
-          // window.open(resp.result);
           console.log(resp.result);
           console.log(resp.result);
-          //   http://120.77.179.54:8811/
           const item = `http://${resp.result?.url}/#/login?token=${resp.result.token}`;
           const item = `http://${resp.result?.url}/#/login?token=${resp.result.token}`;
           setUrl(item);
           setUrl(item);
         }
         }
       });
       });
     }
     }
-  }, [location]);
-
-  useEffect(() => {
     return () => {
     return () => {
-      console.log('---------');
-      _stop();
+      if (deviceId) {
+        _stop(deviceId);
+      }
     };
     };
-  }, []);
+  }, [location]);
 
 
   return (
   return (
     <PageContainer>
     <PageContainer>