From 8c4c7b047117c996ab88b990f289b3532eacfd18 Mon Sep 17 00:00:00 2001 From: keven1024 Date: Sat, 10 Jan 2026 14:34:01 +0800 Subject: [PATCH] feat(front): add axios for API requests and enhance FileUploadProgressView with speed tracking and UI improvements --- .../FileUploadTotalSpeedView.vue | 31 +++++-- .../File/FileUploadProgressView/index.vue | 90 +++++-------------- front/package.json | 1 + 3 files changed, 46 insertions(+), 76 deletions(-) diff --git a/front/components/Home/File/FileUploadProgressView/FileUploadTotalSpeedView.vue b/front/components/Home/File/FileUploadProgressView/FileUploadTotalSpeedView.vue index db169dc..043f421 100644 --- a/front/components/Home/File/FileUploadProgressView/FileUploadTotalSpeedView.vue +++ b/front/components/Home/File/FileUploadProgressView/FileUploadTotalSpeedView.vue @@ -2,33 +2,52 @@ import dayjs from 'dayjs' import { motion } from 'motion-v' import getFileSize from '~/lib/getFileSize' +import showDrawer from '~/lib/showDrawer' +import FileUploadSpeedInfoView from './FileUploadSpeedInfoView.vue' +import { clamp } from 'lodash-es' const { t } = useI18n() const props = defineProps<{ speedChartData: Record }>() +const speedChartList = ref<{ timestamp: number; value: number }[]>([]) +useIntervalFn(() => { + speedChartList.value.push({ + timestamp: dayjs().unix() - 1, + value: props.speedChartData[dayjs().unix() - 1]?.reduce((acc, curr) => acc + curr.value, 0) ?? 0, + }) + if (speedChartList.value.length > 60) { + speedChartList.value.shift() + } +}, 1000) + +const handleShowSpeedInfo = () => { + showDrawer({ + render: ({ hide }) => h(FileUploadSpeedInfoView, { hide }), + }) +}