update
This commit is contained in:
parent
12c18677fc
commit
a007f255f1
@ -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 {
|
||||
|
@ -0,0 +1,5 @@
|
||||
解压文件
|
||||
- resources
|
||||
- RobotGUI.exe
|
||||
|
||||
建议覆盖所有文件
|
@ -20,21 +20,7 @@
|
||||
|
||||
<body>
|
||||
<div id="app">
|
||||
|
||||
<h1>上传原型,获取永久在线浏览地址</h1>
|
||||
|
||||
<upload type="drag" action="/upload" paste="true" accept=".zip" :on-success="handleSuccess">
|
||||
<div style="padding: 20px 0">
|
||||
<icon type="ios-cloud-upload" size="52" style="color: #3399ff"></icon>
|
||||
<p>点击或者拖拽上传</p>
|
||||
</div>
|
||||
</upload>
|
||||
|
||||
<alert type="success" v-for="url in zips">
|
||||
浏览地址:${ url }
|
||||
</alert>
|
||||
|
||||
|
||||
<h1>下载更新包</h1>
|
||||
|
||||
<strong>历史prd:</strong>
|
||||
<br><br>
|
||||
|
69
cmd/upgrade/views/upload.html
Normal file
69
cmd/upgrade/views/upload.html
Normal file
@ -0,0 +1,69 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>上传</title>
|
||||
<!-- import Vue.js -->
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.6/vue.min.js"></script>
|
||||
<!-- import stylesheet -->
|
||||
<link href="https://cdn.bootcdn.net/ajax/libs/iview/3.5.5-rc.1/styles/iview.min.css" rel="stylesheet">
|
||||
<!-- import iView -->
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/iview/3.5.5-rc.1/iview.min.js"></script>
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
|
||||
<style>
|
||||
#app {
|
||||
margin: 20px 40px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app">
|
||||
|
||||
<h1>上传文件</h1>
|
||||
|
||||
<upload type="drag" action="/upload" paste="true" accept=".zip" :on-success="handleSuccess">
|
||||
<div style="padding: 20px 0">
|
||||
<icon type="ios-cloud-upload" size="52" style="color: #3399ff"></icon>
|
||||
<p>点击或者拖拽上传</p>
|
||||
</div>
|
||||
</upload>
|
||||
|
||||
<alert type="success" v-for="url in zips">
|
||||
浏览地址:${ url }
|
||||
</alert>
|
||||
|
||||
|
||||
|
||||
<strong>历史prd:</strong>
|
||||
<br><br>
|
||||
<list border>
|
||||
<list-item v-for="dir in dirs">
|
||||
<a :href="dir.url" target="_blank">${ dir.name }</a> <span>${ dir.dateTime}</span>
|
||||
</list-item>
|
||||
</list>
|
||||
</div>
|
||||
<script>
|
||||
new Vue({
|
||||
el: "#app",
|
||||
delimiters: ['${', '}'],
|
||||
data: {
|
||||
zips: [],
|
||||
dirs: [],
|
||||
},
|
||||
methods: {
|
||||
handleSuccess(response, file, fileList) {
|
||||
this.zips.push(response.url)
|
||||
}
|
||||
},
|
||||
created() {
|
||||
axios.get("/dirs").then((res) => {
|
||||
this.dirs = res.data.dirs
|
||||
})
|
||||
},
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,8 +0,0 @@
|
||||
Website = "https://legu.com"
|
||||
|
||||
[Details]
|
||||
Icon = "Icon.png"
|
||||
Name = "RobotGUI"
|
||||
ID = "com.legu.app"
|
||||
Version = "1.0.1"
|
||||
Build = 8
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user