diff --git a/.gitea/workflows/build_tool.yaml b/.gitea/workflows/build_tool.yaml index 1e2ecfa..aef60e3 100644 --- a/.gitea/workflows/build_tool.yaml +++ b/.gitea/workflows/build_tool.yaml @@ -56,7 +56,7 @@ jobs: build_date=$(TZ=Asia/Shanghai date +"%Y%m%d%H%M") wails build \ -platform windows/amd64 \ - -ldflags "-X 'main.version= $build_date - $git_hash'" \ + -ldflags "-X 'main.version=$build_date - $git_hash'" \ -o 上传工具.exe - name: 上传构建文件 diff --git a/app.go b/app.go index d85d695..7a433ed 100644 --- a/app.go +++ b/app.go @@ -48,7 +48,7 @@ func (a *App) startup(ctx context.Context) { if config.APPConfig.IsRunOnStart { time.Sleep(time.Second) a.uploaderCTX, a.uploaderCancel = context.WithCancel(a.ctx) - go uploader.StartLooking(a.uploaderCTX, &a.logChan, config.APPConfig.CheckDir) + go uploader.StartUpload(a.uploaderCTX, &a.logChan, config.APPConfig.CheckDir) a.isRun = true } } @@ -74,7 +74,7 @@ func (a *App) StartUpload() { return } a.uploaderCTX, a.uploaderCancel = context.WithCancel(a.ctx) - go uploader.StartLooking(a.uploaderCTX, &a.logChan, config.APPConfig.CheckDir) + go uploader.StartUpload(a.uploaderCTX, &a.logChan, config.APPConfig.CheckDir) a.isRun = true } diff --git a/internal/uploader/uploader.go b/internal/uploader/uploader.go index a05e224..4b0bdc1 100644 --- a/internal/uploader/uploader.go +++ b/internal/uploader/uploader.go @@ -34,7 +34,7 @@ type Progress struct { Percentage int `json:"percentage"` } -func StartLooking(ctx context.Context, logChan *chan string, lookingPath string) { +func StartUpload(ctx context.Context, logChan *chan string, lookingPath string) { AddLog(logChan, "===============================================") AddLog(logChan, `服务器: `+config.APPConfig.Url) AddLog(logChan, `Token: `+config.APPConfig.Token) @@ -48,6 +48,7 @@ func StartLooking(ctx context.Context, logChan *chan string, lookingPath string) AddLog(logChan, "创建连接池完成,开始运行程序") progress.Clear() + //推送上传进度 go func() { for { @@ -55,19 +56,19 @@ func StartLooking(ctx context.Context, logChan *chan string, lookingPath string) case <-ctx.Done(): return default: - time.Sleep(250 * time.Millisecond) - var pg []Progress - progress.Range(func(key, value any) bool { - p := value.(Progress) - pg = append(pg, p) + progress.Range(func(_, value any) bool { + pg = append(pg, value.(Progress)) return true }) wailsruntime.EventsEmit(ctx, "progress", pg) + + time.Sleep(250 * time.Millisecond) } } }() + //开启上传程序 for { uploadData(ctx, logChan, lookingPath) select { @@ -79,6 +80,7 @@ func StartLooking(ctx context.Context, logChan *chan string, lookingPath string) } func uploadData(ctx context.Context, logChan *chan string, lookingPath string) { + var path = "./" if lookingPath != "" { path = lookingPath @@ -210,6 +212,7 @@ func getTxtFiles(dir string) (txtFiles []string, err error) { return txtFiles, err } +// processFile 处理每个文件 func processFile(ctx context.Context, logChan *chan string, filePath string, fileLines int) { // 打开文件 file, err := os.Open(filePath) diff --git a/main.go b/main.go index f2e915a..47d9eae 100644 --- a/main.go +++ b/main.go @@ -22,7 +22,7 @@ func main() { // Create application with options err := wails.Run(&options.App{ - Title: "dypid-client - 版本" + version, + Title: "dypid-client - 版本:" + version, Width: 1024, Height: 768, AssetServer: &assetserver.Options{