mac 2 лет назад
Родитель
Сommit
fb1872223b

+ 15
- 0
.vscode/launch.json Просмотреть файл

@@ -0,0 +1,15 @@
1
+{
2
+    // 使用 IntelliSense 了解相关属性。 
3
+    // 悬停以查看现有属性的描述。
4
+    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
5
+    "version": "0.2.0",
6
+    "configurations": [
7
+        {
8
+            "type": "pwa-chrome",
9
+            "request": "launch",
10
+            "name": "Launch Chrome against localhost",
11
+            "url": "http://localhost:8080",
12
+            "webRoot": "${workspaceFolder}"
13
+        }
14
+    ]
15
+}

+ 0
- 1
src/components/GeoMap/marker.js Просмотреть файл

@@ -25,7 +25,6 @@ export function useMarker(amapRef, map, list) {
25 25
 
26 26
 export function useMarkerVisible(map, markerListRef, typeId) {
27 27
   useEffect(() => {
28
-    console.log(typeId, markerListRef.current);
29 28
     if (!map || !markerListRef.current) return;
30 29
 
31 30
     markerListRef.current.forEach((marker) => {

+ 28
- 5
src/pages/MonitoringScreen/components/List/index.jsx Просмотреть файл

@@ -1,4 +1,4 @@
1
-import React, { useEffect, useMemo, useRef, useState } from 'react';
1
+import React, { useCallback, useEffect, useRef } from 'react';
2 2
 import { Swiper, SwiperSlide } from 'swiper/react';
3 3
 import { Autoplay } from 'swiper';
4 4
 import 'swiper/css';
@@ -7,14 +7,32 @@ import Item from './Item';
7 7
 import Styles from './style.less';
8 8
 
9 9
 export default (props) => {
10
-  // 每次加载 4 个
11
-  const tm = 4;
12 10
   const { title, color, children } = props;
13
-
11
+  const swiperRef = useRef();
14 12
   const classList = classNames(Styles['list-title'], {
15 13
     [Styles['yellow-title']]: color !== 'green',
16 14
     [Styles['green-title']]: color === 'green',
17 15
   });
16
+  const initAutoPlay = useCallback(
17
+    (swiper) => {
18
+      console.log(swiper);
19
+      if (!children?.length || children?.length <= 3) {
20
+        swiper.autoplay.stop();
21
+      } else {
22
+        swiper.autoplay.start();
23
+      }
24
+    },
25
+    [children?.length],
26
+  );
27
+
28
+  useEffect(() => {
29
+    if (swiperRef.current) {
30
+      initAutoPlay(swiperRef.current);
31
+    }
32
+  }, [children?.length, initAutoPlay]);
33
+
34
+  const enable = children?.length && children?.length > 3;
35
+
18 36
   return (
19 37
     <div className={Styles['screen-list']}>
20 38
       <div className={classList}>
@@ -22,12 +40,17 @@ export default (props) => {
22 40
       </div>
23 41
       <Swiper
24 42
         height={48}
43
+        onSwiper={(swiper) => {
44
+          swiperRef.current = swiper;
45
+          initAutoPlay(swiper);
46
+        }}
25 47
         className={Styles['list-body']}
48
+        init={false}
26 49
         autoplay={{
27 50
           delay: 2500,
28 51
           disableOnInteraction: false,
29 52
         }}
30
-        loop={children?.length >= 3}
53
+        loop={enable}
31 54
         loopAdditionalSlides={2}
32 55
         modules={[Autoplay]}
33 56
         direction="vertical"

+ 0
- 1
src/pages/MonitoringScreen/index.jsx Просмотреть файл

@@ -105,7 +105,6 @@ export default (props) => {
105 105
     //作业面积统计
106 106
     getAreaDetail()
107 107
       .then((res) => {
108
-        console.log('---------res---->', res);
109 108
         setWorkAreaData([].concat(res));
110 109
       })
111 110
       .catch((err) => {