From 03e4e6f45b366508fc155e816b8268e47c7ee8d0 Mon Sep 17 00:00:00 2001 From: YGXB_net Date: Thu, 30 Apr 2026 21:24:30 +0800 Subject: [PATCH] =?UTF-8?q?fix(uploader):=20=E4=BF=AE=E5=A4=8D=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E5=99=A8=E9=80=BB=E8=BE=91=E5=92=8CUI=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复目录选择为空时不更改配置的逻辑 - 将警告提示改为错误提示以提高用户体验 - 优化停止运行时的成功提示 - 增加进度列表的最大高度以显示更多内容 - 调整定时器逻辑顺序避免提前退出 - 移除重复的任务等待错误处理 - 优化代码结构和空行格式 --- frontend/src/App.vue | 14 +++++++++----- internal/uploader/uploader.go | 10 ++++------ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 684396a..9da1b47 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -52,7 +52,11 @@ const addLog = (msg: string) => { const selectDirectory = () => { // ElMessage.info('请手动输入检测目录路径') SelectPath().then((path) => { - checkDir.value = path + if (path){ + checkDir.value = path + }else { + ElMessage.warning('未选择目录,不更改配置') + } }) } @@ -62,11 +66,11 @@ const startRun = () => { // return // } if (!token.value) { - ElMessage.warning('请输入Token') + ElMessage.error('请输入Token') return } if (!checkDir.value) { - ElMessage.warning('请选择检测目录') + ElMessage.error('请选择检测目录') return } @@ -76,7 +80,7 @@ const startRun = () => { const stopRun = () => { addLog(`正在停止运行`) StopUpload().then(() => { - ElMessage.info('已停止运行') + ElMessage.success('已停止运行') }) } @@ -252,7 +256,7 @@ EventsOn("log", (msg) => { .progress-list { margin-top: 12px; - max-height: 160px; + max-height: 250px; overflow-y: auto; display: flex; flex-direction: column; diff --git a/internal/uploader/uploader.go b/internal/uploader/uploader.go index 3ddc56f..474ff39 100644 --- a/internal/uploader/uploader.go +++ b/internal/uploader/uploader.go @@ -72,9 +72,9 @@ func StartUpload(ctx context.Context, logChan *chan string) { for { uploadData(ctx, logChan) select { - case <-time.After(time.Minute): case <-ctx.Done(): return + case <-time.After(time.Minute): } } } @@ -136,6 +136,7 @@ func uploadData(ctx context.Context, logChan *chan string) { } progress.Clear() + //添加文件上传任务参数(文件路径,文件行数) var tasks []Task for fileName, lines := range fileLines { @@ -182,12 +183,9 @@ func uploadData(ctx context.Context, logChan *chan string) { return default: // 等待所有任务完成 - if err := g.Wait(); err != nil { - AddLog(logChan, fmt.Sprintf("任务执行出错: %v", err)) - } else { - AddLog(logChan, "所有任务执行完成!") - } + g.Wait() + AddLog(logChan, "所有任务执行完成!") AddLog(logChan, fmt.Sprintf("上传完成,耗时:%s", time.Since(start).String())) } }