add 用户头像上传

This commit is contained in:
2023-07-07 21:39:51 +08:00
parent 2db7db4aef
commit eaffa1ace3
9 changed files with 399 additions and 67 deletions

View File

@@ -2,7 +2,8 @@
<div style="display: flex;flex-direction: column;flex-wrap: nowrap" v-show="this.$cookie.get('username')!=null">
<div style="display: flex;flex-direction: row;align-items: center;width: 11vw;justify-content: space-between">
<div @click="toUserPage" style="display: flex;flex-direction: row;align-items: center">
<el-avatar shape="square" style=" cursor: pointer;background-color: #59A3A4;box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04)" size="large">{{this.$cookie.get('username')}}</el-avatar>
<!-- <el-avatar v-if="imageUrl===''" shape="square" style=" cursor: pointer;box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04)" size="large"></el-avatar>-->
<el-avatar shape="square" style=" cursor: pointer;box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04)" :src="imageUrl" size="large">{{this.$cookie.get('username')}}</el-avatar>
<div style="margin-left: 5px;display: flex;flex-direction: column;justify-content: space-evenly">
<span style="cursor: pointer;font-weight: bold">{{this.$cookie.get('username')}}</span>
<span style="cursor: pointer;font-weight: 800;font-size: 13px;color: #3b82f6">Lv.1</span>
@@ -37,13 +38,15 @@ export default {
return{
switchValue:false,
ContributionValue:0,
imageUrl:'',
}
},
mounted() {
this.getContributionValue();
this.getUserInfo();
},
methods:{
signOut(){
methods: {
signOut() {
this.$cookie.delete('username');
// deletecookie
axios({
@@ -51,29 +54,27 @@ export default {
// 请求的地址
url: 'http://localhost:8082/helloGithub_war_exploded/deletesession',
// URL 中的查询参数
params: {
}
params: {}
});
if(this.$cookie.get('username')===null){
if (this.$cookie.get('username') === null) {
Vue.prototype.$notify({
title: '成功',
message: ('i', {style: 'color: teal'}, "退出成功!"),
type: 'success',
offset: 50
});
if(this.$route.path!=='/home'){
setTimeout(()=>{
if (this.$route.path !== '/home') {
setTimeout(() => {
this.$router.push({
path:'/home'
path: '/home'
})
},800)
}else {
}, 800)
} else {
window.location.reload();
}
}else{
} else {
Vue.prototype.$notify.error({
title: '错误',
message: ('i', {style: 'color: teal'}, "退出失败!"),
@@ -84,33 +85,53 @@ export default {
},
toUserPage(){
toUserPage() {
this.$router.push({
path:'/UserInfoPage',
query: {
path: '/UserInfoPage',
query: {
name: this.$cookie.get('username'),
refresh: true
}})
}
})
},
getContributionValue(){
var that=this;
getContributionValue() {
var that = this;
axios({
method: 'post',
// 请求的地址
url: 'http://localhost:8082/helloGithub_war_exploded/contributionValue',
// URL 中的查询参数
params: {
}
}).then((res)=>{
params: {}
}).then((res) => {
// console.log(res);
if(res.data.code===500){
if (res.data.code === 500) {
return;
}else{
that.ContributionValue=res.data;
} else {
that.ContributionValue = res.data;
}
});
},
getUserInfo() {
var that = this;
if(this.$cookie.get("username")!=null){
axios({
method: 'post',
// 请求的地址
url: 'http://localhost:8082/helloGithub_war_exploded/retUser',
// URL 中的查询参数
params: {
username: this.$cookie.get("username")
}
}).then(function (res) {
that.imageUrl = res.data.userAvatar;
// console.log(res);
});
}else{
return;
}
}
}
}