Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8d4cddb
New translations Home.vue (Japanese)
mortal-link Feb 9, 2023
2b18288
New translations Home.vue (English)
mortal-link Feb 9, 2023
14c6600
New translations aside.vue (Japanese)
mortal-link Feb 9, 2023
387e258
New translations aside.vue (English)
mortal-link Feb 9, 2023
dceb03b
New translations head.vue (Japanese)
mortal-link Feb 9, 2023
3c5a295
New translations head.vue (English)
mortal-link Feb 9, 2023
d8d5fc3
New translations Login.vue (Japanese)
mortal-link Feb 9, 2023
503d027
New translations Login.vue (English)
mortal-link Feb 9, 2023
112695f
New translations back.jpg (Japanese)
mortal-link Feb 9, 2023
d52c38f
New translations back.jpg (English)
mortal-link Feb 9, 2023
8841a86
New translations Comments.vue (Japanese)
mortal-link Feb 9, 2023
ad1aa96
New translations Comments.vue (English)
mortal-link Feb 9, 2023
9a0b99e
New translations Content.vue (Japanese)
mortal-link Feb 9, 2023
40699f9
New translations Content.vue (English)
mortal-link Feb 9, 2023
bc252ae
New translations none.png (Japanese)
mortal-link Feb 9, 2023
36b6953
New translations none.png (English)
mortal-link Feb 9, 2023
ed7495c
New translations Fans.vue (Japanese)
mortal-link Feb 9, 2023
83f5d18
New translations Fans.vue (English)
mortal-link Feb 9, 2023
5e6d4c1
New translations First.vue (Japanese)
mortal-link Feb 9, 2023
1564bcb
New translations First.vue (English)
mortal-link Feb 9, 2023
997d06b
New translations Material.vue (Japanese)
mortal-link Feb 9, 2023
7781c55
New translations Material.vue (English)
mortal-link Feb 9, 2023
3f052dd
New translations imageList.vue (Japanese)
mortal-link Feb 9, 2023
fb7b580
New translations imageList.vue (English)
mortal-link Feb 9, 2023
1165e90
New translations tick.png (Japanese)
mortal-link Feb 9, 2023
7736e74
New translations tick.png (English)
mortal-link Feb 9, 2023
7534f8d
New translations Publish.vue (Japanese)
mortal-link Feb 9, 2023
ebb46c8
New translations Publish.vue (English)
mortal-link Feb 9, 2023
098acc7
New translations none.png (Japanese)
mortal-link Feb 9, 2023
eeebba4
New translations none.png (English)
mortal-link Feb 9, 2023
830381d
New translations Setting.vue (Japanese)
mortal-link Feb 9, 2023
6757936
New translations Setting.vue (English)
mortal-link Feb 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
221 changes: 221 additions & 0 deletions src/English
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
<template>
<div>
<el-card class="setting-card">
<el-col :span = 15>
<el-form :label-position="labelPosition" label-width="80px" :model="userInfo">
<el-form-item label="用户名">
{{userInfo.username}}
</el-form-item>
<el-form-item label="手机">
{{userInfo.phone}}
</el-form-item>
<el-form-item label="个人主页">
<el-input v-model="userInfo.page"></el-input>
</el-form-item>
<el-form-item label="个人介绍">
<el-input v-model="userInfo.introduction" type="textarea" :rows="4" placeholder="这个人很懒,什么也没说"></el-input>
</el-form-item>
<el-form-item label="邮箱">
<el-input v-model="userInfo.email"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="keepModi">保存修改</el-button>
</el-form-item>
</el-form>
</el-col>
<el-col :span="6" :offset=3 :xs="24">
<div class="avatar-wrapper" @click="$refs.file.click()">
<el-avatar :size="156" :src="userInfo.avatar" class="avatar">
</el-avatar>
<div class="avatar-cover">点击修改头像</div>
</div>
<input type="file" name="" id="" ref="file" @change="onFileChange">
</el-col>
</el-card>
<!-- 弹出层 -->
<el-dialog
title="修改图片"
append-to-body
:visible.sync="dialogVisible"
width="40%"
@opened="onDialogOpened"
@closed="onDialogClosed"
>
<div>
<img id="image" :src="previewURL" class="previewImg" ref="image-ref">
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">取 消</el-button>
<el-button type="primary" @click="onAvatarUpdate" :loading="loading">确 定</el-button>
</span>
</el-dialog>
</div>
</template>

