Skip to content

Commit c1e8945

Browse files
quanquan2100vanoneang
authored andcommitted
完善头像修改逻辑 (#172)
* feat(*): 头像裁剪功能添加清空input控制, 删除多余文件 * fix(User): 修复用户未初始头像时默认头像图片显示错误 fix(User): 修复用户未初始头像时默认头像图片显示错误
1 parent 82d7850 commit c1e8945

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/components/layout/User.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ export default {
182182
croppa: {},
183183
imgInfo: null,
184184
quality: 1,
185+
defaultAvarta,
185186
}
186187
},
187188
computed: {
@@ -213,9 +214,9 @@ export default {
213214
return
214215
}
215216
const imgFile = evt.target.files[0]
216-
// 验证文件大小是否符合要求, 不大于2M
217-
if (imgFile.size > 1024 * 1024 * 3) {
218-
this.$message.error('文件过大超过3M')
217+
// 验证文件大小是否符合要求, 不大于 5M
218+
if (imgFile.size > 1024 * 1024 * 5) {
219+
this.$message.error('文件过大超过5M')
219220
// 清空输入框
220221
this.clearFileInput(this.$refs.avatarInput)
221222
return
@@ -268,6 +269,8 @@ export default {
268269
file,
269270
},
270271
}).then((res) => {
272+
// 清空输入框
273+
this.clearFileInput(this.$refs.avatarInput)
271274
if (!Array.isArray(res) || res.length !== 1) {
272275
this.$message.error('头像上传失败, 请重试')
273276
return false
@@ -346,6 +349,10 @@ export default {
346349
resetForm(formName) {
347350
this.$refs[formName].resetFields()
348351
},
352+
clearFileInput(ele) {
353+
// eslint-disable-next-line
354+
ele.value = ''
355+
},
349356
},
350357
}
351358
</script>

0 commit comments

Comments
 (0)