Skip to content

Commit ef5c664

Browse files
author
QM303176530
committed
前端代码优化 修改密码迁移至个人中心内部
1 parent e13f1f6 commit ef5c664

File tree

8 files changed

+211
-175
lines changed

8 files changed

+211
-175
lines changed

server/api/v1/sys_user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func ChangePassword(c *gin.Context) {
144144
U := &model.SysUser{Username: user.Username, Password: user.Password}
145145
if err, _ := service.ChangePassword(U, user.NewPassword); err != nil {
146146
global.GVA_LOG.Error("修改失败", zap.Any("err", err))
147-
response.FailWithMessage("修改失败,请检查用户名密码", c)
147+
response.FailWithMessage("修改失败,原密码与当前账户不符", c)
148148
} else {
149149
response.OkWithMessage("修改成功", c)
150150
}

server/cmd/datas/users.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
var Users = []model.SysUser{
14-
{GVA_MODEL: global.GVA_MODEL{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, UUID: uuid.NewV4(), Username: "admin", Password: "e10adc3949ba59abbe56e057f20f883e", NickName: "超级管理员", HeaderImg: "http://qmplusimg.henrongyi.top/1571627762timg.jpg", AuthorityId: "888"},
14+
{GVA_MODEL: global.GVA_MODEL{ID: 1, CreatedAt: time.Now(), UpdatedAt: time.Now()}, UUID: uuid.NewV4(), Username: "admin", Password: "e10adc3949ba59abbe56e057f20f883e", NickName: "超级管理员", HeaderImg: "http://qmplusimg.henrongyi.top/gva_header.jpg", AuthorityId: "888"},
1515
{GVA_MODEL: global.GVA_MODEL{ID: 2, CreatedAt: time.Now(), UpdatedAt: time.Now()}, UUID: uuid.NewV4(), Username: "a303176530", Password: "3ec063004a6f31642261936a379fde3d", NickName: "QMPlusUser", HeaderImg: "http://qmplusimg.henrongyi.top/1572075907logo.png", AuthorityId: "9528"},
1616
}
1717

server/core/server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ func RunWindowsServer() {
2929

3030
fmt.Printf(`
3131
欢迎使用 Gin-Vue-Admin
32-
当前版本:V2.3.4
32+
当前版本:V2.3.5
3333
默认自动化文档地址:http://127.0.0.1%s/swagger/index.html
3434
默认前端文件运行地址:http://127.0.0.1:8080
35+
如果项目让您获得了收益,希望您能请团队喝杯可乐:https://www.gin-vue-admin.com/docs/coffee
3536
`, address)
3637
global.GVA_LOG.Error(s.ListenAndServe().Error())
3738
}

web/src/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ Vue.prototype.$echarts = echarts;
6666

6767
console.log(`
6868
欢迎使用 Gin-Vue-Admin
69-
当前版本:V2.3.4
69+
当前版本:V2.3.5
7070
默认自动化文档地址:http://127.0.0.1%s/swagger/index.html
7171
默认前端文件运行地址:http://127.0.0.1:8080
72+
如果项目让您获得了收益,希望您能请团队喝杯可乐:https://www.gin-vue-admin.com/docs/coffee
7273
`)

web/src/style/main.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,7 @@ $mainHight: 100vh;
11911191
display: inline-block;
11921192
overflow: hidden;
11931193
height: 60px;
1194-
width: 40px;
1194+
width: 120px;
11951195
text-align: center;
11961196
.el-input__inner {
11971197
border: none;
@@ -1215,7 +1215,7 @@ $mainHight: 100vh;
12151215

12161216
.transition-box {
12171217
overflow: hidden;
1218-
width: 40px;
1218+
width: 120px;
12191219
text-align: center;
12201220
}
12211221

web/src/view/layout/index.vue

Lines changed: 2 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
<el-badge is-dot />
4444
</span>
4545
</el-dropdown-item>
46-
<el-dropdown-item @click.native="showPassword=true" icon="el-icon-s-custom">修改密码</el-dropdown-item>
4746
<el-dropdown-item @click.native="toPerson" icon="el-icon-s-custom">个人信息</el-dropdown-item>
4847
<el-dropdown-item @click.native="LoginOut" icon="el-icon-table-lamp">登 出</el-dropdown-item>
4948
</el-dropdown-menu>
@@ -67,23 +66,7 @@
6766
<BottomInfo />
6867
</el-main>
6968
</el-container>
70-
<el-dialog :visible.sync="showPassword" @close="clearPassword" title="修改密码" width="360px">
71-
<el-form :model="pwdModify" :rules="rules" label-width="80px" ref="modifyPwdForm">
72-
<el-form-item :minlength="6" label="原密码" prop="password">
73-
<el-input show-password v-model="pwdModify.password"></el-input>
74-
</el-form-item>
75-
<el-form-item :minlength="6" label="新密码" prop="newPassword">
76-
<el-input show-password v-model="pwdModify.newPassword"></el-input>
77-
</el-form-item>
78-
<el-form-item :minlength="6" label="确认密码" prop="confirmPassword">
79-
<el-input show-password v-model="pwdModify.confirmPassword"></el-input>
80-
</el-form-item>
81-
</el-form>
82-
<div class="dialog-footer" slot="footer">
83-
<el-button @click="showPassword=false">取 消</el-button>
84-
<el-button @click="savePassword" type="primary">确 定</el-button>
85-
</div>
86-
</el-dialog>
69+
8770
</el-container>
8871
</template>
8972

@@ -94,7 +77,6 @@ import Screenfull from '@/view/layout/screenfull'
9477
import Search from '@/view/layout/search/search'
9578
import BottomInfo from '@/view/layout/bottomInfo/bottomInfo'
9679
import { mapGetters, mapActions } from 'vuex'
97-
import { changePassword } from '@/api/user'
9880
import CustomPic from '@/components/customPic'
9981
export default {
10082
name: 'Layout',
@@ -105,33 +87,8 @@ export default {
10587
isSider: true,
10688
isMobile: false,
10789
isShadowBg: false,
108-
showPassword: false,
10990
loadingFlag:false,
110-
pwdModify: {},
111-
rules: {
112-
password: [
113-
{ required: true, message: '请输入密码', trigger: 'blur' },
114-
{ min: 6, message: '最少6个字符', trigger: 'blur' }
115-
],
116-
newPassword: [
117-
{ required: true, message: '请输入新密码', trigger: 'blur' },
118-
{ min: 6, message: '最少6个字符', trigger: 'blur' }
119-
],
120-
confirmPassword: [
121-
{ required: true, message: '请输入确认密码', trigger: 'blur' },
122-
{ min: 6, message: '最少6个字符', trigger: 'blur' },
123-
{
124-
validator: (rule, value, callback) => {
125-
if (value !== this.pwdModify.newPassword) {
126-
callback(new Error('两次密码不一致'))
127-
} else {
128-
callback()
129-
}
130-
},
131-
trigger: 'blur'
132-
}
133-
]
134-
},
91+
13592
value: ''
13693
}
13794
},
@@ -159,30 +116,6 @@ export default {
159116
this.isSider = !!this.isCollapse
160117
this.totalCollapse()
161118
},
162-
savePassword() {
163-
this.$refs.modifyPwdForm.validate(valid => {
164-
if (valid) {
165-
changePassword({
166-
username: this.userInfo.userName,
167-
password: this.pwdModify.password,
168-
newPassword: this.pwdModify.newPassword
169-
}).then(() => {
170-
this.$message.success('修改密码成功!')
171-
this.showPassword = false
172-
})
173-
} else {
174-
return false
175-
}
176-
})
177-
},
178-
clearPassword() {
179-
this.pwdModify = {
180-
password: '',
181-
newPassword: '',
182-
confirmPassword: ''
183-
}
184-
this.$refs.modifyPwdForm.clearValidate()
185-
}
186119
},
187120
computed: {
188121
...mapGetters('user', ['userInfo']),

web/src/view/layout/search/search.vue

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<transition name="el-fade-in-linear">
44
<div class="transition-box" style="display: inline-block; " v-show="show">
55
<el-select
6+
ref="search-input"
67
@blur="hiddenSearch"
78
@change="changeRouter"
89
filterable
@@ -18,36 +19,41 @@
1819
</el-select>
1920
</div>
2021
</transition>
21-
<div :style="{display:'inline-block'}" class="user-box">
22-
<i @click="show = !show" class="el-icon-search search-icon"></i>
22+
<div :style="{display:'inline-block',float:'right'}" class="user-box">
23+
<i @click="showSearch()" class="el-icon-search search-icon"></i>
2324
</div>
2425
</div>
2526
</template>
2627
<script>
27-
import { mapGetters } from 'vuex'
28+
import { mapGetters } from "vuex";
2829
2930
export default {
30-
name: 'searchComponent',
31+
name: "searchComponent",
3132
data() {
3233
return {
33-
value: '',
34+
value: "",
3435
show: false
35-
}
36+
};
3637
},
3738
computed: {
38-
...mapGetters('router', ['routerList'])
39+
...mapGetters("router", ["routerList"])
3940
},
4041
methods: {
4142
changeRouter() {
42-
this.$router.push({ name: this.value })
43-
this.value = ''
43+
this.$router.push({ name: this.value });
44+
this.value = "";
4445
},
4546
hiddenSearch() {
46-
this.show = false
47+
this.show = false;
48+
},
49+
showSearch() {
50+
this.show = true;
51+
this.$nextTick(()=>{
52+
this.$refs['search-input'].focus()
53+
})
4754
}
4855
}
49-
}
56+
};
5057
</script>
5158
<style lang="scss">
52-
5359
</style>

0 commit comments

Comments
 (0)