- 将 StartLooking 函数重命名为 StartUpload 以更准确反映功能 - 修复构建脚本中的版本标记 ldflags 格式问题 - 更新应用标题格式,在版本号前添加冒号分隔符 - 优化上传进度循环逻辑,调整代码执行顺序 - 添加注释说明上传程序启动和文件处理功能 - 清理代码中的多余空行和变量声明
This commit is contained in:
@@ -56,7 +56,7 @@ jobs:
|
|||||||
build_date=$(TZ=Asia/Shanghai date +"%Y%m%d%H%M")
|
build_date=$(TZ=Asia/Shanghai date +"%Y%m%d%H%M")
|
||||||
wails build \
|
wails build \
|
||||||
-platform windows/amd64 \
|
-platform windows/amd64 \
|
||||||
-ldflags "-X 'main.version= $build_date - $git_hash'" \
|
-ldflags "-X 'main.version=$build_date - $git_hash'" \
|
||||||
-o 上传工具.exe
|
-o 上传工具.exe
|
||||||
|
|
||||||
- name: 上传构建文件
|
- name: 上传构建文件
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ func (a *App) startup(ctx context.Context) {
|
|||||||
if config.APPConfig.IsRunOnStart {
|
if config.APPConfig.IsRunOnStart {
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
a.uploaderCTX, a.uploaderCancel = context.WithCancel(a.ctx)
|
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
|
a.isRun = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,7 @@ func (a *App) StartUpload() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
a.uploaderCTX, a.uploaderCancel = context.WithCancel(a.ctx)
|
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
|
a.isRun = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ type Progress struct {
|
|||||||
Percentage int `json:"percentage"`
|
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, "===============================================")
|
||||||
AddLog(logChan, `服务器: `+config.APPConfig.Url)
|
AddLog(logChan, `服务器: `+config.APPConfig.Url)
|
||||||
AddLog(logChan, `Token: `+config.APPConfig.Token)
|
AddLog(logChan, `Token: `+config.APPConfig.Token)
|
||||||
@@ -48,6 +48,7 @@ func StartLooking(ctx context.Context, logChan *chan string, lookingPath string)
|
|||||||
AddLog(logChan, "创建连接池完成,开始运行程序")
|
AddLog(logChan, "创建连接池完成,开始运行程序")
|
||||||
|
|
||||||
progress.Clear()
|
progress.Clear()
|
||||||
|
|
||||||
//推送上传进度
|
//推送上传进度
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
@@ -55,19 +56,19 @@ func StartLooking(ctx context.Context, logChan *chan string, lookingPath string)
|
|||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
time.Sleep(250 * time.Millisecond)
|
|
||||||
|
|
||||||
var pg []Progress
|
var pg []Progress
|
||||||
progress.Range(func(key, value any) bool {
|
progress.Range(func(_, value any) bool {
|
||||||
p := value.(Progress)
|
pg = append(pg, value.(Progress))
|
||||||
pg = append(pg, p)
|
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
wailsruntime.EventsEmit(ctx, "progress", pg)
|
wailsruntime.EventsEmit(ctx, "progress", pg)
|
||||||
|
|
||||||
|
time.Sleep(250 * time.Millisecond)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
//开启上传程序
|
||||||
for {
|
for {
|
||||||
uploadData(ctx, logChan, lookingPath)
|
uploadData(ctx, logChan, lookingPath)
|
||||||
select {
|
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) {
|
func uploadData(ctx context.Context, logChan *chan string, lookingPath string) {
|
||||||
|
|
||||||
var path = "./"
|
var path = "./"
|
||||||
if lookingPath != "" {
|
if lookingPath != "" {
|
||||||
path = lookingPath
|
path = lookingPath
|
||||||
@@ -210,6 +212,7 @@ func getTxtFiles(dir string) (txtFiles []string, err error) {
|
|||||||
return txtFiles, err
|
return txtFiles, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// processFile 处理每个文件
|
||||||
func processFile(ctx context.Context, logChan *chan string, filePath string, fileLines int) {
|
func processFile(ctx context.Context, logChan *chan string, filePath string, fileLines int) {
|
||||||
// 打开文件
|
// 打开文件
|
||||||
file, err := os.Open(filePath)
|
file, err := os.Open(filePath)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ func main() {
|
|||||||
|
|
||||||
// Create application with options
|
// Create application with options
|
||||||
err := wails.Run(&options.App{
|
err := wails.Run(&options.App{
|
||||||
Title: "dypid-client - 版本" + version,
|
Title: "dypid-client - 版本:" + version,
|
||||||
Width: 1024,
|
Width: 1024,
|
||||||
Height: 768,
|
Height: 768,
|
||||||
AssetServer: &assetserver.Options{
|
AssetServer: &assetserver.Options{
|
||||||
|
|||||||
Reference in New Issue
Block a user