From fc64a179e8ad4518844c9811a02c1451b1b7543a Mon Sep 17 00:00:00 2001 From: Qing Date: Sat, 8 Jul 2023 01:00:34 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=B8=8A=E4=BC=A0=E5=AE=8C?= =?UTF-8?q?=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Project/ProjectDetail.vue | 8 +-- src/components/Project/ProjectPublish.vue | 15 +++++ src/components/User/UserComments.vue | 2 +- src/components/User/UserInfo.vue | 31 +++++++-- src/components/User/UserInfoPage.vue | 80 +++++++++++++++++------ 5 files changed, 106 insertions(+), 30 deletions(-) create mode 100644 src/components/Project/ProjectPublish.vue diff --git a/src/components/Project/ProjectDetail.vue b/src/components/Project/ProjectDetail.vue index 8382d64..a966a33 100644 --- a/src/components/Project/ProjectDetail.vue +++ b/src/components/Project/ProjectDetail.vue @@ -196,7 +196,7 @@
- {{item.username}} + {{item.username}}
@@ -222,7 +222,7 @@ {{item.commentTime}}
{{ formatNumber(item.likeNum) }} - 点赞 + 点赞
@@ -235,7 +235,7 @@
- {{item.username}} + {{item.username}}
@@ -602,7 +602,7 @@ export default { trait:'last' } }).then(function (res) { - console.log(res); + // console.log(res); that.commentContent=res.data; that.commentNum=Object.keys(that.commentContent).length; diff --git a/src/components/Project/ProjectPublish.vue b/src/components/Project/ProjectPublish.vue new file mode 100644 index 0000000..d38b419 --- /dev/null +++ b/src/components/Project/ProjectPublish.vue @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/src/components/User/UserComments.vue b/src/components/User/UserComments.vue index b0529c6..55642d5 100644 --- a/src/components/User/UserComments.vue +++ b/src/components/User/UserComments.vue @@ -13,7 +13,7 @@
- {{ this.$cookie.get('username') }} + {{ this.$cookie.get('username') }}
diff --git a/src/components/User/UserInfo.vue b/src/components/User/UserInfo.vue index a164ab3..e6ed346 100644 --- a/src/components/User/UserInfo.vue +++ b/src/components/User/UserInfo.vue @@ -6,7 +6,7 @@ {{this.$cookie.get('username')}}
{{this.$cookie.get('username')}} - Lv.1 + Lv.{{userLevel}}
@@ -39,11 +39,20 @@ export default { switchValue:false, ContributionValue:0, imageUrl:'', + userLevel:null, } }, + created() { + this.updateUserLevel(); + this.getUserInfo(); + }, mounted() { this.getContributionValue(); this.getUserInfo(); + setTimeout(()=>{ + this.updateUserLevel(); + this.getUserInfo(); + },1000) }, methods: { signOut() { @@ -124,15 +133,29 @@ export default { username: this.$cookie.get("username") } }).then(function (res) { - that.imageUrl = res.data.userAvatar; + that.userLevel=res.data.userLevel; + // that.imageUrl = res.data.userAvatar; // console.log(res); }); }else{ return; } + }, + updateUserLevel(){ + if(this.$cookie.get("username")!=null){ + axios({ + method: 'post', + // 请求的地址 + url: 'http://localhost:8082/helloGithub_war_exploded/levelup', + // URL 中的查询参数 + params: { - - } + } + }); + }else{ + return; + } + }, } } diff --git a/src/components/User/UserInfoPage.vue b/src/components/User/UserInfoPage.vue index 23463fe..109fc5a 100644 --- a/src/components/User/UserInfoPage.vue +++ b/src/components/User/UserInfoPage.vue @@ -20,7 +20,7 @@
{{username}} - Lv.1 + Lv.{{userLevel}}
你是 HelloGitHub 社区的第 {{userId}} 位用户,于 {{creatTime}} 加入。 @@ -104,7 +104,8 @@ append-to-body :close-on-click-modal="false" > -
+ 选择一种方式即可! +
@@ -158,12 +159,25 @@ export default { article:[], openChangeAvatar:false, AvatarUrl:'', - imageUrl:'', + imageUrl:'http://localhost:8082/helloGithub_war_exploded/retUserAv', + userLevel:null, } }, mounted() { this.getUserInfo() this.getUserDetail(); + setTimeout(()=>{ + this.updateUserLevel(); + this.getUserInfo(); + },1000) + // this.changeAvatarByLocal(); + + }, + created() { + this.updateUserLevel(); + this.getUserInfo(); + + }, watch: { $route () { @@ -171,7 +185,7 @@ export default { this.getUserInfo() //重新调用http请求实现页面的重新渲染 this.getUserDetail(); } - } + }, }, computed: { headers() { @@ -200,7 +214,8 @@ export default { that.creatTime=res.data.creatTime; that.projectNum=res.data.projectNum; that.userId=res.data.userId; - that.imageUrl=res.data.userAvatar; + // that.imageUrl=res.data.userAvatar; + that.userLevel=res.data.userLevel; }); }, getUserDetail(){ @@ -219,14 +234,33 @@ export default { that.commentList=JSON.parse(res.data.comment); that.like=JSON.parse(res.data.like) that.article=JSON.parse(res.data.article); - console.log(that.commentList); + // console.log(that.commentList); }); }, + updateUserLevel(){ + if(this.$cookie.get("username")!=null){ + axios({ + method: 'post', + // 请求的地址 + url: 'http://localhost:8082/helloGithub_war_exploded/levelup', + // URL 中的查询参数 + params: { + + } + }); + }else{ + return; + } + }, changeAvatar(){ - this.openChangeAvatar=true; + if(this.$route.query.name!==this.$cookie.get('username')){ + return; + }else{ + this.openChangeAvatar=true; + } + }, changeAvatarByUrl(){ - var that=this; if(this.AvatarUrl!==''){ axios({ method: 'post', @@ -244,7 +278,6 @@ export default { type: 'success', offset: 50 }); - that.$root.URL=that.imageUrl; }else{ Vue.prototype.$notify.error({ title: '错误', @@ -265,6 +298,7 @@ export default { }, upload(params){ + var that=this; const formData = new FormData(); formData.append("file", params.file); axios({ @@ -273,36 +307,40 @@ export default { url: '/upload/UploadHandle', headers:{"Content-Type": "multipart/form-data"}, // URL 中的查询参数 - data:formData + data:formData, + params: { + username: this.$cookie.get('username') + } }).then((res)=>{ - console.log(res); - if(res.data.code===200){ - Vue.prototype.$notify({ - title: '成功', - message: ('i', {style: 'color: teal'}, res.data.msg), - type: 'success', - offset: 50 - }); - }else{ + if(res.data.code===500){ Vue.prototype.$notify.error({ title: '错误', message: res.data.msg, offset: 50 }); + }else{ + Vue.prototype.$notify({ + title: '成功', + message: ('i', {style: 'color: teal'}, "上传成功"), + type: 'success', + offset: 50 + }); + that.openChangeAvatar=false; } }) }, changeAvatarByLocal(){ + var that=this; axios({ method: 'post', // 请求的地址 - url: 'http://localhost:8082/helloGithub_war_exploded/retUserAv', + url: '/api/retUserAv', // URL 中的查询参数 responseType: 'blob', }).then((res)=>{ - console.log(res); + }) },