部分中文转换为多语言代号

This commit is contained in:
刘祥超
2023-06-30 18:08:30 +08:00
parent 65555e1fe3
commit 5e38b1fbca
322 changed files with 884 additions and 733 deletions

View File

@@ -1,8 +1,7 @@
package api
import (
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
import ( "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
)
@@ -14,7 +13,7 @@ func (this *DeleteAction) RunPost(params struct {
NodeId int64
}) {
// 创建日志
defer this.CreateLog(oplogs.LevelInfo, "删除API节点 %d", params.NodeId)
defer this.CreateLogInfo(codes.APINode_LogDeleteAPINode, params.NodeId)
// 检查是否是唯一的节点
nodeResp, err := this.RPC().APINodeRPC().FindEnabledAPINode(this.AdminContext(), &pb.FindEnabledAPINodeRequest{ApiNodeId: params.NodeId})

View File

@@ -2,9 +2,9 @@ package node
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs"
@@ -211,7 +211,7 @@ func (this *CreatePopupAction) RunPost(params struct {
}
// 创建日志
defer this.CreateLog(oplogs.LevelInfo, "创建API节点 %d", createResp.ApiNodeId)
defer this.CreateLogInfo(codes.APINode_LogCreateAPINode, createResp.ApiNodeId)
this.Success()
}

View File

@@ -2,9 +2,9 @@ package node
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs"
@@ -335,7 +335,7 @@ func (this *UpdateAction) RunPost(params struct {
}
// 创建日志
defer this.CreateLog(oplogs.LevelInfo, "修改API节点 %d", params.NodeId)
defer this.CreateLogInfo(codes.APINode_LogUpdateAPINode, params.NodeId)
this.Success()
}

View File

@@ -3,6 +3,7 @@ package database
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
"github.com/iwind/TeaGo/actions"
@@ -42,7 +43,7 @@ func (this *CleanSettingAction) RunPost(params struct {
Must *actions.Must
CSRF *actionutils.CSRF
}) {
defer this.CreateLogInfo("修改数据库自动清理设置")
defer this.CreateLogInfo(codes.Database_LogUpdateCleanDays)
days := params.Days
if days < 0 {

View File

@@ -2,6 +2,7 @@ package database
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
)
@@ -12,7 +13,7 @@ type DeleteTableAction struct {
func (this *DeleteTableAction) RunPost(params struct {
Table string
}) {
defer this.CreateLogInfo("删除数据表 %s", params.Table)
defer this.CreateLogInfo(codes.Database_LogDeleteTable, params.Table)
_, err := this.RPC().DBRPC().DeleteDBTable(this.AdminContext(), &pb.DeleteDBTableRequest{DbTable: params.Table})
if err != nil {

View File

@@ -2,6 +2,7 @@ package database
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
)
@@ -12,7 +13,7 @@ type TruncateTableAction struct {
func (this *TruncateTableAction) RunPost(params struct {
Table string
}) {
defer this.CreateLogInfo("清空数据表 %s 数据", params.Table)
defer this.CreateLogInfo(codes.Database_LogTruncateTable, params.Table)
_, err := this.RPC().DBRPC().TruncateDBTable(this.AdminContext(), &pb.TruncateDBTableRequest{DbTable: params.Table})
if err != nil {

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/actions"
@@ -99,7 +100,7 @@ func (this *UpdateAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改API节点数据库设置")
defer this.CreateLogInfo(codes.Database_LogUpdateAPINodeDatabaseConfig)
params.Must.
Field("host", params.Host).

View File

@@ -3,6 +3,7 @@ package login
import (
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
"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"
@@ -42,7 +43,7 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改登录设置")
defer this.CreateLogInfo(codes.AdminLogin_LogUpdateLogin)
params.Must.
Field("username", params.Username).

View File

@@ -3,6 +3,7 @@ package database
import (
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
"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"
@@ -40,7 +41,7 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改个人资料")
defer this.CreateLogInfo(codes.AdminProfile_LogUpdateProfile)
params.Must.
Field("fullname", params.Fullname).

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
"github.com/iwind/TeaGo/actions"
@@ -87,7 +88,7 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
CSRF *actionutils.CSRF
}) {
defer this.CreateLogInfo("修改管理界面安全设置")
defer this.CreateLogInfo(codes.AdminSecurity_LogUpdateSecuritySettings)
config, err := configloaders.LoadSecurityConfig()
if err != nil {

View File

@@ -4,6 +4,7 @@ import (
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
adminserverutils "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/server/admin-server-utils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/iwind/TeaGo/actions"
"net"
)
@@ -33,7 +34,7 @@ func (this *UpdateHTTPPopupAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改管理界面的HTTP设置")
defer this.CreateLogInfo(codes.AdminServer_LogUpdateServerHTTPSettings)
if len(params.Listens) == 0 {
this.Fail("请输入绑定地址")

View File

@@ -5,6 +5,7 @@ import (
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
adminserverutils "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/server/admin-server-utils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs"
"github.com/iwind/TeaGo/Tea"
@@ -65,7 +66,7 @@ func (this *UpdateHTTPSPopupAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改管理界面的HTTPS设置")
defer this.CreateLogInfo(codes.AdminServer_LogUpdateServerHTTPSSettings)
if len(params.Listens) == 0 {
this.Fail("请输入绑定地址")

View File

@@ -4,6 +4,7 @@ package settingutils
import (
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
@@ -34,12 +35,12 @@ func (this *AdvancedHelper) BeforeAction(actionPtr actions.ActionWrapper) (goNex
// 标签栏
var tabbar = actionutils.NewTabbar()
var session = action.Session()
var adminId = session.GetInt64("adminId")
var adminId = session.GetInt64(teaconst.SessionAdminId)
if configloaders.AllowModule(adminId, configloaders.AdminModuleCodeSetting) {
tabbar.Add(this.Lang(actionPtr, codes.AdminSettingsTabTransfer), "", "/settings/database", "", this.tab == "database")
tabbar.Add(this.Lang(actionPtr, codes.AdminSettingsTabAPINodes), "", "/settings/api", "", this.tab == "apiNodes")
tabbar.Add(this.Lang(actionPtr, codes.AdminSettingsTabAccessLogDatabases), "", "/db", "", this.tab == "dbNodes")
tabbar.Add(this.Lang(actionPtr, codes.AdminSettingsTabTransfer), "", "/settings/transfer", "", this.tab == "transfer")
tabbar.Add(this.Lang(actionPtr, codes.AdminSetting_TabTransfer), "", "/settings/database", "", this.tab == "database")
tabbar.Add(this.Lang(actionPtr, codes.AdminSetting_TabAPINodes), "", "/settings/api", "", this.tab == "apiNodes")
tabbar.Add(this.Lang(actionPtr, codes.AdminSetting_TabAccessLogDatabases), "", "/db", "", this.tab == "dbNodes")
tabbar.Add(this.Lang(actionPtr, codes.AdminSetting_TabTransfer), "", "/settings/transfer", "", this.tab == "transfer")
//tabbar.Add(codes.AdminSettingsTabBackup, "", "/settings/backup", "", this.tab == "backup")
}

View File

@@ -4,6 +4,7 @@ package settingutils
import (
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
@@ -34,15 +35,15 @@ func (this *Helper) BeforeAction(actionPtr actions.ActionWrapper) (goNext bool)
// 标签栏
var tabbar = actionutils.NewTabbar()
var session = action.Session()
var adminId = session.GetInt64("adminId")
var adminId = session.GetInt64(teaconst.SessionAdminId)
if configloaders.AllowModule(adminId, configloaders.AdminModuleCodeSetting) {
tabbar.Add(this.Lang(actionPtr, codes.AdminSettingsTabAdminServer), "", "/settings/server", "", this.tab == "server")
tabbar.Add(this.Lang(actionPtr, codes.AdminSettingsTabAdminUI), "", "/settings/ui", "", this.tab == "ui")
tabbar.Add(this.Lang(actionPtr, codes.AdminSettingsTabAdminSecuritySettings), "", "/settings/security", "", this.tab == "security")
tabbar.Add(this.Lang(actionPtr, codes.AdminSettingsTabUpdates), "", "/settings/updates", "", this.tab == "updates")
tabbar.Add(this.Lang(actionPtr, codes.AdminSetting_TabAdminServer), "", "/settings/server", "", this.tab == "server")
tabbar.Add(this.Lang(actionPtr, codes.AdminSetting_TabAdminUI), "", "/settings/ui", "", this.tab == "ui")
tabbar.Add(this.Lang(actionPtr, codes.AdminSetting_TabAdminSecuritySettings), "", "/settings/security", "", this.tab == "security")
tabbar.Add(this.Lang(actionPtr, codes.AdminSetting_TabUpdates), "", "/settings/updates", "", this.tab == "updates")
}
tabbar.Add(this.Lang(actionPtr, codes.AdminSettingsTabProfile), "", "/settings/profile", "", this.tab == "profile")
tabbar.Add(this.Lang(actionPtr, codes.AdminSettingsTabLogin), "", "/settings/login", "", this.tab == "login")
tabbar.Add(this.Lang(actionPtr, codes.AdminSetting_TabProfile), "", "/settings/profile", "", this.tab == "profile")
tabbar.Add(this.Lang(actionPtr, codes.AdminSetting_TabLogin), "", "/settings/login", "", this.tab == "login")
actionutils.SetTabbar(actionPtr, tabbar)
return

View File

@@ -3,6 +3,7 @@ package ui
import (
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/userconfigs"
@@ -61,7 +62,7 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
CSRF *actionutils.CSRF
}) {
defer this.CreateLogInfo("修改管理界面设置")
defer this.CreateLogInfo(codes.AdminUI_LogUpdateUISettings)
params.Must.
Field("productName", params.ProductName).

View File

@@ -6,6 +6,7 @@ import (
"encoding/json"
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
)
@@ -17,7 +18,7 @@ type IgnoreVersionAction struct {
func (this *IgnoreVersionAction) RunPost(params struct {
Version string
}) {
defer this.CreateLogInfo("忽略升级版本 %s", params.Version)
defer this.CreateLogInfo(codes.AdminUpdate_LogIgnoreVersion, params.Version)
if len(params.Version) == 0 {
this.Fail("请输入要忽略的版本号")

View File

@@ -5,6 +5,7 @@ package updates
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
)
@@ -14,7 +15,7 @@ type ResetIgnoredVersionAction struct {
}
func (this *ResetIgnoredVersionAction) RunPost(params struct{}) {
defer this.CreateLogInfo("重置忽略升级版本")
defer this.CreateLogInfo(codes.AdminUpdate_LogResetIgnoreVersion)
valueResp, err := this.RPC().SysSettingRPC().ReadSysSetting(this.AdminContext(), &pb.ReadSysSettingRequest{Code: systemconfigs.SettingCodeCheckUpdates})
if err != nil {

View File

@@ -6,6 +6,7 @@ import (
"encoding/json"
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
)
@@ -17,7 +18,7 @@ type UpdateAction struct {
func (this *UpdateAction) RunPost(params struct {
AutoCheck bool
}) {
defer this.CreateLogInfo("修改检查更新设置")
defer this.CreateLogInfo(codes.AdminUpdate_LogUpdateCheckSettings)
// 读取当前设置
valueResp, err := this.RPC().SysSettingRPC().ReadSysSetting(this.AdminContext(), &pb.ReadSysSettingRequest{Code: systemconfigs.SettingCodeCheckUpdates})