fix(uploader): 修复上传器逻辑和UI提示问题
构建上传工具 / build (push) Successful in 1m23s

- 修复目录选择为空时不更改配置的逻辑
- 将警告提示改为错误提示以提高用户体验
- 优化停止运行时的成功提示
- 增加进度列表的最大高度以显示更多内容
- 调整定时器逻辑顺序避免提前退出
- 移除重复的任务等待错误处理
- 优化代码结构和空行格式
This commit is contained in:
2026-04-30 21:24:30 +08:00
parent 6bd82024d9
commit 03e4e6f45b
2 changed files with 13 additions and 11 deletions
+8 -4
View File
@@ -52,7 +52,11 @@ const addLog = (msg: string) => {
const selectDirectory = () => { const selectDirectory = () => {
// ElMessage.info('请手动输入检测目录路径') // ElMessage.info('请手动输入检测目录路径')
SelectPath().then((path) => { SelectPath().then((path) => {
if (path){
checkDir.value = path checkDir.value = path
}else {
ElMessage.warning('未选择目录,不更改配置')
}
}) })
} }
@@ -62,11 +66,11 @@ const startRun = () => {
// return // return
// } // }
if (!token.value) { if (!token.value) {
ElMessage.warning('请输入Token') ElMessage.error('请输入Token')
return return
} }
if (!checkDir.value) { if (!checkDir.value) {
ElMessage.warning('请选择检测目录') ElMessage.error('请选择检测目录')
return return
} }
@@ -76,7 +80,7 @@ const startRun = () => {
const stopRun = () => { const stopRun = () => {
addLog(`正在停止运行`) addLog(`正在停止运行`)
StopUpload().then(() => { StopUpload().then(() => {
ElMessage.info('已停止运行') ElMessage.success('已停止运行')
}) })
} }
@@ -252,7 +256,7 @@ EventsOn("log", (msg) => {
.progress-list { .progress-list {
margin-top: 12px; margin-top: 12px;
max-height: 160px; max-height: 250px;
overflow-y: auto; overflow-y: auto;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
+4 -6
View File
@@ -72,9 +72,9 @@ func StartUpload(ctx context.Context, logChan *chan string) {
for { for {
uploadData(ctx, logChan) uploadData(ctx, logChan)
select { select {
case <-time.After(time.Minute):
case <-ctx.Done(): case <-ctx.Done():
return return
case <-time.After(time.Minute):
} }
} }
} }
@@ -136,6 +136,7 @@ func uploadData(ctx context.Context, logChan *chan string) {
} }
progress.Clear() progress.Clear()
//添加文件上传任务参数(文件路径,文件行数) //添加文件上传任务参数(文件路径,文件行数)
var tasks []Task var tasks []Task
for fileName, lines := range fileLines { for fileName, lines := range fileLines {
@@ -182,12 +183,9 @@ func uploadData(ctx context.Context, logChan *chan string) {
return return
default: default:
// 等待所有任务完成 // 等待所有任务完成
if err := g.Wait(); err != nil { g.Wait()
AddLog(logChan, fmt.Sprintf("任务执行出错: %v", err))
} else {
AddLog(logChan, "所有任务执行完成!")
}
AddLog(logChan, "所有任务执行完成!")
AddLog(logChan, fmt.Sprintf("上传完成,耗时:%s", time.Since(start).String())) AddLog(logChan, fmt.Sprintf("上传完成,耗时:%s", time.Since(start).String()))
} }
} }