<script>
import { getUserInfoRequest, updateUserProfile } from '@/api/user.js'
import { updateAvatar } from '@/api/setting.js'
import Cropper from 'cropperjs'
import 'cropperjs/dist/cropper.css'
import $BUS from '@/utils/Bus.js'

export default {
name: 'Setting',
data () {
return {
labelPosition: 'left',
userInfo: {
username: '',
page: '',
phone: '',
introduction: '',
email: '',
avatar: ''
},
dialogVisible: false,
previewURL: '',
cropper: null,
loading: false
}
},
methods: {
keepModi () {
updateUserProfile(this.userInfo)
.then((val) => {
// console.log(val)
this.$message({
message: '修改成功',
type: 'success'
})
})
},
onFileChange () {
const fileDom = this.$refs.file
const BlobData = window.URL.createObjectURL(fileDom.files[0])
this.previewURL = BlobData
this.$refs.file.value = ''
this.dialogVisible = true
},
onDialogOpened () {
// 裁剪
const image = this.$refs['image-ref']
if (this.cropper) {
this.cropper.replace(this.previewURL)
return
}
this.cropper = new Cropper(image, {
aspectRatio: 1 / 1,
dragMode: 'none',
viewMode: 1,
crop (event) {
// console.log(event.detail.x)
// console.log(event.detail.y)
// console.log(event.detail.width)
// console.log(event.detail.height)
// console.log(event.detail.rotate)
// console.log(event.detail.scaleX)
// console.log(event.detail.scaleY)
}
})
},

onDialogClosed () {
// this.cropper.destroy()
},
onAvatarUpdate () {
this.loading = true
this.cropper.getCroppedCanvas().toBlob(blob => {
// console.log(blob)
const fd = new FormData()
fd.append('avatar', blob)
updateAvatar(fd)
.then((val) => {
console.log(val)
this.dialogVisible = false
// this.userInfo.avatar = val.data 比较慢,需要再发请求
this.userInfo.avatar = window.URL.createObjectURL(blob)
this.loading = false
this.$message({
message: '头像更新成功',
type: 'success'
})
// 更新顶部 头像
$BUS.$emit('updateProfile', this.userInfo.avatar)
})
})
}
},

// 生命周期钩子
mounted () {
getUserInfoRequest()
.then((val) => {
this.userInfo = val.data.data
// console.log(this.userInfo)
})
}

}
</script>

<style lang="less" scoped>
.setting-card {
width: 84%;
margin-left: 22px;
}

.el-avatar{
}
// .el-col{
// height: 100%;
// }

input[type=file]{
display: none;
}
.avatar{
&:hover{
cursor: pointer;
// overflow: hidden;
// height: 200px;
}
}

.avatar-cover{
// display: none;
text-align: center;
line-height: 156px;
color: #fff;
visibility: hidden;
cursor: pointer;
position: absolute;
top: 0;
left: 0;
width: 156px;
height: 156px;
background-color: rgba(29,33,41,.5);
}

.avatar-wrapper{
position: relative;
// height: 400px;
width: 156px;
height: 156px;
border-radius: 50%;
overflow: hidden;
margin-top: 40px;
margin-bottom: 20px;
// margin-bottom: 20px;
&:hover .avatar-cover{
visibility: visible;
}
}
/* Ensure the size of the image fit the container perfectly */
.previewImg{
display: block;

/* This rule is very important, please don't ignore this */
max-width: 100%;
// max-height: 1200px;
}
</style>
Loading