From 776bc95d3be7e8d4bfbaaf202232aa20fcbdfa03 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Fri, 4 Nov 2022 15:19:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=B8=8D=E5=BF=85=E8=A6=81?= =?UTF-8?q?=E7=9A=84=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/configloaders/user_ui_config.go | 96 ------------------------ internal/web/import.go | 1 - 2 files changed, 97 deletions(-) delete mode 100644 internal/configloaders/user_ui_config.go diff --git a/internal/configloaders/user_ui_config.go b/internal/configloaders/user_ui_config.go deleted file mode 100644 index 73fcf71b..00000000 --- a/internal/configloaders/user_ui_config.go +++ /dev/null @@ -1,96 +0,0 @@ -package configloaders - -import ( - "encoding/json" - "github.com/TeaOSLab/EdgeAdmin/internal/rpc" - "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" - "github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs" - "github.com/iwind/TeaGo/logs" - "reflect" -) - -var sharedUserUIConfig *systemconfigs.UserUIConfig = nil - -const ( - UserUISettingName = "userUIConfig" -) - -func LoadUserUIConfig() (*systemconfigs.UserUIConfig, error) { - locker.Lock() - defer locker.Unlock() - - config, err := loadUserUIConfig() - if err != nil { - return nil, err - } - - v := reflect.Indirect(reflect.ValueOf(config)).Interface().(systemconfigs.UserUIConfig) - return &v, nil -} - -func UpdateUserUIConfig(uiConfig *systemconfigs.UserUIConfig) error { - locker.Lock() - defer locker.Unlock() - - var rpcClient, err = rpc.SharedRPC() - if err != nil { - return err - } - valueJSON, err := json.Marshal(uiConfig) - if err != nil { - return err - } - _, err = rpcClient.SysSettingRPC().UpdateSysSetting(rpcClient.Context(0), &pb.UpdateSysSettingRequest{ - Code: UserUISettingName, - ValueJSON: valueJSON, - }) - if err != nil { - return err - } - sharedUserUIConfig = uiConfig - - return nil -} - -func loadUserUIConfig() (*systemconfigs.UserUIConfig, error) { - if sharedUserUIConfig != nil { - return sharedUserUIConfig, nil - } - var rpcClient, err = rpc.SharedRPC() - if err != nil { - return nil, err - } - resp, err := rpcClient.SysSettingRPC().ReadSysSetting(rpcClient.Context(0), &pb.ReadSysSettingRequest{ - Code: UserUISettingName, - }) - if err != nil { - return nil, err - } - if len(resp.ValueJSON) == 0 { - sharedUserUIConfig = defaultUserUIConfig() - return sharedUserUIConfig, nil - } - - config := &systemconfigs.UserUIConfig{} - err = json.Unmarshal(resp.ValueJSON, config) - if err != nil { - logs.Println("[UI_MANAGER]" + err.Error()) - sharedUserUIConfig = defaultUserUIConfig() - return sharedUserUIConfig, nil - } - sharedUserUIConfig = config - return sharedUserUIConfig, nil -} - -func defaultUserUIConfig() *systemconfigs.UserUIConfig { - return &systemconfigs.UserUIConfig{ - ProductName: "GoEdge", - UserSystemName: "GoEdge用户系统", - ShowOpenSourceInfo: true, - ShowVersion: true, - ShowFinance: true, - BandwidthUnit: systemconfigs.BandwidthUnitBit, - ShowBandwidthCharts: true, - ShowTrafficCharts: true, - } -} diff --git a/internal/web/import.go b/internal/web/import.go index 4af82413..caf87fe6 100644 --- a/internal/web/import.go +++ b/internal/web/import.go @@ -124,7 +124,6 @@ import ( _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/ui" _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/updates" _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/upgrade" - _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/user-ui" // 恢复 _ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/recover"