Quellcode durchsuchen

更新节流函数

li.shaoyi vor 3 Jahren
Ursprung
Commit
713e096e1b
1 geänderte Dateien mit 3 neuen und 2 gelöschten Zeilen
  1. 3 2
      src/common/components/echarts/echarts-timeline/options.ts

+ 3 - 2
src/common/components/echarts/echarts-timeline/options.ts

@@ -3,6 +3,7 @@ import { formatDecimal } from '@/utils/number';
 import * as echarts from 'echarts';
 import { State, Colors } from './type'
 import { getTheme, ThemeEnum } from '@/common/config/theme';
+import { throttle } from '@/utils/time'
 
 export function useOptions(state: State) {
     const theme = getTheme(),
@@ -192,7 +193,7 @@ export function useOptions(state: State) {
     }
 
     // 动态更新数据
-    const updateOptions = () => {
+    const updateOptions = throttle(() => {
         const { seriesMarkLineColor } = getColors();
         const { dataset, yestClose } = state;
 
@@ -219,7 +220,7 @@ export function useOptions(state: State) {
                 },
             ],
         }
-    }
+    }, 1000)
 
     // 计算涨跌幅百分比,涨跌幅=(今日收盘价-昨日收盘价)/昨日收盘价*100%
     const calcRatio = (val: number) => {