Initial commit (code only without large binaries)

This commit is contained in:
robin
2026-02-15 18:58:44 +08:00
commit 35df75498f
9442 changed files with 1495866 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
package providers
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/ip-library/iplibraryutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
)
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.Nav("", "", "provider")
}
func (this *IndexAction) RunGet(params struct{}) {
// 检查权限
if !iplibraryutils.CanAccess() {
return
}
this.Data["canAccess"] = true
providersResp, err := this.RPC().RegionProviderRPC().FindAllRegionProviders(this.AdminContext(), &pb.FindAllRegionProvidersRequest{})
if err != nil {
this.ErrorPage(err)
return
}
var providerMaps = []maps.Map{}
for _, provider := range providersResp.RegionProviders {
if provider.Codes == nil {
provider.Codes = []string{}
}
if provider.CustomCodes == nil {
provider.CustomCodes = []string{}
}
providerMaps = append(providerMaps, maps.Map{
"id": provider.Id,
"name": provider.Name,
"codes": provider.Codes,
"customName": provider.CustomName,
"customCodes": provider.CustomCodes,
})
}
this.Data["providers"] = providerMaps
this.Show()
}

View File

@@ -0,0 +1,75 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
package providers
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/maps"
)
type UpdatePopupAction struct {
actionutils.ParentAction
}
func (this *UpdatePopupAction) Init() {
this.Nav("", "", "")
}
func (this *UpdatePopupAction) RunGet(params struct {
ProviderId int64
}) {
providerResp, err := this.RPC().RegionProviderRPC().FindRegionProvider(this.AdminContext(), &pb.FindRegionProviderRequest{RegionProviderId: params.ProviderId})
if err != nil {
this.ErrorPage(err)
return
}
var provider = providerResp.RegionProvider
if provider == nil {
this.NotFound("regionProvider", params.ProviderId)
return
}
if provider.Codes == nil {
provider.Codes = []string{}
}
if provider.CustomCodes == nil {
provider.CustomCodes = []string{}
}
this.Data["provider"] = maps.Map{
"id": provider.Id,
"name": provider.Name,
"codes": provider.Codes,
"customName": provider.CustomName,
"customCodes": provider.CustomCodes,
}
this.Show()
}
func (this *UpdatePopupAction) RunPost(params struct {
ProviderId int64
CustomName string
CustomCodes []string
Must *actions.Must
CSRF *actionutils.CSRF
}) {
defer this.CreateLogInfo(codes.RegionProvider_LogUpdateRegionProviderCustom, params.ProviderId)
_, err := this.RPC().RegionProviderRPC().UpdateRegionProviderCustom(this.AdminContext(), &pb.UpdateRegionProviderCustomRequest{
RegionProviderId: params.ProviderId,
CustomName: params.CustomName,
CustomCodes: params.CustomCodes,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}