diff --git a/cmd/v2/FyneApp.toml b/cmd/v2/FyneApp.toml index 98ebc255e..c552525f7 100644 --- a/cmd/v2/FyneApp.toml +++ b/cmd/v2/FyneApp.toml @@ -4,5 +4,5 @@ Website = "http://legu.cc" Icon = "app.png" Name = "RobotGUI" ID = "cc.legu.app" - Version = "1.2.6" - Build = 34 + Version = "1.2.7" + Build = 37 diff --git a/cmd/v2/main.go b/cmd/v2/main.go index 57ab30cef..7bf4c815c 100644 --- a/cmd/v2/main.go +++ b/cmd/v2/main.go @@ -27,11 +27,10 @@ import ( ) var ( - connService service.ConnService - pttService service.PttService - configService service.ConfigService - obs = observer.NewObserver() - logger *logrus.Logger + connService service.ConnService + pttService service.PttService + obs = observer.NewObserver() + logger *logrus.Logger ) // @@ -44,10 +43,10 @@ func init() { os.Exit(1) } - if err = setupConfig(); err != nil { - fmt.Println(err) - os.Exit(1) - } + // if err = setupConfig(); err != nil { + // fmt.Println(err) + // os.Exit(1) + // } if err = setupWsConn(); err != nil { fmt.Println(err) @@ -65,7 +64,7 @@ func main() { app := app.NewWithID("df-toolkit") app.SetIcon(theme.ResourceAppPng) - appUI, err := ui.NewUI(app, configService, connService, pttService, obs) + appUI, err := ui.NewUI(app, connService, pttService, obs) if err != nil { w := fyne.CurrentApp().NewWindow("错误") w.SetContent(canvas.NewText(err.Error(), color.RGBA{255, 0, 0, 255})) @@ -135,18 +134,6 @@ func setupWsConn() (err error) { return } -func setupConfig() (err error) { - configService, err = service.NewConfigService() - if err != nil { - return - } - if err = configService.ApplyConfig(); err != nil { - return - } - - return -} - func setupLogger() (err error) { logrus.SetFormatter(&logrus.JSONFormatter{ TimestampFormat: "2006-01-02 15:04:05", @@ -176,7 +163,7 @@ func setupLogger() (err error) { // check version func checkVersion(app fyne.App, parent fyne.Window) { logrus.Debug("check version") - b, err := connService.HttpConnect(configService.GetConfig().UpgradeUrl + "version") + b, err := connService.HttpConnect("http://10.0.0.9:8080/" + "version") if err != nil { dialog.ShowError(errors.New("版本检查:"+err.Error()), parent) return @@ -207,7 +194,7 @@ func checkVersion(app fyne.App, parent fyne.Window) { cmd := exec.Command(run, uri) return cmd.Run() } - _ = open(configService.GetConfig().UpgradeUrl) + _ = open("http://10.0.0.9:8080/") defer parent.Close() }, parent) chkDialog.SetConfirmText(common.BUTTON_OK) diff --git a/cmd/v2/resources/config.yaml b/cmd/v2/resources/config.yaml deleted file mode 100644 index 13ef87505..000000000 --- a/cmd/v2/resources/config.yaml +++ /dev/null @@ -1,26 +0,0 @@ -upgradeUrl: http://10.0.0.9:8080/ -services: - - service: - sid: "df01" - name: 外网 - url: ws://119.3.89.14:9891/gateway - - service: - sid: "dfz" - name: 赵长远 - url: ws://10.0.0.238:7891/gateway - - service: - sid: "df01" - name: 内网 - url: ws://10.0.0.9:7891/gateway - - service: - sid: "dfmxf" - name: 梅雄风 - url: ws://10.0.0.85:7891/gateway - - service: - sid: "dflw" - name: 李伟 - url: ws://10.0.0.85:7891/gateway - - service: - sid: "df01" - name: 压测服 - url: ws://106.54.189.74:7891/gateway diff --git a/cmd/v2/service/configService.go b/cmd/v2/service/configService.go deleted file mode 100644 index 7e5a2341d..000000000 --- a/cmd/v2/service/configService.go +++ /dev/null @@ -1,106 +0,0 @@ -package service - -import ( - "fmt" - "go_dreamfactory/cmd/v2/lib/common" - - "github.com/sirupsen/logrus" - "github.com/spf13/viper" -) - -type ConfigService interface { - GetConfig() *Config - LoadConfig() error - ApplyConfig() error -} - -type ConfigServiceImpl struct { - ResourcePath string - Config *Config -} - -type ServiceConf struct { - SId string `yaml:"sid"` - Name string `yaml:"name"` - Url string `yaml:"url"` -} - -type Services struct { - Service *ServiceConf `yaml:"service"` -} - -type Config struct { - Services []*Services `yaml:"services"` - UpgradeUrl string `yaml:"upgradeUrl"` -} - -func NewConfigService() (ConfigService, error) { - srv := &ConfigServiceImpl{ - ResourcePath: common.DEFAULT_RESOURCE_PATH, - Config: &Config{}, - } - err := srv.init() - return srv, err -} - -func (c *ConfigServiceImpl) LoadConfig() error { - viper.AddConfigPath("./" + c.ResourcePath) - return viper.ReadInConfig() -} - -func (c *ConfigServiceImpl) ApplyConfig() error { - if err := c.LoadConfig(); err != nil { - logrus.Error(err) - return err - } - if err := viper.Unmarshal(c.Config); err != nil { - logrus.Error(err) - return err - } - return nil -} - -func (c *ConfigServiceImpl) Unmarshal() error { - if sArr, ok := viper.Get("services").([]interface{}); ok { - for _, service := range sArr { - if services, ok := service.(map[interface{}]interface{}); ok { - for _, v := range services { - if vv, ok := v.(map[interface{}]interface{}); ok { - for k, _ := range vv { - kk := k.(string) - logrus.Debug(vv[kk]) - srvConf := &ServiceConf{} - switch kk { - case "sid": - srvConf.SId = vv[kk].(string) - case "name": - srvConf.Name = vv[kk].(string) - case "url": - srvConf.Url = vv[kk].(string) - default: - return fmt.Errorf("config key[%s] not foud", kk) - } - c.Config.Services = append(c.Config.Services, &Services{}) - } - - } - logrus.Debug(v) - // if v - } - - } - } - - } - return nil -} - -func (c *ConfigServiceImpl) GetConfig() *Config { - return c.Config -} - -func (c *ConfigServiceImpl) init() error { - viper.SetConfigName("config") - viper.SetConfigType("yaml") - return nil -} diff --git a/cmd/v2/ui/ui.go b/cmd/v2/ui/ui.go index 171f3055b..8d2746674 100644 --- a/cmd/v2/ui/ui.go +++ b/cmd/v2/ui/ui.go @@ -22,19 +22,17 @@ type UI interface { } type UIImpl struct { - app fyne.App - windows map[string]fyne.Window - winMux *sync.Mutex - connService service.ConnService - pttService service.PttService - configService service.ConfigService - obs observer.Observer - storage storage.Storage - config *storage.Config + app fyne.App + windows map[string]fyne.Window + winMux *sync.Mutex + connService service.ConnService + pttService service.PttService + obs observer.Observer + storage storage.Storage + config *storage.Config } func NewUI(app fyne.App, - configService service.ConfigService, connService service.ConnService, pttService service.PttService, obs observer.Observer, @@ -54,15 +52,14 @@ func NewUI(app fyne.App, return nil, err } return &UIImpl{ - app: app, - windows: make(map[string]fyne.Window), - winMux: &sync.Mutex{}, - configService: configService, - connService: connService, - pttService: pttService, - obs: obs, - storage: iStorage, - config: config, + app: app, + windows: make(map[string]fyne.Window), + winMux: &sync.Mutex{}, + connService: connService, + pttService: pttService, + obs: obs, + storage: iStorage, + config: config, }, nil } diff --git a/modules/rtask/module.go b/modules/rtask/module.go index bdb87e38c..fa141a490 100644 --- a/modules/rtask/module.go +++ b/modules/rtask/module.go @@ -15,7 +15,6 @@ import ( cfg "go_dreamfactory/sys/configure/structs" "go_dreamfactory/sys/db" "go_dreamfactory/utils" - "runtime" "github.com/pkg/errors" ) @@ -296,12 +295,9 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T module, err := this.service.GetModule(comm.ModuleWorldtask) if err == nil { go func() { - defer func() { //程序异常 收集异常信息传递给前端显示 + defer func() { if r := recover(); r != nil { - buf := make([]byte, 4096) - l := runtime.Stack(buf, false) - - log.Errorf("[Handle Api] m:%s ", fmt.Sprintf("%v: %s", r, buf[:l])) + log.Errorf("[worldtask ] err:%v ", r) } }() // 世界任务 @@ -338,9 +334,7 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T go func() { defer func() { //程序异常 收集异常信息传递给前端显示 if r := recover(); r != nil { - buf := make([]byte, 4096) - l := runtime.Stack(buf, false) - log.Errorf("[Handle Api] m:%s ", fmt.Sprintf("%v: %s", r, buf[:l])) + log.Errorf("[sociatytask ] err:%v ", r) } }() // 公会 diff --git a/modules/user/module.go b/modules/user/module.go index b51b4d983..6c8bfbfc4 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -662,22 +662,22 @@ func (this *User) BingoSetUserLv(session comm.IUserSession, lv int32) error { return nil } -func (this *User) Update() { - if this.IsCross() { - return - } - cu, err := this.UserOnlineList() - if err != nil { - return - } +// func (this *User) Update() { +// if this.IsCross() { +// return +// } +// cu, err := this.UserOnlineList() +// if err != nil { +// return +// } - for _, v := range cu { - if isession, ok := this.ModuleBase.GetUserSession(v.Uid); ok { - //del session - log.Debug("del session", log.Field{Key: "uid", Value: v.Uid}, log.Field{Key: "isLogin", Value: isession.IsLogin()}) - } - } -} +// for _, v := range cu { +// if isession, ok := this.ModuleBase.GetUserSession(v.Uid); ok { +// //del session +// log.Debug("del session", log.Field{Key: "uid", Value: v.Uid}, log.Field{Key: "isLogin", Value: isession.IsLogin()}) +// } +// } +// } // 玩家体力恢复 func (this *User) RecoverUserPsStart(uid string) {