diff --git a/src/components/sidebar/SpeedCharts.vue b/src/components/sidebar/SpeedCharts.vue index 802be8c4..5dcd29f3 100644 --- a/src/components/sidebar/SpeedCharts.vue +++ b/src/components/sidebar/SpeedCharts.vue @@ -79,7 +79,6 @@ onMounted(() => { }, splitLine: { show: false }, }, - animation: false, series: [ { name: t('upload'), diff --git a/src/store/statistics.ts b/src/store/statistics.ts index 78a74a81..f877df80 100644 --- a/src/store/statistics.ts +++ b/src/store/statistics.ts @@ -1,19 +1,21 @@ import { fetchMemoryAPI, fetchTrafficAPI } from '@/api' import { ref, watch } from 'vue' +const initValue = new Array(60).fill(0).map((v, i) => ({ name: i, value: v })) + export const memory = ref(0) export const downloadSpeed = ref(0) export const uploadSpeed = ref(0) -export const downloadSpeedHistory = ref(new Array(60).fill(0)) -export const uploadSpeedHistory = ref(new Array(60).fill(0)) +export const downloadSpeedHistory = ref([...initValue]) +export const uploadSpeedHistory = ref([...initValue]) let cancel: () => void export const initSatistic = () => { cancel?.() - downloadSpeedHistory.value = new Array(60).fill(0) - uploadSpeedHistory.value = new Array(60).fill(0) + downloadSpeedHistory.value = [...initValue] + uploadSpeedHistory.value = [...initValue] const memoryWs = fetchMemoryAPI() const unwatchMemory = watch(memoryWs.data, (data) => { @@ -34,12 +36,19 @@ export const initSatistic = () => { up: number down: number } + const timestamp = Date.now().valueOf() downloadSpeed.value = parsedData.down uploadSpeed.value = parsedData.up - downloadSpeedHistory.value.push(parsedData.down) - uploadSpeedHistory.value.push(parsedData.up) + downloadSpeedHistory.value.push({ + value: parsedData.down, + name: timestamp, + }) + uploadSpeedHistory.value.push({ + value: parsedData.up, + name: timestamp, + }) downloadSpeedHistory.value = downloadSpeedHistory.value.slice(-60) uploadSpeedHistory.value = uploadSpeedHistory.value.slice(-60)