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,91 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
package browser
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
}) {
browserResp, err := this.RPC().FormalClientBrowserRPC().FindFormalClientBrowserWithDataId(this.AdminContext(), &pb.FindFormalClientBrowserWithDataIdRequest{DataId: params.DataId})
if err != nil {
this.ErrorPage(err)
return
}
var browser = browserResp.FormalClientBrowser
if browser == nil {
this.NotFound("formalClientBrowser", 0)
return
}
if browser.Codes == nil {
browser.Codes = []string{}
}
this.Data["browser"] = maps.Map{
"id": browser.Id,
"name": browser.Name,
"codes": browser.Codes,
"dataId": browser.DataId,
}
this.Show()
}
func (this *UpdatePopupAction) RunPost(params struct {
BrowserId int64
Name string
Codes []string
DataId string
Must *actions.Must
CSRF *actionutils.CSRF
}) {
defer this.CreateLogInfo(codes.ClientBrowser_LogUpdateClientBrowser, params.BrowserId)
params.Must.
Field("name", params.Name).
Require("请输入浏览器名称").
Field("dataId", params.DataId).
Require("请输入数据ID")
if len(params.Codes) == 0 {
params.Codes = []string{params.Name}
}
// 检查dataId
browserResp, err := this.RPC().FormalClientBrowserRPC().FindFormalClientBrowserWithDataId(this.AdminContext(), &pb.FindFormalClientBrowserWithDataIdRequest{DataId: params.DataId})
if err != nil {
this.ErrorPage(err)
return
}
if browserResp.FormalClientBrowser != nil && browserResp.FormalClientBrowser.Id != params.BrowserId {
this.Fail("该数据ID已经被 '" + browserResp.FormalClientBrowser.Name + "'所使用,请换一个")
return
}
_, err = this.RPC().FormalClientBrowserRPC().UpdateFormalClientBrowser(this.AdminContext(), &pb.UpdateFormalClientBrowserRequest{
FormalClientBrowserId: params.BrowserId,
Name: params.Name,
Codes: params.Codes,
DataId: params.DataId,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}

View File

@@ -0,0 +1,66 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
package clientbrowsers
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.ClientBrowser_LogCreateBrowser, 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
browserResp, err := this.RPC().FormalClientBrowserRPC().FindFormalClientBrowserWithDataId(this.AdminContext(), &pb.FindFormalClientBrowserWithDataIdRequest{DataId: params.DataId})
if err != nil {
this.ErrorPage(err)
return
}
if browserResp.FormalClientBrowser != nil {
this.Fail("该数据ID已经被 '" + browserResp.FormalClientBrowser.Name + "'所使用,请换一个")
return
}
_, err = this.RPC().FormalClientBrowserRPC().CreateFormalClientBrowser(this.AdminContext(), &pb.CreateFormalClientBrowserRequest{
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 clientbrowsers
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().FormalClientBrowserRPC().CountFormalClientBrowsers(this.AdminContext(), &pb.CountFormalClientBrowsersRequest{
Keyword: params.Keyword,
})
if err != nil {
this.ErrorPage(err)
return
}
var page = this.NewPage(countResp.Count)
this.Data["page"] = page.AsHTML()
browsersResp, err := this.RPC().FormalClientBrowserRPC().ListFormalClientBrowsers(this.AdminContext(), &pb.ListFormalClientBrowsersRequest{
Keyword: params.Keyword,
Offset: page.Offset,
Size: page.Size,
})
if err != nil {
this.ErrorPage(err)
return
}
var browserMaps = []maps.Map{}
for _, browser := range browsersResp.FormalClientBrowsers {
var codes = browser.Codes
if codes == nil {
codes = []string{}
}
browserMaps = append(browserMaps, maps.Map{
"id": browser.Id,
"name": browser.Name,
"codes": codes,
"dataId": browser.DataId,
})
}
this.Data["browsers"] = browserMaps
this.Show()
}

View File

@@ -0,0 +1,33 @@
//go:build plus
package clientbrowsers
import (
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
"github.com/TeaOSLab/EdgeAdmin/internal/plus"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/client-browsers/browser"
"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("clientBrowser")).
//
Prefix("/settings/client-browsers").
Get("", new(IndexAction)).
GetPost("/createPopup", new(CreatePopupAction)).
//
Prefix("/settings/client-browsers/browser").
GetPost("/updatePopup", new(browser.UpdatePopupAction)).
//
EndAll()
})
}