mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-08 02:52:07 +08:00
refactor(traffic-monitor): Move traffic sampling/compression to a dedicated Web Worker (#5588)
* refactor(traffic-monitor): Move traffic sampling/compression to a dedicated Web Worker * refactor(traffic-monitor): introduce shared sampler, safe fallback, and decoupled range handling * refactor(traffic-monitor): add optional subscribe flag and fix range handling * fix(traffic-monitor): age out idle samples and prevent ref-count updates after unmount
This commit is contained in:
@@ -110,7 +110,7 @@ export const EnhancedCanvasTrafficGraph = memo(
|
||||
const { t } = useTranslation();
|
||||
|
||||
// 使用增强版全局流量数据管理
|
||||
const { dataPoints, getDataForTimeRange, samplerStats } =
|
||||
const { dataPoints, requestRange, samplerStats } =
|
||||
useTrafficGraphDataEnhanced();
|
||||
|
||||
// 基础状态
|
||||
@@ -183,8 +183,7 @@ export const EnhancedCanvasTrafficGraph = memo(
|
||||
|
||||
// 监听数据变化
|
||||
useEffect(() => {
|
||||
const timeRangeData = getDataForTimeRange(timeRange);
|
||||
updateDisplayData(timeRangeData);
|
||||
updateDisplayData(dataPoints);
|
||||
|
||||
return () => {
|
||||
if (debounceTimeoutRef.current !== null) {
|
||||
@@ -192,7 +191,11 @@ export const EnhancedCanvasTrafficGraph = memo(
|
||||
debounceTimeoutRef.current = null;
|
||||
}
|
||||
};
|
||||
}, [dataPoints, timeRange, getDataForTimeRange, updateDisplayData]);
|
||||
}, [dataPoints, updateDisplayData]);
|
||||
|
||||
useEffect(() => {
|
||||
requestRange(timeRange);
|
||||
}, [requestRange, timeRange]);
|
||||
|
||||
useEffect(() => {
|
||||
if (displayData.length === 0) {
|
||||
|
||||
Reference in New Issue
Block a user