前端页面

This commit is contained in:
robin
2026-02-24 22:43:49 +08:00
parent 2eb32b9f1f
commit 4d275c921d
18 changed files with 611 additions and 485 deletions

View File

@@ -1,23 +0,0 @@
package apps
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/iwind/TeaGo/actions"
)
type AppSettingsResetAESSecretAction struct {
actionutils.ParentAction
}
func (this *AppSettingsResetAESSecretAction) RunPost(params struct {
AppId int64
Must *actions.Must
CSRF *actionutils.CSRF
}) {
params.Must.Field("appId", params.AppId).Gt(0, "请选择应用")
app := pickApp(params.AppId)
resetAESSecret(app)
this.Success()
}

View File

@@ -17,7 +17,6 @@ var appSettingsStore = struct {
func defaultAppSettings(app maps.Map) maps.Map {
signSecretPlain := randomPlainSecret("ss")
aesSecretPlain := randomPlainSecret("as")
return maps.Map{
"appId": app.GetString("appId"),
"primaryClusterId": app.GetInt64("clusterId"),
@@ -25,9 +24,6 @@ func defaultAppSettings(app maps.Map) maps.Map {
"signSecretPlain": signSecretPlain,
"signSecretMasked": maskSecret(signSecretPlain),
"signSecretUpdatedAt": "2026-02-20 12:30:00",
"aesSecretPlain": aesSecretPlain,
"aesSecretMasked": maskSecret(aesSecretPlain),
"aesSecretUpdatedAt": "2026-02-12 09:45:00",
"appStatus": app.GetBool("isOn"),
"defaultTTL": 30,
"fallbackTimeoutMs": 300,
@@ -52,9 +48,6 @@ func cloneSettings(settings maps.Map) maps.Map {
"signSecretPlain": settings.GetString("signSecretPlain"),
"signSecretMasked": settings.GetString("signSecretMasked"),
"signSecretUpdatedAt": settings.GetString("signSecretUpdatedAt"),
"aesSecretPlain": settings.GetString("aesSecretPlain"),
"aesSecretMasked": settings.GetString("aesSecretMasked"),
"aesSecretUpdatedAt": settings.GetString("aesSecretUpdatedAt"),
"appStatus": settings.GetBool("appStatus"),
"defaultTTL": settings.GetInt("defaultTTL"),
"fallbackTimeoutMs": settings.GetInt("fallbackTimeoutMs"),
@@ -110,16 +103,6 @@ func resetSignSecret(app maps.Map) maps.Map {
return settings
}
func resetAESSecret(app maps.Map) maps.Map {
settings := loadAppSettings(app)
aesSecretPlain := randomPlainSecret("as")
settings["aesSecretPlain"] = aesSecretPlain
settings["aesSecretMasked"] = maskSecret(aesSecretPlain)
settings["aesSecretUpdatedAt"] = nowDateTime()
saveAppSettings(app.GetInt64("id"), settings)
return settings
}
func nowDateTime() string {
return time.Now().Format("2006-01-02 15:04:05")
}
@@ -182,21 +165,6 @@ func ensureSettingsFields(settings maps.Map) bool {
changed = true
}
aesSecretPlain := settings.GetString("aesSecretPlain")
if len(aesSecretPlain) == 0 {
aesSecretPlain = randomPlainSecret("as")
settings["aesSecretPlain"] = aesSecretPlain
changed = true
}
if len(settings.GetString("aesSecretMasked")) == 0 {
settings["aesSecretMasked"] = maskSecret(aesSecretPlain)
changed = true
}
if len(settings.GetString("aesSecretUpdatedAt")) == 0 {
settings["aesSecretUpdatedAt"] = nowDateTime()
changed = true
}
if len(settings.GetString("sniPolicy")) == 0 {
settings["sniPolicy"] = "level2"
changed = true

View File

@@ -19,7 +19,6 @@ func init() {
GetPost("/app/settings", new(AppSettingsAction)).
Post("/app/settings/toggleSignEnabled", new(AppSettingsToggleSignEnabledAction)).
Post("/app/settings/resetSignSecret", new(AppSettingsResetSignSecretAction)).
Post("/app/settings/resetAESSecret", new(AppSettingsResetAESSecretAction)).
Get("/domains", new(DomainsAction)).
Get("/customRecords", new(CustomRecordsAction)).
GetPost("/createPopup", new(CreatePopupAction)).

View File

@@ -45,7 +45,7 @@ func (this *ClusterSettingsAction) RunGet(params struct {
cid := strconv.FormatInt(params.ClusterId, 10)
this.Data["leftMenuItems"] = []map[string]interface{}{
{"name": "基础设置", "url": "/httpdns/clusters/cluster/settings?clusterId=" + cid + "&section=basic", "isActive": section == "basic"},
{"name": "TLS", "url": "/httpdns/clusters/cluster/settings?clusterId=" + cid + "&section=tls", "isActive": section == "tls"},
{"name": "端口设置", "url": "/httpdns/clusters/cluster/settings?clusterId=" + cid + "&section=tls", "isActive": section == "tls"},
}
settings["isDefaultCluster"] = (policies.LoadDefaultClusterID() == cluster.GetInt64("id"))
@@ -88,7 +88,8 @@ func (this *ClusterSettingsAction) RunGet(params struct {
}
} else {
sslPolicy = &sslconfigs.SSLPolicy{
IsOn: true,
IsOn: true,
MinVersion: "TLS 1.1",
}
}

View File

@@ -3,6 +3,7 @@ package sandbox
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/httpdns/httpdnsutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/httpdns/policies"
)
type IndexAction struct {
@@ -15,21 +16,29 @@ func (this *IndexAction) Init() {
func (this *IndexAction) RunGet(params struct{}) {
httpdnsutils.AddLeftMenu(this.Parent())
this.Data["clusters"] = policies.LoadAvailableDeployClusters()
this.Data["apps"] = []map[string]interface{}{
{
"id": int64(1),
"name": "主站移动业务",
"appId": "ab12xc34s2",
"id": int64(1),
"name": "主站移动业务",
"appId": "ab12xc34s2",
"clusterId": int64(1),
"domains": []string{"api.business.com", "www.aliyun.com"},
},
{
"id": int64(2),
"name": "视频网关业务",
"appId": "vd8992ksm1",
"id": int64(2),
"name": "支付网关业务",
"appId": "vd8992ksm1",
"clusterId": int64(2),
"domains": []string{"payment.business.com"},
},
{
"id": int64(3),
"name": "海外灰度测试",
"appId": "ov7711hkq9",
"id": int64(3),
"name": "海外灰度测试",
"appId": "ov7711hkq9",
"clusterId": int64(1),
"domains": []string{"global.example.com", "edge.example.com"},
},
}
this.Show()

View File

@@ -6,6 +6,7 @@ import (
"strconv"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/httpdns/policies"
"github.com/iwind/TeaGo/maps"
)
@@ -14,10 +15,11 @@ type TestAction struct {
}
func (this *TestAction) RunPost(params struct {
AppId string
Domain string
ClientIp string
Qtype string
AppId string
ClusterId int64
Domain string
ClientIp string
Qtype string
}) {
if len(params.ClientIp) == 0 {
params.ClientIp = "203.0.113.100"
@@ -40,7 +42,11 @@ func (this *TestAction) RunPost(params struct {
query.Set("dn", params.Domain)
query.Set("cip", params.ClientIp)
query.Set("qtype", params.Qtype)
requestURL := "https://api.httpdns.example.com/resolve?" + query.Encode()
clusterServiceDomain := policies.LoadClusterGatewayByID(params.ClusterId)
if len(clusterServiceDomain) == 0 {
clusterServiceDomain = "gw.httpdns.example.com"
}
requestURL := "https://" + clusterServiceDomain + "/resolve?" + query.Encode()
this.Data["result"] = maps.Map{
"code": 0,