|
@@ -6,8 +6,6 @@ import (
|
|
|
"fmt"
|
|
|
"io"
|
|
|
"launcher/conf"
|
|
|
- "launcher/mproto/entity"
|
|
|
- "launcher/socket"
|
|
|
"os"
|
|
|
"os/exec"
|
|
|
"path"
|
|
@@ -250,21 +248,34 @@ func RegApi(event *cef.BrowserEvent, window cef.IBrowserWindow, bw *cef.LCLBrows
|
|
|
timeout = 60 * 20
|
|
|
}
|
|
|
go func() {
|
|
|
- eventName := sid
|
|
|
+ // eventName := sid
|
|
|
DownFile(url, fpath, time.Duration(timeout)*time.Second, func(w *WriteCounter) {
|
|
|
fmt.Println("on start=>")
|
|
|
- socket.BroadMsgObj(&entity.NormMsg{Sub: eventName, Type: "start"})
|
|
|
+ // socket.BroadMsgObj(&entity.NormMsg{Sub: eventName, Type: "start"})
|
|
|
+ downloadStartJsFunc := fmt.Sprintf("DownloadStartJsFunc('%s','%s')", sid, "start")
|
|
|
+ fmt.Println("DownloadStartJsFunc:", downloadStartJsFunc)
|
|
|
+ window.Chromium().ExecuteJavaScript(downloadStartJsFunc, "", 0)
|
|
|
|
|
|
}, func(w *WriteCounter) {
|
|
|
- socket.BroadMsgObj(&entity.NormMsg{Sub: eventName, Type: "progress", Fva11: float32(w.Curr) / float32(w.Total)})
|
|
|
+ // socket.BroadMsgObj(&entity.NormMsg{Sub: eventName, Type: "progress", Fva11: float32(w.Curr) / float32(w.Total)})
|
|
|
+ downloadProgressJsFunc := fmt.Sprintf("DownloadProgressJsFunc('%s','%s',%f)", sid, "progress", float32(w.Curr)/float32(w.Total))
|
|
|
+ fmt.Println("DownloadProgressJsFunc:", downloadProgressJsFunc)
|
|
|
+ window.Chromium().ExecuteJavaScript(downloadProgressJsFunc, "", 0)
|
|
|
+
|
|
|
}, func(err string) {
|
|
|
fmt.Println("on error=>", err)
|
|
|
delete(downingMap, fpath)
|
|
|
- socket.BroadMsgObj(&entity.NormMsg{Sub: eventName, Type: "error", Error: err})
|
|
|
+ // socket.BroadMsgObj(&entity.NormMsg{Sub: eventName, Type: "error", Error: err})
|
|
|
+ downloadErrorJsFunc := fmt.Sprintf("DownloadErrorJsFunc('%s','%s')", sid, "error")
|
|
|
+ fmt.Println("DownloadErrorJsFunc:", downloadErrorJsFunc)
|
|
|
+ window.Chromium().ExecuteJavaScript(downloadErrorJsFunc, "", 0)
|
|
|
}, func() {
|
|
|
fmt.Println("on succ=>")
|
|
|
delete(downingMap, fpath)
|
|
|
- socket.BroadMsgObj(&entity.NormMsg{Sub: eventName, Type: "succ"})
|
|
|
+ // socket.BroadMsgObj(&entity.NormMsg{Sub: eventName, Type: "succ"})
|
|
|
+ downloadSuccJsFunc := fmt.Sprintf("DownloadSuccJsFunc('%s','%s')", sid, "succ")
|
|
|
+ fmt.Println("DownloadSuccJsFunc:", downloadSuccJsFunc)
|
|
|
+ window.Chromium().ExecuteJavaScript(downloadSuccJsFunc, "", 0)
|
|
|
})
|
|
|
}()
|
|
|
return ""
|
|
@@ -363,15 +374,24 @@ func RegApi(event *cef.BrowserEvent, window cef.IBrowserWindow, bw *cef.LCLBrows
|
|
|
|
|
|
ipc.On("Unzip", func(sid, fpath string, distDir string) bool {
|
|
|
go func() {
|
|
|
- eventName := sid
|
|
|
+ // eventName := sid
|
|
|
err := Unzip(fpath, distDir, func(per1000 int) {
|
|
|
- socket.BroadMsgObj(&entity.NormMsg{Sub: eventName, Type: "progress", Fva11: float32(per1000 / 100.0)})
|
|
|
+ // socket.BroadMsgObj(&entity.NormMsg{Sub: eventName, Type: "progress", Fva11: float32(per1000 / 100.0)})
|
|
|
+ unzipProgressJsFunc := fmt.Sprintf("UnzipProgressJsFunc('%s','%s',%f)", sid, "progress", float32(per1000/100.0))
|
|
|
+ fmt.Println("UnzipProgressJsFunc:", unzipProgressJsFunc)
|
|
|
+ window.Chromium().ExecuteJavaScript(unzipProgressJsFunc, "", 0)
|
|
|
})
|
|
|
if err != nil {
|
|
|
- socket.BroadMsgObj(&entity.NormMsg{Sub: eventName, Type: "error", Error: err.Error()})
|
|
|
+ // socket.BroadMsgObj(&entity.NormMsg{Sub: eventName, Type: "error", Error: err.Error()})
|
|
|
+ unzipErrorJsFunc := fmt.Sprintf("UnzipErrorJsFunc('%s','%s')", sid, "error")
|
|
|
+ fmt.Println("UnzipErrorJsFunc:", unzipErrorJsFunc)
|
|
|
+ window.Chromium().ExecuteJavaScript(unzipErrorJsFunc, "", 0)
|
|
|
return
|
|
|
}
|
|
|
- socket.BroadMsgObj(&entity.NormMsg{Sub: eventName, Type: "succ"})
|
|
|
+ // socket.BroadMsgObj(&entity.NormMsg{Sub: eventName, Type: "succ"})
|
|
|
+ unzipSuccJsFunc := fmt.Sprintf("UnzipSuccJsFunc('%s','%s')", sid, "succ")
|
|
|
+ fmt.Println("UnzipSuccJsFunc:", unzipSuccJsFunc)
|
|
|
+ window.Chromium().ExecuteJavaScript(unzipSuccJsFunc, "", 0)
|
|
|
}()
|
|
|
return true
|
|
|
})
|