From a007f255f17538bfd77ee8ec18a9b368a5e1cfcc Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Mon, 22 Aug 2022 10:53:52 +0800 Subject: [PATCH] update --- cmd/upgrade/main.go | 50 +++---------------------- cmd/upgrade/readme.md | 5 +++ cmd/upgrade/views/index.html | 16 +------- cmd/upgrade/views/upload.html | 69 +++++++++++++++++++++++++++++++++++ cmd/v2/FyneApp.toml | 8 ---- cmd/v2/ui/about.go | 2 +- 6 files changed, 81 insertions(+), 69 deletions(-) create mode 100644 cmd/upgrade/views/upload.html delete mode 100644 cmd/v2/FyneApp.toml diff --git a/cmd/upgrade/main.go b/cmd/upgrade/main.go index 83e5ff798..687b52f26 100644 --- a/cmd/upgrade/main.go +++ b/cmd/upgrade/main.go @@ -6,61 +6,16 @@ import ( "fmt" "go_dreamfactory/cmd/upgrade/tools" "html/template" - "io" "io/ioutil" "log" "net/http" - "os" "path" - "strconv" "strings" "time" "github.com/gin-gonic/gin" ) -// func main() { -// http.HandleFunc("/download", FileDownload) -// http.HandleFunc("/upload", FileUpload) - -// log.Print("http server start") -// if err := http.ListenAndServe(":8910", nil); err != nil { -// log.Fatal(err) -// } -// } - -func FileUpload(w http.ResponseWriter, r *http.Request) { - //获取文件流,第三个返回值是错误对象 - file, header, _ := r.FormFile("file") - //读取文件流为[]byte - b, _ := ioutil.ReadAll(file) - //把文件保存到指定位置 - ioutil.WriteFile("/opt/upgrade", b, 0777) - //输出上传时文件名 - fmt.Println("上传文件名:", header.Filename) -} - -func FileDownload(w http.ResponseWriter, r *http.Request) { - filename := "E:\\projects\\workspace\\go_dreamfactory\\cmd\\v2\\RobotGUI.exe" - - file, _ := os.Open(filename) - defer file.Close() - - fileHeader := make([]byte, 512) - file.Read(fileHeader) - - fileStat, _ := file.Stat() - - w.Header().Set("Content-Disposition", "attachment; filename="+filename) - w.Header().Set("Content-Type", http.DetectContentType(fileHeader)) - w.Header().Set("Content-Length", strconv.FormatInt(fileStat.Size(), 10)) - - file.Seek(0, 0) - io.Copy(w, file) - - return -} - //go:embed views/* var f embed.FS @@ -92,6 +47,11 @@ func main() { c.HTML(http.StatusOK, "index.html", nil) }) + r.GET("/upload", func(c *gin.Context) { + fmt.Println(tmpl.DefinedTemplates()) + c.HTML(http.StatusOK, "upload.html", nil) + }) + r.POST("/upload", func(c *gin.Context) { f, err := c.FormFile("file") if err != nil { diff --git a/cmd/upgrade/readme.md b/cmd/upgrade/readme.md index e69de29bb..93367b14b 100644 --- a/cmd/upgrade/readme.md +++ b/cmd/upgrade/readme.md @@ -0,0 +1,5 @@ +解压文件 +- resources +- RobotGUI.exe + +建议覆盖所有文件 \ No newline at end of file diff --git a/cmd/upgrade/views/index.html b/cmd/upgrade/views/index.html index d8181e590..c4470ff00 100644 --- a/cmd/upgrade/views/index.html +++ b/cmd/upgrade/views/index.html @@ -20,21 +20,7 @@
- -

上传原型,获取永久在线浏览地址

- - -
- -

点击或者拖拽上传

-
-
- - - 浏览地址:${ url } - - - +

下载更新包

历史prd:

diff --git a/cmd/upgrade/views/upload.html b/cmd/upgrade/views/upload.html new file mode 100644 index 000000000..3f5b8014a --- /dev/null +++ b/cmd/upgrade/views/upload.html @@ -0,0 +1,69 @@ + + + + + + 上传 + + + + + + + + + + + +
+ +

上传文件

+ + +
+ +

点击或者拖拽上传

+
+
+ + + 浏览地址:${ url } + + + + + 历史prd: +

+ + + ${ dir.name }    ${ dir.dateTime} + + +
+ + + + \ No newline at end of file diff --git a/cmd/v2/FyneApp.toml b/cmd/v2/FyneApp.toml deleted file mode 100644 index 2876f20fb..000000000 --- a/cmd/v2/FyneApp.toml +++ /dev/null @@ -1,8 +0,0 @@ -Website = "https://legu.com" - -[Details] - Icon = "Icon.png" - Name = "RobotGUI" - ID = "com.legu.app" - Version = "1.0.1" - Build = 8 diff --git a/cmd/v2/ui/about.go b/cmd/v2/ui/about.go index 9175a2fb5..59ad21395 100644 --- a/cmd/v2/ui/about.go +++ b/cmd/v2/ui/about.go @@ -14,7 +14,7 @@ type about struct { func newAbout() *about { var a about content := widget.NewCard("", "", widget.NewRichTextFromMarkdown(common.APP_ABOUT_INFO)) - a.aboutDialog = dialog.NewCustom(common.APP_ABOUT_TITLE, common.APP_ABOUT_CONFIRM, content, globalWin.w) + a.aboutDialog = dialog.NewCustom(common.APP_ABOUT_TITLE, common.APP_ABOUT_CONFIRM, content, toolWin.w) return &a }