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,66 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
package clientsystems
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"
)
type CreatePopupAction struct {
actionutils.ParentAction
}
func (this *CreatePopupAction) Init() {
this.Nav("", "", "")
}
func (this *CreatePopupAction) RunGet(params struct{}) {
this.Show()
}
func (this *CreatePopupAction) RunPost(params struct {
Name string
Codes []string
DataId string
Must *actions.Must
CSRF *actionutils.CSRF
}) {
defer this.CreateLogInfo(codes.ClientSystem_LogCreateSystem, params.Name)
params.Must.
Field("name", params.Name).
Require("请输入操作系统名称").
Field("dataId", params.DataId).
Require("请输入数据ID")
if len(params.Codes) == 0 {
params.Codes = []string{params.Name}
}
// 检查dataId
systemResp, err := this.RPC().FormalClientSystemRPC().FindFormalClientSystemWithDataId(this.AdminContext(), &pb.FindFormalClientSystemWithDataIdRequest{DataId: params.DataId})
if err != nil {
this.ErrorPage(err)
return
}
if systemResp.FormalClientSystem != nil {
this.Fail("该数据ID已经被 '" + systemResp.FormalClientSystem.Name + "'所使用,请换一个")
return
}
_, err = this.RPC().FormalClientSystemRPC().CreateFormalClientSystem(this.AdminContext(), &pb.CreateFormalClientSystemRequest{
Name: params.Name,
Codes: params.Codes,
DataId: params.DataId,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}

View File

@@ -0,0 +1,59 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
package clientsystems
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
)
type IndexAction struct {
actionutils.ParentAction
}
func (this *IndexAction) Init() {
this.Nav("", "", "")
}
func (this *IndexAction) RunGet(params struct {
Keyword string
}) {
this.Data["keyword"] = params.Keyword
countResp, err := this.RPC().FormalClientSystemRPC().CountFormalClientSystems(this.AdminContext(), &pb.CountFormalClientSystemsRequest{
Keyword: params.Keyword,
})
if err != nil {
this.ErrorPage(err)
return
}
var page = this.NewPage(countResp.Count)
this.Data["page"] = page.AsHTML()
systemsResp, err := this.RPC().FormalClientSystemRPC().ListFormalClientSystems(this.AdminContext(), &pb.ListFormalClientSystemsRequest{
Keyword: params.Keyword,
Offset: page.Offset,
Size: page.Size,
})
if err != nil {
this.ErrorPage(err)
return
}
var systemMaps = []maps.Map{}
for _, system := range systemsResp.FormalClientSystems {
var codes = system.Codes
if codes == nil {
codes = []string{}
}
systemMaps = append(systemMaps, maps.Map{
"id": system.Id,
"name": system.Name,
"codes": codes,
"dataId": system.DataId,
})
}
this.Data["systems"] = systemMaps
this.Show()
}

View File

@@ -0,0 +1,33 @@
//go:build plus
package clientsystems
import (
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
"github.com/TeaOSLab/EdgeAdmin/internal/plus"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/client-systems/system"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/settingutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
"github.com/iwind/TeaGo"
)
func init() {
TeaGo.BeforeStart(func(server *TeaGo.Server) {
server.
Helper(plus.NewBasicHelper()).
Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeSetting)).
Helper(settingutils.NewAdvancedHelper("clientSystem")).
//
Prefix("/settings/client-systems").
Get("", new(IndexAction)).
GetPost("/createPopup", new(CreatePopupAction)).
//
Prefix("/settings/client-systems/system").
GetPost("/updatePopup", new(system.UpdatePopupAction)).
//
EndAll()
})
}

View File

@@ -0,0 +1,91 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
package system
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 {
DataId string
}) {
systemResp, err := this.RPC().FormalClientSystemRPC().FindFormalClientSystemWithDataId(this.AdminContext(), &pb.FindFormalClientSystemWithDataIdRequest{DataId: params.DataId})
if err != nil {
this.ErrorPage(err)
return
}
var system = systemResp.FormalClientSystem
if system == nil {
this.NotFound("formalClientSystem", 0)
return
}
if system.Codes == nil {
system.Codes = []string{}
}
this.Data["system"] = maps.Map{
"id": system.Id,
"name": system.Name,
"codes": system.Codes,
"dataId": system.DataId,
}
this.Show()
}
func (this *UpdatePopupAction) RunPost(params struct {
SystemId int64
Name string
Codes []string
DataId string
Must *actions.Must
CSRF *actionutils.CSRF
}) {
defer this.CreateLogInfo(codes.ClientSystem_LogUpdateClientSystem, params.SystemId)
params.Must.
Field("name", params.Name).
Require("请输入操作系统名称").
Field("dataId", params.DataId).
Require("请输入数据ID")
if len(params.Codes) == 0 {
params.Codes = []string{params.Name}
}
// 检查dataId
systemResp, err := this.RPC().FormalClientSystemRPC().FindFormalClientSystemWithDataId(this.AdminContext(), &pb.FindFormalClientSystemWithDataIdRequest{DataId: params.DataId})
if err != nil {
this.ErrorPage(err)
return
}
if systemResp.FormalClientSystem != nil && systemResp.FormalClientSystem.Id != params.SystemId {
this.Fail("该数据ID已经被 '" + systemResp.FormalClientSystem.Name + "'所使用,请换一个")
return
}
_, err = this.RPC().FormalClientSystemRPC().UpdateFormalClientSystem(this.AdminContext(), &pb.UpdateFormalClientSystemRequest{
FormalClientSystemId: params.SystemId,
Name: params.Name,
Codes: params.Codes,
DataId: params.DataId,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}