From 3cc7d32032e51d6792ef4dd6523e2b799da42dda Mon Sep 17 00:00:00 2001 From: taoshihan Date: Tue, 22 Jul 2025 11:41:29 +0800 Subject: [PATCH] Profile Settings --- controller/kefu.go | 32 +----- models/users.go | 5 +- router/view.go | 1 + static/templates/header.html | 29 +---- static/templates/main.html | 2 +- static/templates/pannel.html | 1 - static/templates/setting.html | 155 +++++++++++++++++++++++++-- static/templates/setting_bottom.html | 25 ++--- static/templates/setting_config.html | 22 ---- 9 files changed, 165 insertions(+), 107 deletions(-) diff --git a/controller/kefu.go b/controller/kefu.go index 21da9a6..81083b8 100644 --- a/controller/kefu.go +++ b/controller/kefu.go @@ -202,11 +202,13 @@ func PostKefuRegister(c *gin.Context) { }) } func PostKefuInfo(c *gin.Context) { - id := c.PostForm("id") - name := c.PostForm("name") + name, _ := c.Get("kefu_name") password := c.PostForm("password") avator := c.PostForm("avator") nickname := c.PostForm("nickname") + if password != "" { + password = tools.Md5(password) + } if name == "" { c.JSON(200, gin.H{ "code": 400, @@ -214,31 +216,7 @@ func PostKefuInfo(c *gin.Context) { }) return } - //插入新用户 - if id == "" { - uid := models.CreateUser(name, tools.Md5(password), avator, nickname) - if uid == 0 { - c.JSON(200, gin.H{ - "code": 400, - "msg": "增加用户失败", - "result": "", - }) - return - } - } else { - //更新用户 - if password != "" { - password = tools.Md5(password) - } - message := &models.Message{ - KefuId: name, - } - models.DB.Model(&models.Message{}).Update(message) - visitor := &models.Visitor{ - ToId: name, - } - models.DB.Model(&models.Visitor{}).Update(visitor) - } + models.UpdateUser(name.(string), password, avator, nickname) c.JSON(200, gin.H{ "code": 200, diff --git a/models/users.go b/models/users.go index 1131ca2..7304bfc 100644 --- a/models/users.go +++ b/models/users.go @@ -26,9 +26,8 @@ func CreateUser(name string, password string, avator string, nickname string) ui DB.Create(user) return user.ID } -func UpdateUser(id string, name string, password string, avator string, nickname string) { +func UpdateUser(name string, password string, avator string, nickname string) { user := &User{ - Name: name, Avator: avator, Nickname: nickname, } @@ -36,7 +35,7 @@ func UpdateUser(id string, name string, password string, avator string, nickname if password != "" { user.Password = password } - DB.Model(&User{}).Where("id = ?", id).Update(user) + DB.Model(&User{}).Where("name = ?", name).Update(user) } func UpdateUserPass(name string, pass string) { user := &User{ diff --git a/router/view.go b/router/view.go index 1fa20ca..d73b16e 100644 --- a/router/view.go +++ b/router/view.go @@ -12,6 +12,7 @@ func InitViewRouter(engine *gin.Engine) { engine.GET("/login", tmpl.PageLogin) engine.GET("/pannel", tmpl.PagePannel) engine.GET("/chatIndex", tmpl.PageChat) + engine.GET("/livechat", tmpl.PageChat) engine.GET("/main", middleware.JwtPageMiddleware, tmpl.PageMain) engine.GET("/chat_main", middleware.JwtPageMiddleware, middleware.DomainLimitMiddleware, tmpl.PageChatMain) engine.GET("/setting", middleware.DomainLimitMiddleware, tmpl.PageSetting) diff --git a/static/templates/header.html b/static/templates/header.html index c064966..af0a31c 100644 --- a/static/templates/header.html +++ b/static/templates/header.html @@ -4,40 +4,13 @@ - GO语言开源客服系统-GOFLY + Go Open Source Live Chat Software - diff --git a/static/templates/main.html b/static/templates/main.html index 14e0b25..dab87e8 100644 --- a/static/templates/main.html +++ b/static/templates/main.html @@ -52,7 +52,7 @@
- +
-{{template "setting_bottom" .}} +{{template "setting_bottom" .}} \ No newline at end of file diff --git a/static/templates/setting_bottom.html b/static/templates/setting_bottom.html index 3a387ce..701d05f 100644 --- a/static/templates/setting_bottom.html +++ b/static/templates/setting_bottom.html @@ -190,15 +190,7 @@ //初始化数据 initInfo(){ let _this=this; - if(ACTION=="setting_mysql"){ - this.sendAjax("/mysql","get",{},function(result){ - _this.mysql.username=result.Username; - _this.mysql.password=result.Password; - _this.mysql.database=result.Database; - _this.mysql.server=result.Server; - _this.mysql.port=result.Port; - }); - } + if(ACTION=="setting_kefu_list"){ this.sendAjax("/kefulist","get",{},function(result){ _this.kefuList=result; @@ -227,11 +219,9 @@ _this.ipblackList=result.list; }); } - if(ACTION=="setting_config"){ - this.sendAjax("/configs","get",{},function(result){ - _this.configList=result; - }); - } + this.sendAjax("/configs","get",{},function(result){ + _this.configList=result; + }); if(ACTION=="setting_pageindex"){ this.sendAjax("/about","get",{},function(result){ _this.pageindex=result; @@ -445,16 +435,17 @@ }); }, //修改密码 - setModifyAvatar(){ + setUser(){ let _this=this; this.sendAjax("/kefuinfo","POST",{ id:_this.kefuInfo.uid, name:_this.kefuInfo.username, nickname:_this.kefuInfo.nickname, avator:_this.kefuInfo.avator, + password:_this.kefuInfo.password, },function(result){ _this.$message({ - message: "操作成功:注意,如果修改账户名,后台需重新登录", + message: "success", type: 'success' }); }); @@ -552,7 +543,7 @@ success: function(data) { if(data.code==200 && data.result!=null){ _this.kefuInfo=data.result; - _this.chatEndpoint=window.location.origin + '/chatIndex?kefu_id='+_this.kefuInfo.username; + _this.chatEndpoint=window.location.origin + '/livechat?kefu_id='+_this.kefuInfo.username; } if(data.code!=200){ _this.$message({ diff --git a/static/templates/setting_config.html b/static/templates/setting_config.html index 01811a7..3d61c54 100644 --- a/static/templates/setting_config.html +++ b/static/templates/setting_config.html @@ -10,28 +10,6 @@ - - - - - - - -