Profile Settings

master
taoshihan 2 months ago
parent 5efe4dc591
commit 3cc7d32032

@ -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,

@ -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{

@ -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)

@ -4,40 +4,13 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<title>GO语言开源客服系统-GOFLY</title>
<title>Go Open Source Live Chat Software</title>
<link rel="stylesheet" href="/static/cdn/element-ui/2.15.1/theme-chalk/index.min.css">
<script src="/static/cdn/vue/2.6.11/vue.min.js"></script>
<script src="/static/cdn/element-ui/2.15.1/index.js"></script>
<script src="/static/cdn/jquery/3.6.0/jquery.min.js"></script>
<script src="/static/js/functions.js"></script>
<link rel="stylesheet" href="/static/css/common.css">
<style>
html,
body {
height: 100%;
padding: 0;
margin: 0;
}
body {
overflow: hidden;
background-color: #f5f5f5;
}
.el-aside .el-menu{
border-right: none;
}
.mainMain{
background: #fff;
/*margin-left: 10px;*/
margin-bottom: 60px;
}
.mainIframe{
width: 100%;
height: 100%;
}
.el-card__body{
cursor: pointer;
}
</style>
</head>
<body class="text-center">

@ -52,7 +52,7 @@
<div class="mainLeftMenu">
<div style="margin: 20px auto;">
<el-badge :type="onlineType" is-dot class="item">
<el-avatar class="mainLogo" title="Customer Support" :size="45" src="/static/images/1.jpg"></el-avatar>
<el-avatar class="mainLogo" title="Customer Support" :size="45" :src="adminAvator"></el-avatar>
</el-badge>
</div>
<div class="menuLeftItem active" v-on:click="openIframeUrl('/pannel')">

@ -1,7 +1,6 @@
{{template "header"}}
<style>
.deployment-guide {
max-width: 1200px;
margin: 20px auto;
padding: 24px;
background: #fff;

@ -1,13 +1,152 @@
{{template "header" }}
<div id="app" style="width:100%">
{{template "header"}}
<style>
/* Enhanced Uploader Styles */
.avatar-uploader .el-upload {
border: 2px dashed #dcdfe6;
border-radius: 8px;
cursor: pointer;
position: relative;
overflow: hidden;
transition: all 0.3s ease;
}
.avatar-uploader .el-upload:hover {
border-color: #409EFF;
box-shadow: 0 2px 12px 0 rgba(64, 158, 255, 0.2);
}
.avatar-uploader-icon {
font-size: 32px;
color: #c0c4cc;
width: 180px;
height: 180px;
line-height: 180px;
text-align: center;
}
.avatar {
width: 180px;
height: 180px;
display: block;
object-fit: cover;
border-radius: 6px;
}
/* Form Styling */
.profile-form {
margin: 0 auto;
padding: 24px;
background: #fff;
border-radius: 8px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
}
.form-section {
margin-bottom: 32px;
}
.form-title {
font-size: 18px;
color: #303133;
margin-bottom: 24px;
padding-bottom: 12px;
border-bottom: 1px solid #ebeef5;
}
.el-form-item__label {
font-weight: 500;
color: #606266;
}
/* Table Styling */
.config-table {
margin-top: 32px;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
}
.config-textarea .el-textarea__inner {
min-height: 80px !important;
font-family: monospace;
}
</style>
<div id="app" style="width:100%; background: #f5f7fa; padding: 20px;">
<template>
<el-container v-loading.fullscreen.lock="fullscreenLoading">
<div class="profile-form">
<h3 class="form-title">Profile Settings</h3>
{{template "setting_left" .}}
<iframe class="mainIframe" v-bind:src="iframeUrl" frameborder="0"></iframe>
</el-container>
</template>
<el-form :model="modifyPass" label-width="180px" label-position="left">
<el-form-item label="Username">
<el-input v-model="kefuInfo.username" placeholder="Enter your username"></el-input>
</el-form-item>
<el-form-item label="Display Name">
<el-input v-model="kefuInfo.nickname" placeholder="Enter your display name"></el-input>
</el-form-item>
<el-form-item label="New Password">
<el-input
v-model="kefuInfo.password"
type="password"
placeholder="Enter new password"
show-password>
</el-input>
</el-form-item>
<el-form-item label="Current Avatar">
<el-avatar :size="120" :src="kefuInfo.avator"></el-avatar>
</el-form-item>
<el-form-item label="Upload New Avatar">
<el-upload
class="avatar-uploader"
action="/uploadimg"
:show-file-list="false"
name="imgfile"
:on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload">
<i class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
<div class="el-upload__tip">JPG/PNG files with size less than 2MB</div>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="setUser()">Save Changes</el-button>
</el-form-item>
</el-form>
</div>
<div class="profile-form" style="margin-top: 20px">
<h3 class="form-title">System Configuration</h3>
<el-table
:data="configList"
class="config-table"
stripe
style="width: 100%">
<el-table-column
width="180"
prop="conf_name"
label="Parameter Name">
</el-table-column>
<el-table-column
prop="conf_key"
label="Configuration Key"
width="180">
</el-table-column>
<el-table-column
prop="id"
label="Value">
<template slot-scope="scope">
<el-input
type="textarea"
class="config-textarea"
@change="setConfigItem(scope.row.conf_key,scope.row.conf_value)"
v-model="scope.row.conf_value"
:autosize="{ minRows: 1, maxRows: 4 }">
</el-input>
</template>
</el-table-column>
</el-table>
</div>
</template>
</div>
</body>
{{template "setting_bottom" .}}
{{template "setting_bottom" .}}

@ -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({

@ -10,28 +10,6 @@
<el-main class="mainMain">
<el-table
:data="configList"
border
style="width: 100%">
<el-table-column
width="150"
prop="conf_name"
label="配置参数">
</el-table-column>
<el-table-column
prop="conf_key"
label="配置key"
width="150"
>
</el-table-column>
<el-table-column
prop="id"
label="操作">
<template slot-scope="scope">
<el-input type="textarea" @change="setConfigItem(scope.row.conf_key,scope.row.conf_value)" v-model="scope.row.conf_value"></el-input>
</template>
</el-table-column>
</el-table>
</el-main>

Loading…
Cancel
Save