2020-10-04 20:38:27 +08:00
|
|
|
package cache
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
|
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
|
|
|
|
"github.com/iwind/TeaGo/actions"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type CreatePopupAction struct {
|
|
|
|
|
actionutils.ParentAction
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (this *CreatePopupAction) Init() {
|
|
|
|
|
this.Nav("", "", "")
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-08 22:46:08 +08:00
|
|
|
func (this *CreatePopupAction) RunGet(params struct {
|
|
|
|
|
IsReverse bool
|
|
|
|
|
}) {
|
|
|
|
|
this.Data["isReverse"] = params.IsReverse
|
|
|
|
|
|
2020-10-04 20:38:27 +08:00
|
|
|
this.Show()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (this *CreatePopupAction) RunPost(params struct {
|
2020-12-17 15:50:44 +08:00
|
|
|
CacheRefJSON []byte
|
2020-10-04 20:38:27 +08:00
|
|
|
|
|
|
|
|
Must *actions.Must
|
|
|
|
|
}) {
|
|
|
|
|
cacheRef := &serverconfigs.HTTPCacheRef{}
|
2020-12-17 15:50:44 +08:00
|
|
|
err := json.Unmarshal(params.CacheRefJSON, cacheRef)
|
2020-10-04 20:38:27 +08:00
|
|
|
if err != nil {
|
|
|
|
|
this.ErrorPage(err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if len(cacheRef.Key) == 0 {
|
|
|
|
|
this.Fail("请输入缓存Key")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err = cacheRef.Init()
|
|
|
|
|
if err != nil {
|
|
|
|
|
this.ErrorPage(err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.Data["cacheRef"] = cacheRef
|
|
|
|
|
|
|
|
|
|
this.Success()
|
|
|
|
|
}
|