Browse Source

优化页面显示

master
453530270@qq.com 2 years ago
parent
commit
b35b0b1c76
  1. 1
      fssc/README.md
  2. BIN
      fssc/fssc
  3. 33
      fssc/internal/handler/handler.go
  4. 7
      fssc/web/list.tmpl

1
fssc/README.md

@ -5,3 +5,4 @@
更新服务器
需要更新的文件,上传到更新服务器后,按日期生成更新包
注意最后需要 加上 / 要不然会导致创建的zip文件 包含本地文件名,造成不必要的麻烦

BIN
fssc/fssc

Binary file not shown.

33
fssc/internal/handler/handler.go

@ -19,12 +19,6 @@ import (
"fssc/web"
)
// rpc功能 压缩包的结构体
// 文件路径 文件名
type Args struct {
Zpfile, Fname string
}
// 获取文件大小的接口
type Size interface {
Size() int64
@ -35,31 +29,6 @@ type Stat interface {
Stat() (os.FileInfo, error)
}
// 显示状态
func ReceiveStatus(w http.ResponseWriter, r *http.Request) {
switch r.Method {
// 显示当前传送文件的大小
case http.MethodPost:
file, _, err := r.FormFile("file")
if err != nil {
http.Error(w, err.Error(), 500)
return
}
if statInterface, ok := file.(Stat); ok {
fileInfo, _ := statInterface.Stat()
fmt.Fprintf(w, "上传文件的大小为: %d", fileInfo.Size())
}
if sizeInterface, ok := file.(Size); ok {
fmt.Fprintf(w, "上传文件的大小为: %d", sizeInterface.Size())
}
return
}
// fmt.Fprintf(w, r.Method)
}
/**
** 文件更新服务器
**/
@ -210,6 +179,7 @@ func SendHandler(w http.ResponseWriter, r *http.Request) {
data := struct {
DeviceName string
Loip string
Rundir string
IsDir bool
FileName string
@ -218,6 +188,7 @@ func SendHandler(w http.ResponseWriter, r *http.Request) {
Files []os.DirEntry
}{
DeviceName: config.G.DeviceName,
Loip: config.G.LocalIP,
Rundir: config.G.FilePath,
DownloadPath: downloadPath,
UrlPath: strings.TrimSuffix(r.URL.Path, "/"),

7
fssc/web/list.tmpl

@ -101,7 +101,12 @@
</head>
<body>
<div class="container">
<p>主机名:{{ .DeviceName }}</p>
<div class="jumbotron">
<h4>升级控制台</h4>
<p>主机名:{{ .DeviceName }}</p>
<p>IPv4: {{.Loip}}</p>
</div>
<hr>
{{ if .IsDir }}
<h2>{{ .DownloadPath }}</h2>

Loading…
Cancel
Save