阶段性提交

This commit is contained in:
刘祥超
2021-06-27 21:59:06 +08:00
parent bd34a9bd37
commit 963be2bc63
42 changed files with 956 additions and 139 deletions

View File

@@ -2,22 +2,33 @@ package ui
import (
"bytes"
"crypto/md5"
"encoding/json"
"fmt"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/conds/condutils"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/files"
"github.com/iwind/TeaGo/logs"
"net/http"
)
type ComponentsAction actions.Action
var componentsData = []byte{}
var componentsDataSum string
func (this *ComponentsAction) RunGet(params struct{}) {
this.AddHeader("Content-Type", "text/javascript; charset=utf-8")
// etag
var requestETag = this.Header("If-None-Match")
if len(requestETag) > 0 && requestETag == "\""+componentsDataSum+"\"" {
this.ResponseWriter.WriteHeader(http.StatusNotModified)
return
}
if !Tea.IsTesting() && len(componentsData) > 0 {
this.AddHeader("Last-Modified", "Fri, 06 Sep 2019 08:29:50 GMT")
this.Write(componentsData)
@@ -81,5 +92,12 @@ func (this *ComponentsAction) RunGet(params struct{}) {
}
componentsData = buffer.Bytes()
// ETag
var h = md5.New()
h.Write(buffer.Bytes())
componentsDataSum = fmt.Sprintf("%x", h.Sum(nil))
this.AddHeader("ETag", "\""+componentsDataSum+"\"")
this.Write(componentsData)
}